From: Simon Sasburg <simon.sasburg@gmail.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Simon Sasburg <Simon.Sasburg@gmail.com>
Subject: [PATCH] Make git-mailsplit strip whitespace from the start of the mailbox file.
Date: Sun, 4 Nov 2007 14:32:00 +0100 [thread overview]
Message-ID: <1194183120-3660-1-git-send-email-Simon.Sasburg@gmail.com> (raw)
In-Reply-To: <7v8x5h58qj.fsf@gitster.siamese.dyndns.org>
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@gmail.com>
---
On Nov 2, 2007 9:53 AM, Junio C Hamano <gitster@pobox.com> wrote:
> I wonder why this is not using isspace(peek).
Fixed.
On Nov 1, 2007 11:26 PM, Junio C Hamano <gitster@pobox.com> 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
prev parent reply other threads:[~2007-11-04 13:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-01 21:05 [PATCH] Make git-mailinfo strip whitespace from the start of the mail file Simon Sasburg
2007-11-01 21:33 ` Junio C Hamano
2007-11-01 21:41 ` Simon Sasburg
2007-11-01 22:26 ` Junio C Hamano
2007-11-01 22:57 ` [PATCH] Make git-mailsplit strip whitespace from the start of the mailbox file Simon Sasburg
2007-11-02 8:53 ` [PATCH] Make git-mailinfo strip whitespace from the start of the mail file Junio C Hamano
2007-11-04 13:32 ` Simon Sasburg [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1194183120-3660-1-git-send-email-Simon.Sasburg@gmail.com \
--to=simon.sasburg@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).