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 <kirr@mns.spb.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kirill Smelkov committed Feb 5, 2014 at 20:57 UTC 6275c91c08f16f9d9aefea39ab7dab8560f50512
1 file changed +1 -11
revision.c
+1 -11
@@ -496,24 +496,14 @@ static int rev_compare_tree(struct rev_info *revs,
496 static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
497 {
498 int retval;
499 - void *tree;
500 - unsigned long size;
501 - struct tree_desc empty, real;
499 struct tree *t1 = commit->tree;
500
501 if (!t1)
502 return 0;
503
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 -
504 tree_difference = REV_TREE_SAME;
505 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);
507
508 return retval >= 0 && (tree_difference == REV_TREE_SAME);
509 }