author | Junio C Hamano <junkio@cox.net> | |
Sun, 2 Apr 2006 20:54:28 +0000 (13:54 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 2 Apr 2006 20:54:28 +0000 (13:54 -0700) |
* lt/fix-sol-pack:
pack-objects: be incredibly anal about stdio semantics
Fix Solaris stdio signal handling stupidities
Signed-off-by: Junio C Hamano <junkio@cox.net>
pack-objects: be incredibly anal about stdio semantics
Fix Solaris stdio signal handling stupidities
Signed-off-by: Junio C Hamano <junkio@cox.net>
1 | 2 | |||
---|---|---|---|---|
pack-objects.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc pack-objects.c
index ccfaa5f609431490c886abe0e0af842987428bf6,084c2006a987c79dfbd2f70c616d46eac23ed50d..0ea16ad67fa7f14cf4dedf35a1adbd6da3856489
--- 1/pack-objects.c
--- 2/pack-objects.c
+++ b/pack-objects.c
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 (progress_update) {
- fprintf(stderr, "Counting objects...%d\r", nr_objects);
- progress_update = 0;
+ if (!fgets(line, sizeof(line), stdin)) {
+ if (feof(stdin))
+ break;
+ if (!ferror(stdin))
+ die("fgets returned NULL, not EOF, not error!");
+ if (errno == EINTR)
+ continue;
+ die("fgets: %s", strerror(errno));
+ }
+
+ 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);