replay: remove HEAD related sanity check
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>
Elijah Newren committed
Nov 24, 2023 at 12:10 UTC
fda7dea7c95a7958d36ead75116c1ffbf1791cc0
2 files changed
+1
-9
builtin/replay.c
+1
-7
@@ -123,7 +123,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
123
struct commit *onto;
124
const char *onto_name = NULL;
125
struct commit *last_commit = NULL, *last_picked_commit = NULL;
126
- struct object_id head;
126
struct lock_file lock = LOCK_INIT;
127
struct strvec rev_walk_args = STRVEC_INIT;
128
struct rev_info revs;
@@ -162,11 +161,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
161
onto = peel_committish(onto_name);
162
strbuf_addf(&branch_name, "refs/heads/%s", argv[2]);
163
165
- /* Sanity check */
166
- if (repo_get_oid(the_repository, "HEAD", &head))
167
- die(_("Cannot read HEAD"));
168
- assert(oideq(&onto->object.oid, &head));
169
-
164
repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
165
if (repo_read_index(the_repository) < 0)
166
BUG("Could not read index");
@@ -275,7 +269,7 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
269
oid_to_hex(&last_picked_commit->object.oid));
270
if (update_ref(reflog_msg.buf, "HEAD",
271
&last_commit->object.oid,
278
- &head,
272
+ &onto->object.oid,
273
REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) {
274
error(_("could not update %s"), argv[2]);
275
die("Failed to update %s", argv[2]);
t/t3650-replay-basics.sh
-2
@@ -48,8 +48,6 @@ test_expect_success 'setup' '
48
'
49
50
test_expect_success 'using replay to rebase two branches, one on top of other' '
51
- git switch main &&
52
-
51
git replay --onto main topic1 topic2 >result &&
52
53
git log --format=%s $(cut -f 3 -d " " result) >actual &&