Git development
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: git@vger.kernel.org
Subject: "git-diff -p :/anything" always segfaults
Date: Sun, 11 Mar 2007 19:49:08 +0100	[thread overview]
Message-ID: <87d53fsjiz.fsf@rho.meyering.net> (raw)

I like the idea of the new ':/<oneline prefix>' notation, and gave it
a try, but all I could get was a segfault.  It was dereferencing a NULL
commit list.  Fix below.  With it, this example now works:

$ mkdir .j; cd .j; touch f
$ (git-init; git-add f; git-commit -mc f; echo x >f; git-commit -md f)>/dev/null
$ git-diff -p :/c :/d
diff --git a/f b/f
index e69de29..587be6b 100644
--- a/f
+++ b/f
@@ -0,0 +1 @@
+x

Signed-off-by: Jim Meyering <jim@meyering.net>
---
 sha1_name.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 31812d3..6b6270b 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -617,7 +617,7 @@ int get_sha1_oneline(const char *prefix, unsigned char *sha1)
 	for_each_ref(handle_one_ref, &list);
 	for (l = list; l; l = l->next)
 		commit_list_insert(l->item, &backup);
-	while ((commit = pop_most_recent_commit(&list, ONELINE_SEEN))) {
+	while (list && (commit = pop_most_recent_commit(&list, ONELINE_SEEN))) {
 		char *p;
 		parse_object(commit->object.sha1);
 		if (!commit->buffer || !(p = strstr(commit->buffer, "\n\n")))
--
1.5.0.3.316.gbd1fc

             reply	other threads:[~2007-03-11 18:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-11 18:49 Jim Meyering [this message]
2007-03-11 19:08 ` "git-diff -p :/anything" always segfaults Johannes Schindelin
2007-03-11 20:25 ` Linus Torvalds
2007-03-11 20:58   ` Junio C Hamano
2007-03-12 16:14     ` Linus Torvalds
2007-03-12 16:22       ` Linus Torvalds
2007-03-12 18:42       ` Junio C Hamano

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=87d53fsjiz.fsf@rho.meyering.net \
    --to=jim@meyering.net \
    --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