@@ -252,6 +252,16 @@ static int init_basic_state(struct replay_opts *opts, const char *head_name,
return write_basic_state(opts, head_name, onto, orig_head);
}
+static void update_tail(struct rebase_options *opts)
+{
+ const char *shortname = NULL;
+ struct strbuf ref = STRBUF_INIT;
+ skip_prefix(opts->head_name, "refs/heads/", &shortname);
+ strbuf_addf(&ref, "refs/tails/%s", shortname);
+ update_ref(NULL, ref.buf, &opts->onto->object.oid, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
+ strbuf_release(&ref);
+}
+
static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
{
int ret = -1;
@@ -294,6 +304,9 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
shortrevisions, opts->onto_name, opts->onto,
&opts->orig_head->object.oid, &opts->exec,
opts->autosquash, opts->update_refs, &todo_list);
+
+ if (!ret)
+ update_tail(opts);
}
cleanup:
@@ -564,6 +577,8 @@ static int finish_rebase(struct rebase_options *opts)
strbuf_release(&dir);
}
+ update_tail(opts);
+
return ret;
}
@@ -26,4 +26,14 @@ test_expect_success 'test @{tail}' '
test_cmp expect actual
'
+test_expect_success 'test rebase tail update' '
+ git checkout -b next master &&
+ echo three > content &&
+ git commit -a -m three &&
+ git rebase --onto next test@{tail} test &&
+ git rev-parse test@{tail} > actual &&
+ git rev-parse next > expect &&
+ test_cmp expect actual
+'
+
test_done
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- builtin/rebase.c | 15 +++++++++++++++ t/t1514-rev-parse-tail.sh | 10 ++++++++++ 2 files changed, 25 insertions(+)