git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Daniel Barkalow <barkalow@iabervon.org>,
	Hugo Mildenberger <Hugo.Mildenberger@namir.de>
Subject: [PATCH] Quote LF in urls git fetch saves in FETCH_HEAD
Date: Tue, 12 May 2009 19:24:52 +0200	[thread overview]
Message-ID: <20090512172452.GA32594@blimp.localdomain> (raw)
In-Reply-To: <81b0412b0905121018lbccda1fvf6c4c19417cdde00@mail.gmail.com>

The fmt-merge-msg does a strong syntax checking of its input and fails
with if it is incorrect. The LF character is the only character
important for fmt-merge-msg. As the url in FETCH_HEAD plays only
informational role, a quoted representation of the url should be good
and true enough.
The url often comes from either user-editable config or command line,
so it is reasonable to expect all kinds of characters in it, including
the characters which the format of FETCH_HEAD considers special (line
separator in this case).

Noticed and reported by Hugo Mildenberger.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---

Alex Riesen, Tue, May 12, 2009 19:18:33 +0200:
> 2009/5/12 Hugo Mildenberger <Hugo.Mildenberger@namir.de>:
> > hm@localhost /var/tmp/bluetooth-testing.git $ git pull
> > fatal: Error in line 2:
> 
> That's already fixed. Will send the fix in a minute.

Here

 builtin-fetch.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/builtin-fetch.c b/builtin-fetch.c
index 3c998ea..eef7091 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -353,12 +353,17 @@ static int store_updated_refs(const char *url, const char *remote_name,
 						    kind);
 			note_len += sprintf(note + note_len, "'%s' of ", what);
 		}
-		note_len += sprintf(note + note_len, "%.*s", url_len, url);
-		fprintf(fp, "%s\t%s\t%s\n",
+		fprintf(fp, "%s\t%s\t%s",
 			sha1_to_hex(commit ? commit->object.sha1 :
 				    rm->old_sha1),
 			rm->merge ? "" : "not-for-merge",
 			note);
+		for (i = 0; i < url_len; ++i)
+			if ('\n' == url[i])
+				fputs("\\n", fp);
+			else
+				fputc(url[i], fp);
+		fputc('\n', fp);
 
 		if (ref)
 			rc |= update_local_ref(ref, what, note);
-- 
1.6.3.28.ga852b

  reply	other threads:[~2009-05-12 17:25 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-11 20:08 git fails with control characters in trunk directory name Hugo Mildenberger
2009-05-12  6:51 ` Alex Riesen
2009-05-12  9:02   ` Hugo Mildenberger
2009-05-12 10:54     ` Alex Riesen
2009-05-12 13:57       ` Hugo Mildenberger
2009-05-12 14:59         ` Alex Riesen
2009-05-12 16:59           ` Hugo Mildenberger
2009-05-12 17:18             ` Alex Riesen
2009-05-12 17:24               ` Alex Riesen [this message]
2009-05-12 23:16                 ` [PATCH] Quote LF in urls git fetch saves in FETCH_HEAD Junio C Hamano
2009-05-13  6:06                   ` Alex Riesen
     [not found]                     ` <200905131340.31509.Hugo.Mildenberger@namir.de>
2009-05-13 12:10                       ` Alex Riesen
2009-05-13 14:49                         ` Hugo Mildenberger
2009-05-13 12:39                     ` Hugo Mildenberger
2009-05-13 15:18                     ` Daniel Barkalow
2009-05-13 16:09                       ` Alex Riesen
2009-05-13 17:07                         ` Alex Riesen
2009-05-13 17:12                         ` Daniel Barkalow
2009-05-13 18:11                           ` Alex Riesen
2009-05-13 18:23                       ` Junio C Hamano
2009-05-13 18:08                 ` [PATCH 1/2] " Alex Riesen
2009-05-13 20:53                   ` [PATCH 2/2] Improve the naming of guessed target repository for git clone Alex Riesen
2009-05-14  0:41                     ` Junio C Hamano
2009-05-14  5:54                       ` Alex Riesen
2009-05-14  6:35                         ` Junio C Hamano
2009-05-14  8:45                           ` Alex Riesen
2009-05-14 12:50                             ` Hugo Mildenberger
2009-05-14  8:33                         ` Alex Riesen
2009-05-16 17:49                           ` Junio C Hamano
2009-05-12 17:41             ` git fails with control characters in trunk directory name Alex Riesen

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=20090512172452.GA32594@blimp.localdomain \
    --to=raa.lkml@gmail.com \
    --cc=Hugo.Mildenberger@namir.de \
    --cc=barkalow@iabervon.org \
    --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).