Skip to content

Commit 5d55915

Browse files
committed
receive-pack: use in_merge_bases() for fast-forward check
The original computed merge-base between the old commit and the new commit and checked if the old commit was a merge base between them, in order to make sure we are fast-forwarding. Instead, call in_merge_bases(old, new) which does the same. Signed-off-by: Junio C Hamano <[email protected]>
1 parent a20efee commit 5d55915

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

builtin/receive-pack.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ static const char *update(struct command *cmd)
478478
!prefixcmp(name, "refs/heads/")) {
479479
struct object *old_object, *new_object;
480480
struct commit *old_commit, *new_commit;
481-
struct commit_list *bases, *ent;
482481

483482
old_object = parse_object(old_sha1);
484483
new_object = parse_object(new_sha1);
@@ -491,12 +490,7 @@ static const char *update(struct command *cmd)
491490
}
492491
old_commit = (struct commit *)old_object;
493492
new_commit = (struct commit *)new_object;
494-
bases = get_merge_bases(old_commit, new_commit, 1);
495-
for (ent = bases; ent; ent = ent->next)
496-
if (!hashcmp(old_sha1, ent->item->object.sha1))
497-
break;
498-
free_commit_list(bases);
499-
if (!ent) {
493+
if (!in_merge_bases(old_commit, new_commit)) {
500494
rp_error("denying non-fast-forward %s"
501495
" (you should pull first)", name);
502496
return "non-fast-forward";

0 commit comments

Comments
 (0)