git/list[1] front-page[2] threads[3] people[4] search[5] about
 

"git-diff -p :/anything" always segfaults

From
Jim Meyering <jim@meyering.net>
Date
Mar 11, 2007, 18:49 UTC
Message-ID
<87d53fsjiz.fsf@rho.meyering.net>

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
Next: Johannes Schindelin
Message 1 of 7 in “"git-diff -p :/anything" always segfaults”
  1. Jim MeyeringMar 11, 2007
  2. Johannes SchindelinMar 11, 2007
  3. Linus TorvaldsMar 11, 2007
  4. Junio C HamanoMar 11, 2007
  5. Linus TorvaldsMar 12, 2007
  6. Linus TorvaldsMar 12, 2007
  7. Junio C HamanoMar 12, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.