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 <gitster@pobox.com>
Junio C Hamano committed
Aug 27, 2012 at 15:16 UTC
5d55915c7a58e59d913b0cfc38a6f49514068cd2
1 file changed
+1
-7
builtin/receive-pack.c
+1
-7
@@ -478,7 +478,6 @@ static const char *update(struct command *cmd)
478
!prefixcmp(name, "refs/heads/")) {
479
struct object *old_object, *new_object;
480
struct commit *old_commit, *new_commit;
481
- struct commit_list *bases, *ent;
481
482
old_object = parse_object(old_sha1);
483
new_object = parse_object(new_sha1);
@@ -491,12 +490,7 @@ static const char *update(struct command *cmd)
490
}
491
old_commit = (struct commit *)old_object;
492
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)) {
494
rp_error("denying non-fast-forward %s"
495
" (you should pull first)", name);
496
return "non-fast-forward";