Skip to content

Commit

Permalink
diff-tree: show hex sha1 of the single-commit argument case correctly.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Linus Torvalds committed May 18, 2005
1 parent 0a8365a commit 7384889
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion diff-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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], "");
Expand Down

0 comments on commit 7384889

Please sign in to comment.