summaryrefslogtreecommitdiff
path: root/diff-tree.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-18 20:43:58 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-18 20:43:58 (GMT)
commit73848892adeaa421825672bce929b9cc16043fa9 (patch)
tree56dbc1aa76bca0ff8ff72e311f5dad382caad8d3 /diff-tree.c
parent0a8365a179685feecee427075a9c2db8a66c434a (diff)
downloadgit-73848892adeaa421825672bce929b9cc16043fa9.zip
git-73848892adeaa421825672bce929b9cc16043fa9.tar.gz
git-73848892adeaa421825672bce929b9cc16043fa9.tar.bz2
diff-tree: show hex sha1 of the single-commit argument case correctly.
We can't just do the "sha1_to_hex()" thing directly, since the buffer in question will be overwritten by the name of the parent. So teach diff_tree_commit() to generate the proper hex name itself.
Diffstat (limited to 'diff-tree.c')
-rw-r--r--diff-tree.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/diff-tree.c b/diff-tree.c
index 8cfe990..acd1524 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -356,6 +356,12 @@ static int diff_tree_commit(const unsigned char *commit, const char *name)
return 0;
}
+ if (!name) {
+ static char commit_name[60];
+ strcpy(commit_name, sha1_to_hex(commit));
+ name = commit_name;
+ }
+
offset = 46;
while (offset + 48 < size && !memcmp(buf + offset, "parent ", 7)) {
unsigned char parent[20];
@@ -472,7 +478,7 @@ int main(int argc, char **argv)
usage(diff_tree_usage);
break;
case 1:
- diff_tree_commit(sha1[0], sha1_to_hex(sha1[0]));
+ diff_tree_commit(sha1[0], NULL);
break;
case 2:
diff_tree_sha1(sha1[0], sha1[1], "");