Merge branch 'en/sequencer-reflog-action'
"git rebase -i" did not leave the reflog entries correctly. * en/sequencer-reflog-action: sequencer: honor GIT_REFLOG_ACTION
This commit is contained in:
10
sequencer.c
10
sequencer.c
@ -3724,10 +3724,11 @@ static const char *reflog_message(struct replay_opts *opts,
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
static struct strbuf buf = STRBUF_INIT;
|
static struct strbuf buf = STRBUF_INIT;
|
||||||
|
char *reflog_action = getenv(GIT_REFLOG_ACTION);
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
strbuf_reset(&buf);
|
strbuf_reset(&buf);
|
||||||
strbuf_addstr(&buf, action_name(opts));
|
strbuf_addstr(&buf, reflog_action ? reflog_action : action_name(opts));
|
||||||
if (sub_action)
|
if (sub_action)
|
||||||
strbuf_addf(&buf, " (%s)", sub_action);
|
strbuf_addf(&buf, " (%s)", sub_action);
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
@ -3815,8 +3816,11 @@ static int pick_commits(struct repository *r,
|
|||||||
struct replay_opts *opts)
|
struct replay_opts *opts)
|
||||||
{
|
{
|
||||||
int res = 0, reschedule = 0;
|
int res = 0, reschedule = 0;
|
||||||
|
char *prev_reflog_action;
|
||||||
|
|
||||||
|
/* Note that 0 for 3rd parameter of setenv means set only if not set */
|
||||||
setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
|
setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
|
||||||
|
prev_reflog_action = xstrdup(getenv(GIT_REFLOG_ACTION));
|
||||||
if (opts->allow_ff)
|
if (opts->allow_ff)
|
||||||
assert(!(opts->signoff || opts->no_commit ||
|
assert(!(opts->signoff || opts->no_commit ||
|
||||||
opts->record_origin || opts->edit));
|
opts->record_origin || opts->edit));
|
||||||
@ -3861,12 +3865,14 @@ static int pick_commits(struct repository *r,
|
|||||||
}
|
}
|
||||||
if (item->command <= TODO_SQUASH) {
|
if (item->command <= TODO_SQUASH) {
|
||||||
if (is_rebase_i(opts))
|
if (is_rebase_i(opts))
|
||||||
setenv("GIT_REFLOG_ACTION", reflog_message(opts,
|
setenv(GIT_REFLOG_ACTION, reflog_message(opts,
|
||||||
command_to_string(item->command), NULL),
|
command_to_string(item->command), NULL),
|
||||||
1);
|
1);
|
||||||
res = do_pick_commit(r, item->command, item->commit,
|
res = do_pick_commit(r, item->command, item->commit,
|
||||||
opts, is_final_fixup(todo_list),
|
opts, is_final_fixup(todo_list),
|
||||||
&check_todo);
|
&check_todo);
|
||||||
|
if (is_rebase_i(opts))
|
||||||
|
setenv(GIT_REFLOG_ACTION, prev_reflog_action, 1);
|
||||||
if (is_rebase_i(opts) && res < 0) {
|
if (is_rebase_i(opts) && res < 0) {
|
||||||
/* Reschedule */
|
/* Reschedule */
|
||||||
advise(_(rescheduled_advice),
|
advise(_(rescheduled_advice),
|
||||||
|
@ -89,22 +89,22 @@ test_expect_success 'GIT_REFLOG_ACTION' '
|
|||||||
git checkout -b reflog-topic start &&
|
git checkout -b reflog-topic start &&
|
||||||
test_commit reflog-to-rebase &&
|
test_commit reflog-to-rebase &&
|
||||||
|
|
||||||
git rebase --apply reflog-onto &&
|
git rebase reflog-onto &&
|
||||||
git log -g --format=%gs -3 >actual &&
|
git log -g --format=%gs -3 >actual &&
|
||||||
cat >expect <<-\EOF &&
|
cat >expect <<-\EOF &&
|
||||||
rebase finished: returning to refs/heads/reflog-topic
|
rebase (finish): returning to refs/heads/reflog-topic
|
||||||
rebase: reflog-to-rebase
|
rebase (pick): reflog-to-rebase
|
||||||
rebase: checkout reflog-onto
|
rebase (start): checkout reflog-onto
|
||||||
EOF
|
EOF
|
||||||
test_cmp expect actual &&
|
test_cmp expect actual &&
|
||||||
|
|
||||||
git checkout -b reflog-prefix reflog-to-rebase &&
|
git checkout -b reflog-prefix reflog-to-rebase &&
|
||||||
GIT_REFLOG_ACTION=change-the-reflog git rebase --apply reflog-onto &&
|
GIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto &&
|
||||||
git log -g --format=%gs -3 >actual &&
|
git log -g --format=%gs -3 >actual &&
|
||||||
cat >expect <<-\EOF &&
|
cat >expect <<-\EOF &&
|
||||||
rebase finished: returning to refs/heads/reflog-prefix
|
change-the-reflog (finish): returning to refs/heads/reflog-prefix
|
||||||
change-the-reflog: reflog-to-rebase
|
change-the-reflog (pick): reflog-to-rebase
|
||||||
change-the-reflog: checkout reflog-onto
|
change-the-reflog (start): checkout reflog-onto
|
||||||
EOF
|
EOF
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
Reference in New Issue
Block a user