Skip to content

Commit 6275c91

Browse files
Kirill Smelkovgitster
authored andcommitted
revision: convert to using diff_tree_sha1()
Since diff_tree_sha1() can now accept empty trees via NULL sha1, we could just call it without manually reading trees into tree_desc and duplicating code. Besides, that if (!tree) return 0; looked suspect - we were saying an invalid tree != empty tree, but maybe it is better to just say the tree is invalid here, which is what diff_tree_sha1() does for such case. Signed-off-by: Kirill Smelkov <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7bc4ec0 commit 6275c91

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

revision.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -496,24 +496,14 @@ static int rev_compare_tree(struct rev_info *revs,
496496
static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
497497
{
498498
int retval;
499-
void *tree;
500-
unsigned long size;
501-
struct tree_desc empty, real;
502499
struct tree *t1 = commit->tree;
503500

504501
if (!t1)
505502
return 0;
506503

507-
tree = read_object_with_reference(t1->object.sha1, tree_type, &size, NULL);
508-
if (!tree)
509-
return 0;
510-
init_tree_desc(&real, tree, size);
511-
init_tree_desc(&empty, "", 0);
512-
513504
tree_difference = REV_TREE_SAME;
514505
DIFF_OPT_CLR(&revs->pruning, HAS_CHANGES);
515-
retval = diff_tree(&empty, &real, "", &revs->pruning);
516-
free(tree);
506+
retval = diff_tree_sha1(NULL, t1->object.sha1, "", &revs->pruning);
517507

518508
return retval >= 0 && (tree_difference == REV_TREE_SAME);
519509
}

0 commit comments

Comments
 (0)