Code

t7401: squelch garbage output
[git.git] / builtin-mailsplit.c
index 10fa1773401d6474d8e6c88065e3a992690ae0f8..46b27cdaea71cba92974480da74ec5922fcf3a7a 100644 (file)
@@ -170,6 +170,7 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
 {
        char name[PATH_MAX];
        int ret = -1;
+       int peek;
 
        FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
        int file_done = 0;
@@ -179,6 +180,11 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
                goto out;
        }
 
+       do {
+               peek = fgetc(f);
+       } while (isspace(peek));
+       ungetc(peek, f);
+
        if (fgets(buf, sizeof(buf), f) == NULL) {
                /* empty stdin is OK */
                if (f != stdin) {