Skip to content

Commit fda7dea

Browse files
newrenchriscool
authored andcommitted
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 <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a37727 commit fda7dea

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

builtin/replay.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
123123
struct commit *onto;
124124
const char *onto_name = NULL;
125125
struct commit *last_commit = NULL, *last_picked_commit = NULL;
126-
struct object_id head;
127126
struct lock_file lock = LOCK_INIT;
128127
struct strvec rev_walk_args = STRVEC_INIT;
129128
struct rev_info revs;
@@ -162,11 +161,6 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
162161
onto = peel_committish(onto_name);
163162
strbuf_addf(&branch_name, "refs/heads/%s", argv[2]);
164163

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-
170164
repo_hold_locked_index(the_repository, &lock, LOCK_DIE_ON_ERROR);
171165
if (repo_read_index(the_repository) < 0)
172166
BUG("Could not read index");
@@ -275,7 +269,7 @@ int cmd_replay(int argc, const char **argv, const char *prefix)
275269
oid_to_hex(&last_picked_commit->object.oid));
276270
if (update_ref(reflog_msg.buf, "HEAD",
277271
&last_commit->object.oid,
278-
&head,
272+
&onto->object.oid,
279273
REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) {
280274
error(_("could not update %s"), argv[2]);
281275
die("Failed to update %s", argv[2]);

t/t3650-replay-basics.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ test_expect_success 'setup' '
4848
'
4949

5050
test_expect_success 'using replay to rebase two branches, one on top of other' '
51-
git switch main &&
52-
5351
git replay --onto main topic1 topic2 >result &&
5452
5553
git log --format=%s $(cut -f 3 -d " " result) >actual &&

0 commit comments

Comments
 (0)