summaryrefslogtreecommitdiff
path: root/builtin-mailsplit.c
diff options
context:
space:
mode:
authorSimon Sasburg <simon.sasburg@gmail.com>2007-11-01 23:57:45 +0100
committerJunio C Hamano <gitster@pobox.com>2007-11-02 01:58:40 -0700
commitf88a545a94cb474d370ef97dd3694d09b6ac90c1 (patch)
tree6c897e2743260174fb849198b4a7c2b5a15f350b /builtin-mailsplit.c
parent3e4bb087a18435b12eb82116e93af2887578e816 (diff)
downloadgit-f88a545a94cb474d370ef97dd3694d09b6ac90c1.tar.gz
Make mailsplit and mailinfo strip whitespace from the start of the input
Signed-off-by: Simon Sasburg <Simon.Sasburg@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-mailsplit.c')
-rw-r--r--builtin-mailsplit.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index 43fc373a15..74b04706f3 100644
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
@@ -164,6 +164,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;
@@ -173,6 +174,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) {