From: Jonathan Nieder <jrnieder@gmail.com>
To: Andreas Krey <a.krey@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: git cherry(pick) dumps core
Date: Thu, 29 Apr 2010 14:49:36 -0500 [thread overview]
Message-ID: <20100429194936.GA31941@progeny.tock> (raw)
In-Reply-To: <20100429191150.GA10526@inner.home.ulmdo.de>
Hi Andreas,
Andreas Krey wrote:
> I just have a case of git cherry-pick dieing with a core dump.
> The directly offending lines are get_message() in buildin/revert.c:
>
> if ((out->reencoded_message = reencode_string(raw_message,
> git_commit_encoding, encoding)))
> out->message = out->reencoded_message;
>
> abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
> abbrev_len = strlen(abbrev);
>
> /* Find beginning and end of commit subject. */
> p = out->message;
> while (*p && (*p != '\n' || p[1] != '\n'))
>
> and out->message is null at that point.
>
> It looks like reencode_string is returning NULL,
> and get_message can't quite cope with that.
Thanks for the report. What encoding were you using? (You can check
with ‘git cat-file commit <revision you were trying to cherry-pick>’.)
The code you mention was just wrong, sorry. If the local iconv
doesn’t understand some recording, the correct behavior is to pass the
message through, not to segfault.
With this change, cherry-pick would treat the old message as UTF-8
(or whatever the current [i18n] commitencoding setting specifies,
if present). If the message happens to contain an illegal byte
sequence, the cherry-pick will not segfault but it will still fail.
In other words, this patch should fix the segfault, but it does not
fix the underlying problem which was there before.
diff --git a/builtin/revert.c b/builtin/revert.c
index bbaa937..9f8ceab 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -114,6 +114,8 @@ static int get_message(const char *raw_message, struct commit_message *out)
if ((out->reencoded_message = reencode_string(raw_message,
git_commit_encoding, encoding)))
out->message = out->reencoded_message;
+ else
+ out->message = raw_message;
abbrev = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
abbrev_len = strlen(abbrev);
next prev parent reply other threads:[~2010-04-30 17:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-28 19:38 Proper way to abort incorrect cherry-picking? Eugene Sajine
2010-04-28 19:49 ` David Borowitz
2010-04-28 19:59 ` Eugene Sajine
2010-04-28 22:39 ` Jon Seymour
2010-04-28 23:37 ` Jonathan Nieder
2010-04-29 0:07 ` Jon Seymour
2010-04-29 19:11 ` git cherry(pick) dumps core Andreas Krey
2010-04-29 19:49 ` Jonathan Nieder [this message]
2010-04-29 20:21 ` Andreas Krey
2010-04-30 13:32 ` Jonathan Nieder
2010-05-08 23:17 ` [PATCH] cherry-pick: do not dump core when iconv fails Jonathan Nieder
2010-05-08 23:55 ` Junio C Hamano
2010-04-28 19:50 ` Proper way to abort incorrect cherry-picking? Jonathan Nieder
2010-04-28 20:05 ` Eugene Sajine
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=20100429194936.GA31941@progeny.tock \
--to=jrnieder@gmail.com \
--cc=a.krey@gmx.de \
--cc=git@vger.kernel.org \
/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).