mirror of
https://github.com/git/git.git
synced 2024-11-18 06:03:53 +01:00
7cf67205ca
Now if GIT_TRACE is set to an integer value greater than 1 and lower than 10, we interpret this as an open fd value and we trace into it. Note that this behavior is not compatible with the previous one. We also trace whole messages using one write(2) call to make sure messages from processes do net get mixed up in the middle. It's now possible to run the tests like this: GIT_TRACE=9 make test 9>/var/tmp/trace.log Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
46 lines
831 B
C
46 lines
831 B
C
#include "cache.h"
|
|
|
|
void write_or_die(int fd, const void *buf, size_t count)
|
|
{
|
|
const char *p = buf;
|
|
ssize_t written;
|
|
|
|
while (count > 0) {
|
|
written = xwrite(fd, p, count);
|
|
if (written == 0)
|
|
die("disk full?");
|
|
else if (written < 0) {
|
|
if (errno == EPIPE)
|
|
exit(0);
|
|
die("write error (%s)", strerror(errno));
|
|
}
|
|
count -= written;
|
|
p += written;
|
|
}
|
|
}
|
|
|
|
int write_or_whine(int fd, const void *buf, size_t count, const char *msg)
|
|
{
|
|
const char *p = buf;
|
|
ssize_t written;
|
|
|
|
while (count > 0) {
|
|
written = xwrite(fd, p, count);
|
|
if (written == 0) {
|
|
fprintf(stderr, "%s: disk full?\n", msg);
|
|
return 0;
|
|
}
|
|
else if (written < 0) {
|
|
if (errno == EPIPE)
|
|
exit(0);
|
|
fprintf(stderr, "%s: write error (%s)\n",
|
|
msg, strerror(errno));
|
|
return 0;
|
|
}
|
|
count -= written;
|
|
p += written;
|
|
}
|
|
|
|
return 1;
|
|
}
|