From: Junio C Hamano Date: Tue, 4 Apr 2006 20:42:02 +0000 (-0700) Subject: Merge branch 'lt/fix-sol-pack' X-Git-Tag: v1.3.0-rc2~5 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4c61b7d15a6215fa4dffa33c37c3ef9df80d3f67;p=git.git Merge branch 'lt/fix-sol-pack' * lt/fix-sol-pack: Use sigaction and SA_RESTART in read-tree.c; add option in Makefile. safe_fgets() - even more anal fgets() pack-objects: be incredibly anal about stdio semantics Fix Solaris stdio signal handling stupidities --- 4c61b7d15a6215fa4dffa33c37c3ef9df80d3f67 diff --cc pack-objects.c index ccfaa5f6,7d624779..d7ba938a --- a/pack-objects.c +++ b/pack-objects.c @@@ -1090,24 -901,29 +1106,30 @@@ int main(int argc, char **argv prepare_packed_git(); if (progress) { - struct itimerval v; - v.it_interval.tv_sec = 1; - v.it_interval.tv_usec = 0; - v.it_value = v.it_interval; - signal(SIGALRM, progress_interval); - setitimer(ITIMER_REAL, &v, NULL); fprintf(stderr, "Generating pack...\n"); + setup_progress_signal(); } - while (fgets(line, sizeof(line), stdin) != NULL) { + for (;;) { - unsigned int hash; - char *p; unsigned char sha1[20]; + if (!fgets(line, sizeof(line), stdin)) { + if (feof(stdin)) + break; + if (!ferror(stdin)) + die("fgets returned NULL, not EOF, not error!"); + if (errno != EINTR) + die("fgets: %s", strerror(errno)); + clearerr(stdin); + continue; + } + - if (progress_update) { - fprintf(stderr, "Counting objects...%d\r", nr_objects); - progress_update = 0; + if (line[0] == '-') { + if (get_sha1_hex(line+1, sha1)) + die("expected edge sha1, got garbage:\n %s", + line+1); + add_preferred_base(sha1); + continue; } if (get_sha1_hex(line, sha1)) die("expected sha1, got garbage:\n %s", line);