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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Nov 12, 2018 at 03:44 UTC
73d6d7b24b498df98295763dd82c010c15e65db5
1 file changed
+6
-3
builtin/rebase.c
+6
-3
@@ -522,10 +522,13 @@ finished_rebase:
522
523
#define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
524
525
+#define RESET_HEAD_DETACH (1<<0)
526
+
527
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,
529
const char *reflog_orig_head, const char *reflog_head)
530
{
531
+ unsigned detach_head = flags & RESET_HEAD_DETACH;
532
struct object_id head_oid;
533
struct tree_desc desc;
534
struct lock_file lock = LOCK_INIT;
@@ -1500,8 +1503,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1503
"it...\n"));
1504
1505
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))
1508
die(_("Could not detach HEAD"));
1509
strbuf_release(&msg);
1510