diff.h: drop diff_tree_oid() & friends' return value
ll_diff_tree_oid() has only ever returned 0 [1], so it's return value is basically useless. It's only caller diff_tree_oid() has only ever returned the return value of ll_diff_tree_oid() as-is [2], so its return value is just as useless. Most of diff_tree_oid()'s callers simply ignore its return value, except: - diff_root_tree_oid() is a thin wrapper around diff_tree_oid() and returns with its return value, but all of diff_root_tree_oid()'s callers ignore its return value. - rev_compare_tree() and rev_same_tree_as_empty() do look at the return value in a condition, but, since the return value is always 0, the former's < 0 condition is never fulfilled, while the latter's >= 0 condition is always fulfilled. So let's drop the return value of ll_diff_tree_oid(), diff_tree_oid() and diff_root_tree_oid(), and drop those conditions from rev_compare_tree() and rev_same_tree_as_empty() as well. [1] ll_diff_tree_oid() and its ancestors have been returning only 0 ever since it was introduced as diff_tree() in9174026cfe
(Add "diff-tree" program to show which files have changed between two trees., 2005-04-09). [2] diff_tree_oid() traces back to diff-tree.c:main() in9174026cfe
as well. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
1df15f8dee
commit
0ee3cb888d
@ -791,9 +791,7 @@ static int rev_compare_tree(struct rev_info *revs,
|
||||
|
||||
tree_difference = REV_TREE_SAME;
|
||||
revs->pruning.flags.has_changes = 0;
|
||||
if (diff_tree_oid(&t1->object.oid, &t2->object.oid, "",
|
||||
&revs->pruning) < 0)
|
||||
return REV_TREE_DIFFERENT;
|
||||
diff_tree_oid(&t1->object.oid, &t2->object.oid, "", &revs->pruning);
|
||||
|
||||
if (!nth_parent)
|
||||
if (bloom_ret == 1 && tree_difference == REV_TREE_SAME)
|
||||
@ -804,7 +802,6 @@ static int rev_compare_tree(struct rev_info *revs,
|
||||
|
||||
static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
|
||||
{
|
||||
int retval;
|
||||
struct tree *t1 = get_commit_tree(commit);
|
||||
|
||||
if (!t1)
|
||||
@ -812,9 +809,9 @@ static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
|
||||
|
||||
tree_difference = REV_TREE_SAME;
|
||||
revs->pruning.flags.has_changes = 0;
|
||||
retval = diff_tree_oid(NULL, &t1->object.oid, "", &revs->pruning);
|
||||
diff_tree_oid(NULL, &t1->object.oid, "", &revs->pruning);
|
||||
|
||||
return retval >= 0 && (tree_difference == REV_TREE_SAME);
|
||||
return tree_difference == REV_TREE_SAME;
|
||||
}
|
||||
|
||||
struct treesame_state {
|
||||
|
Reference in New Issue
Block a user