handle_revision_arg: simplify commit reference lookups
The "dotdot" range parser avoids calling lookup_commit_reference() if we are directly fed two commits. But its casts are unnecessarily complex; that function will just return a commit we pass into it. Just calling the function all the time is much simpler, and doesn't do any significant extra work (the object is already parsed, and deref_tag() on a non-tag is a noop; we do incur one extra lookup_object() call, but that's fairly trivial). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
May 19, 2017 at 08:48 UTC
1d6c93817bf22d6bf279bac302911cc93f63046c
1 file changed
+2
-6
revision.c
+2
-6
@@ -1500,12 +1500,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
1500
struct commit *a, *b;
1501
struct commit_list *exclude;
1502
1503
- a = (a_obj->type == OBJ_COMMIT
1504
- ? (struct commit *)a_obj
1505
- : lookup_commit_reference(a_obj->oid.hash));
1506
- b = (b_obj->type == OBJ_COMMIT
1507
- ? (struct commit *)b_obj
1508
- : lookup_commit_reference(b_obj->oid.hash));
1503
+ a = lookup_commit_reference(a_obj->oid.hash);
1504
+ b = lookup_commit_reference(b_obj->oid.hash);
1505
if (!a || !b)
1506
goto missing;
1507
exclude = get_merge_bases(a, b);