Skip to content

Commit 0b707c3

Browse files
Kirill Smelkovgitster
authored andcommitted
tree-diff: convert diff_root_tree_sha1() to just call diff_tree_sha1 with old=NULL
Now since diff_tree_sha1 understands NULL for both old and new, we could indicate an empty tree for root commit by providing just NULL for old sha1. Signed-off-by: Kirill Smelkov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7913032 commit 0b707c3

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

tree-diff.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,5 @@ int diff_tree_sha1(const unsigned char *old, const unsigned char *new, const cha
311311

312312
int diff_root_tree_sha1(const unsigned char *new, const char *base, struct diff_options *opt)
313313
{
314-
int retval;
315-
void *tree;
316-
unsigned long size;
317-
struct tree_desc empty, real;
318-
319-
tree = read_object_with_reference(new, tree_type, &size, NULL);
320-
if (!tree)
321-
die("unable to read root tree (%s)", sha1_to_hex(new));
322-
init_tree_desc(&real, tree, size);
323-
324-
init_tree_desc(&empty, "", 0);
325-
retval = diff_tree(&empty, &real, base, opt);
326-
free(tree);
327-
return retval;
314+
return diff_tree_sha1(NULL, new, base, opt);
328315
}

0 commit comments

Comments
 (0)