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))