Skip to content

Commit 73d6d7b

Browse files
dschogitster
authored andcommitted
rebase: prepare reset_head() for more flags
Currently, we only accept the flag indicating whether the HEAD should be detached not. In the next commit, we want to introduce another flag: to toggle between emulating `reset --hard` vs `checkout -q`. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3249c12 commit 73d6d7b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

builtin/rebase.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,13 @@ static int run_specific_rebase(struct rebase_options *opts)
522522

523523
#define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
524524

525+
#define RESET_HEAD_DETACH (1<<0)
526+
525527
static int reset_head(struct object_id *oid, const char *action,
526-
const char *switch_to_branch, int detach_head,
528+
const char *switch_to_branch, unsigned flags,
527529
const char *reflog_orig_head, const char *reflog_head)
528530
{
531+
unsigned detach_head = flags & RESET_HEAD_DETACH;
529532
struct object_id head_oid;
530533
struct tree_desc desc;
531534
struct lock_file lock = LOCK_INIT;
@@ -1500,8 +1503,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
15001503
"it...\n"));
15011504

15021505
strbuf_addf(&msg, "rebase: checkout %s", options.onto_name);
1503-
if (reset_head(&options.onto->object.oid, "checkout", NULL, 1,
1504-
NULL, msg.buf))
1506+
if (reset_head(&options.onto->object.oid, "checkout", NULL,
1507+
RESET_HEAD_DETACH, NULL, msg.buf))
15051508
die(_("Could not detach HEAD"));
15061509
strbuf_release(&msg);
15071510

0 commit comments

Comments
 (0)