Skip to content

Commit f48aa67

Browse files
committed
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]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 7d0ec44 commit f48aa67

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
@@ -523,10 +523,13 @@ static int run_specific_rebase(struct rebase_options *opts)
523523

524524
#define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
525525

526+
#define RESET_HEAD_DETACH (1<<0)
527+
526528
static int reset_head(struct object_id *oid, const char *action,
527-
const char *switch_to_branch, int detach_head,
529+
const char *switch_to_branch, unsigned flags,
528530
const char *reflog_orig_head, const char *reflog_head)
529531
{
532+
unsigned detach_head = flags & RESET_HEAD_DETACH;
530533
struct object_id head_oid;
531534
struct tree_desc desc;
532535
struct lock_file lock = LOCK_INIT;
@@ -1502,8 +1505,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
15021505
"it...\n"));
15031506

15041507
strbuf_addf(&msg, "rebase: checkout %s", options.onto_name);
1505-
if (reset_head(&options.onto->object.oid, "checkout", NULL, 1,
1506-
NULL, msg.buf))
1508+
if (reset_head(&options.onto->object.oid, "checkout", NULL,
1509+
RESET_HEAD_DETACH, NULL, msg.buf))
15071510
die(_("Could not detach HEAD"));
15081511
strbuf_release(&msg);
15091512

0 commit comments

Comments
 (0)