]> git.ipfire.org Git - thirdparty/git.git/commitdiff
replay: remove HEAD related sanity check
authorElijah Newren <newren@gmail.com>
Fri, 24 Nov 2023 11:10:38 +0000 (12:10 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sun, 26 Nov 2023 01:10:49 +0000 (10:10 +0900)
We want replay to be a command that can be used on the server side on
any branch, not just the current one, so we are going to stop updating
HEAD in a future commit.

A "sanity check" that makes sure we are replaying the current branch
doesn't make sense anymore. Let's remove it.

Co-authored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/replay.c
t/t3650-replay-basics.sh

index ca3867dc5796be209222b9260e8caf73f0f57dad..bdec2f2b97113b1518ea97746e43c36d5c51892d 100644 (file)
@@ -123,7 +123,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
        struct commit *onto;
        const char *onto_name = NULL;
        struct commit *last_commit = NULL, *last_picked_commit = NULL;
-       struct object_id head;
        struct lock_file lock = LOCK_INIT;
        struct strvec rev_walk_args = STRVEC_INIT;
        struct rev_info revs;
@@ -162,11 +161,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
        onto = peel_committish(onto_name);
        strbuf_addf(&branch_name, "refs/heads/%s", argv[2]);
 
-       /* Sanity check */
-       if (repo_get_oid(the_repository, "HEAD", &head))
-               die(_("Cannot read HEAD"));
-       assert(oideq(&onto->object.oid, &head));
-
        repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
        if (repo_read_index(the_repository) < 0)
                BUG("Could not read index");
@@ -275,7 +269,7 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
                            oid_to_hex(&last_picked_commit->object.oid));
                if (update_ref(reflog_msg.buf, "HEAD",
                               &last_commit->object.oid,
-                              &head,
+                              &onto->object.oid,
                               REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) {
                        error(_("could not update %s"), argv[2]);
                        die("Failed to update %s", argv[2]);
index 36c1b5082a8541a73d5bbdff27d0271440a87cec..b5b9f9ade2d8c8c0ba694cae24ff31ddcc65bd00 100755 (executable)
@@ -48,8 +48,6 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'using replay to rebase two branches, one on top of other' '
-       git switch main &&
-
        git replay --onto main topic1 topic2 >result &&
 
        git log --format=%s $(cut -f 3 -d " " result) >actual &&