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

Re: [PATCH] show changed tree objects with recursive git-diff-tree

From
Junio C Hamano <junkio@cox.net>
Date
May 21, 2005, 03:47 UTC
Message-ID
<7vd5rlp7ef.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.58.0505202019330.2206@ppc970.osdl.org>

Diff heler _should_ not get confused, but maybe it currently does. If that is the case, I would consider that a bug (my bad).

... goes back to the Linus tip for a while and comes back ...

Yup. It says a change line containing tree is not something it recognizes. Sorry, there is a bug there (and another bug that partially hides that bug).

I'm doing major rewrite of the diff-core right now but even after that, diff helper _should_ just ignore trees.

In the meantime, this patch should fix it. And this should be the right fix even after the "major rewrite" I am doing now.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
# - linus: [PATCH] delta creation
# + (working tree)
diff --git a/diff-helper.c b/diff-helper.c
--- a/diff-helper.c
+++ b/diff-helper.c
@@ -20,7 +20,8 @@ static int parse_oneside_change(const ch
 		cp++;
 	}
 	*mode = m;
-	if (strncmp(cp, "\tblob\t", 6) && strncmp(cp, " blob ", 6))
+	if (strncmp(cp, "\ttree\t", 6) && strncmp(cp, " tree ", 6) &&
+	    strncmp(cp, "\tblob\t", 6) && strncmp(cp, " blob ", 6))
 		return -1;
 	cp += 6;
 	if (get_sha1_hex(cp, sha1))
@@ -44,11 +45,13 @@ static int parse_diff_raw_output(const c
 		diff_unmerge(cp + 1);
 		break;
 	case '+':
-		parse_oneside_change(cp, &new_mode, new_sha1, path);
+		if (parse_oneside_change(cp, &new_mode, new_sha1, path))
+			return -1;
 		diff_addremove('+', new_mode, new_sha1, path, NULL);
 		break;
 	case '-':
-		parse_oneside_change(cp, &old_mode, old_sha1, path);
+		if (parse_oneside_change(cp, &old_mode, old_sha1, path))
+			return -1;
 		diff_addremove('-', old_mode, old_sha1, path, NULL);
 		break;
 	case '*':
@@ -64,7 +67,8 @@ static int parse_diff_raw_output(const c
 			new_mode = (new_mode << 3) | (ch - '0');
 			cp++;
 		}
-		if (strncmp(cp, "\tblob\t", 6) && strncmp(cp, " blob ", 6))
+		if (strncmp(cp, "\tblob\t", 6) && strncmp(cp, " blob ", 6) &&
+		    (strncmp(cp, "\ttree\t", 6) && strncmp(cp, " tree ", 6)))
 			return -1;
 		cp += 6;
 		if (get_sha1_hex(cp, old_sha1))
Previous: Linus Torvalds
Message 9 of 9 in “show changed tree objects with recursive git-diff-tree”
  1. show changed tree objects with recursive git-diff-treeNicolas Pitre, May 21, 2005
  2. Junio C HamanoMay 21, 2005
  3. Linus TorvaldsMay 21, 2005
  4. Nicolas PitreMay 23, 2005
  5. Junio C HamanoMay 25, 2005
  6. Nicolas PitreMay 25, 2005
  7. Junio C HamanoMay 25, 2005
  8. Linus TorvaldsMay 21, 2005
  9. Junio C HamanoMay 21, 2005

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.