Skip to content

Commit a97d791

Browse files
derrickstoleegitster
authored andcommitted
sequencer: add update-ref command
Add the boilerplate for an "update-ref" command in the sequencer. This connects to the current no-op do_update_ref() which will be filled in after more connections are created. The syntax in the todo list will be "update-ref <ref-name>" to signal that we should store the current commit as the value for updating <ref-name> at the end of the rebase. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d7ce9a2 commit a97d791

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

rebase-interactive.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ void append_todo_help(int command_count,
5757
" create a merge commit using the original merge commit's\n"
5858
" message (or the oneline, if no original merge commit was\n"
5959
" specified); use -c <commit> to reword the commit message\n"
60+
"u, update-ref <ref> = track a placeholder for the <ref> to be updated\n"
61+
" to this position in the new commits. The <ref> is\n"
62+
" updated at the end of the rebase\n"
6063
"\n"
6164
"These lines can be re-ordered; they are executed from top to bottom.\n");
6265
unsigned edit_todo = !(shortrevisions && shortonto);

sequencer.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,7 @@ static struct {
17231723
[TODO_LABEL] = { 'l', "label" },
17241724
[TODO_RESET] = { 't', "reset" },
17251725
[TODO_MERGE] = { 'm', "merge" },
1726+
[TODO_UPDATE_REF] = { 'u', "update-ref" },
17261727
[TODO_NOOP] = { 0, "noop" },
17271728
[TODO_DROP] = { 'd', "drop" },
17281729
[TODO_COMMENT] = { 0, NULL },
@@ -2504,7 +2505,7 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
25042505
command_to_string(item->command));
25052506

25062507
if (item->command == TODO_EXEC || item->command == TODO_LABEL ||
2507-
item->command == TODO_RESET) {
2508+
item->command == TODO_RESET || item->command == TODO_UPDATE_REF) {
25082509
item->commit = NULL;
25092510
item->arg_offset = bol - buf;
25102511
item->arg_len = (int)(eol - bol);
@@ -4104,6 +4105,11 @@ static int do_merge(struct repository *r,
41044105
return ret;
41054106
}
41064107

4108+
static int do_update_ref(struct repository *r, const char *ref_name)
4109+
{
4110+
return 0;
4111+
}
4112+
41074113
static int is_final_fixup(struct todo_list *todo_list)
41084114
{
41094115
int i = todo_list->current;
@@ -4479,6 +4485,12 @@ static int pick_commits(struct repository *r,
44794485
return error_with_patch(r, item->commit,
44804486
arg, item->arg_len,
44814487
opts, res, 0);
4488+
} else if (item->command == TODO_UPDATE_REF) {
4489+
struct strbuf ref = STRBUF_INIT;
4490+
strbuf_add(&ref, arg, item->arg_len);
4491+
if ((res = do_update_ref(r, ref.buf)))
4492+
reschedule = 1;
4493+
strbuf_release(&ref);
44824494
} else if (!is_noop(item->command))
44834495
return error(_("unknown command %d"), item->command);
44844496

sequencer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ enum todo_command {
9696
TODO_LABEL,
9797
TODO_RESET,
9898
TODO_MERGE,
99+
TODO_UPDATE_REF,
99100
/* commands that do nothing but are counted for reporting progress */
100101
TODO_NOOP,
101102
TODO_DROP,

0 commit comments

Comments
 (0)