Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
rebase: teach `reset_head()` to optionally skip the worktree
author
Johannes Schindelin
<johannes.schindelin@gmx.de>
Fri, 18 Jan 2019 15:09:26 +0000
(07:09 -0800)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 18 Jan 2019 18:11:45 +0000
(10:11 -0800)
This is what the legacy (scripted) rebase does in
`move_to_original_branch`, and we will need this functionality in the
next commit.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rebase.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
5b2237a
)
diff --git
a/builtin/rebase.c
b/builtin/rebase.c
index 768bea0da8751228d3aa3acf1943aaefbe19666c..df151217dab16b27ca6d3392615991b333ec9f25 100644
(file)
--- a/
builtin/rebase.c
+++ b/
builtin/rebase.c
@@
-337,6
+337,7
@@
static void add_var(struct strbuf *buf, const char *name, const char *value)
#define RESET_HEAD_DETACH (1<<0)
#define RESET_HEAD_HARD (1<<1)
#define RESET_HEAD_DETACH (1<<0)
#define RESET_HEAD_HARD (1<<1)
+#define RESET_HEAD_REFS_ONLY (1<<2)
static int reset_head(struct object_id *oid, const char *action,
const char *switch_to_branch, unsigned flags,
static int reset_head(struct object_id *oid, const char *action,
const char *switch_to_branch, unsigned flags,
@@
-344,6
+345,7
@@
static int reset_head(struct object_id *oid, const char *action,
{
unsigned detach_head = flags & RESET_HEAD_DETACH;
unsigned reset_hard = flags & RESET_HEAD_HARD;
{
unsigned detach_head = flags & RESET_HEAD_DETACH;
unsigned reset_hard = flags & RESET_HEAD_HARD;
+ unsigned refs_only = flags & RESET_HEAD_REFS_ONLY;
struct object_id head_oid;
struct tree_desc desc[2] = { { NULL }, { NULL } };
struct lock_file lock = LOCK_INIT;
struct object_id head_oid;
struct tree_desc desc[2] = { { NULL }, { NULL } };
struct lock_file lock = LOCK_INIT;
@@
-359,7
+361,7
@@
static int reset_head(struct object_id *oid, const char *action,
if (switch_to_branch && !starts_with(switch_to_branch, "refs/"))
BUG("Not a fully qualified branch: '%s'", switch_to_branch);
if (switch_to_branch && !starts_with(switch_to_branch, "refs/"))
BUG("Not a fully qualified branch: '%s'", switch_to_branch);
- if (hold_locked_index(&lock, LOCK_REPORT_ON_ERROR) < 0) {
+ if (
!refs_only &&
hold_locked_index(&lock, LOCK_REPORT_ON_ERROR) < 0) {
ret = -1;
goto leave_reset_head;
}
ret = -1;
goto leave_reset_head;
}
@@
-372,6
+374,9
@@
static int reset_head(struct object_id *oid, const char *action,
if (!oid)
oid = &head_oid;
if (!oid)
oid = &head_oid;
+ if (refs_only)
+ goto reset_head_refs;
+
memset(&unpack_tree_opts, 0, sizeof(unpack_tree_opts));
setup_unpack_trees_porcelain(&unpack_tree_opts, action);
unpack_tree_opts.head_idx = 1;
memset(&unpack_tree_opts, 0, sizeof(unpack_tree_opts));
setup_unpack_trees_porcelain(&unpack_tree_opts, action);
unpack_tree_opts.head_idx = 1;
@@
-412,6
+417,7
@@
static int reset_head(struct object_id *oid, const char *action,
goto leave_reset_head;
}
goto leave_reset_head;
}
+reset_head_refs:
reflog_action = getenv(GIT_REFLOG_ACTION_ENVIRONMENT);
strbuf_addf(&msg, "%s: ", reflog_action ? reflog_action : "rebase");
prefix_len = msg.len;
reflog_action = getenv(GIT_REFLOG_ACTION_ENVIRONMENT);
strbuf_addf(&msg, "%s: ", reflog_action ? reflog_action : "rebase");
prefix_len = msg.len;