Git development
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: git-mailinfo: cut lines at ^M
Date: Mon, 16 Jan 2006 11:13:15 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0601161104070.13339@g5.osdl.org> (raw)


This changes "eatspace()" to cut lines at the first ^M (\r, CR) character.

Normally it should make no difference at all, since even if you have a 
non-UNIX CR/LF end-of-line, it would have removed the ^M at the end of the 
line as whitespace.

The main reason for this patch is that I seem to have something buggy in 
my mail path (possibly fetchmail) which very occasionally causes the mail 
headers to have an appended "^M)" line. This silly thing works around it, 
and shouldn't hurt anything else.

The alternative would be to simply disallow control characters in the 
commit message (so that I would not commit these things by mistake).

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---

Junio, feel free to ignore this. It shouldn't hurt, but admittedly it's a 
stupid hack for a problem that has nothing to do with git. The "disallow 
control characters" fix is probably better, if you prefer that I can do it 
that way instead.

		Linus

diff --git a/mailinfo.c b/mailinfo.c
index 0265a29..e1c95a9 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -226,9 +226,19 @@ static int is_multipart_boundary(const c
 
 static int eatspace(char *line)
 {
-	int len = strlen(line);
-	while (len > 0 && isspace(line[len-1]))
-		line[--len] = 0;
+	int len, idx;
+
+	len = idx = 0;
+	for (;;) {
+		unsigned char c = line[idx++];
+		if (isspace(c)) {
+			if (c == '\n' || c == '\r')
+				break;
+			continue;
+		}
+		len = idx;
+	}
+	line[len] = 0;
 	return len;
 }
 

             reply	other threads:[~2006-01-16 19:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-16 19:13 Linus Torvalds [this message]
2006-01-16 23:38 ` git-mailinfo: cut lines at ^M Junio C Hamano
2006-01-16 23:49   ` Linus Torvalds

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=Pine.LNX.4.64.0601161104070.13339@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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