[PATCH] Make git-mailsplit strip whitespace from the start of the mailbox file.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will allow it to handle the files gotten through gmail's web interface via its 'Show original' option.
These files contain the mail headers and the mail body, but start with some whitespace.
Now you can give these files to git-am without having to remove the whitespace yourself.

Signed-off-by: Simon Sasburg <Simon.Sasburg@xxxxxxxxx>
---

On Nov 2, 2007 9:53 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> I wonder why this is not using isspace(peek).

Fixed.

On Nov 1, 2007 11:26 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Ah, I meant "git-mailsplit", which is the command internally run
> by "git-am" to preprocess the file and to split it into
> individual mail pieces to be fed to "git-mailinfo".
> 
> That may suggest the change is better done in git-mailsplit not
> git-mailinfo.

The files from gmail only contain 1 mail per file, but having git-mailspit
massage these into a proper file that git-mailinfo can parse seems like
a sane solution to me.

 builtin-mailsplit.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index 43fc373..74b0470 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) {
-- 
1.5.3.4.504.gdf75-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux