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 1/2] Quote LF in urls git fetch saves in FETCH_HEAD
Date: Wed, 13 May 2009 20:08:53 +0200 [thread overview]
Message-ID: <20090513180853.GB26288@blimp.localdomain> (raw)
In-Reply-To: <20090512172452.GA32594@blimp.localdomain>
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:24:52 +0200:
> 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
>
That one has a bug which breaks t5515: printing an unterminated
string ('note').
builtin-fetch.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 3c998ea..ec75df0 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -353,12 +353,18 @@ 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",
+ note[note_len] = '\0';
+ 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
next prev parent reply other threads:[~2009-05-13 18:09 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 ` [PATCH] Quote LF in urls git fetch saves in FETCH_HEAD Alex Riesen
2009-05-12 23:16 ` 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 ` Alex Riesen [this message]
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=20090513180853.GB26288@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).