summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorLiam Beguin <liambeguin@gmail.com>2017-12-05 17:52:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-05 18:20:51 (GMT)
commitd8ae6c84da52a210e84b3734bb93c575638236d3 (patch)
tree1754874ac9b537a7a5f542e82b43b67d6d160583 /sequencer.c
parent0cce4a2756eb2c66544615e5ccd74671afb33256 (diff)
downloadgit-d8ae6c84da52a210e84b3734bb93c575638236d3.zip
git-d8ae6c84da52a210e84b3734bb93c575638236d3.tar.gz
git-d8ae6c84da52a210e84b3734bb93c575638236d3.tar.bz2
rebase -i: learn to abbreviate command names
`git rebase -i` already know how to interpret single-letter command names. Teach it to generate the todo list with these same abbreviated names. Based-on-patch-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Liam Beguin <liambeguin@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sequencer.c b/sequencer.c
index 892d242..115085d 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -795,6 +795,13 @@ static const char *command_to_string(const enum todo_command command)
die("Unknown command: %d", command);
}
+static const char command_to_char(const enum todo_command command)
+{
+ if (command < TODO_COMMENT && todo_command_info[command].c)
+ return todo_command_info[command].c;
+ return comment_line_char;
+}
+
static int is_noop(const enum todo_command command)
{
return TODO_NOOP <= command;
@@ -2453,6 +2460,7 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
struct rev_info revs;
struct commit *commit;
int keep_empty = flags & TODO_LIST_KEEP_EMPTY;
+ const char *insn = flags & TODO_LIST_ABBREVIATE_CMDS ? "p" : "pick";
init_revisions(&revs, NULL);
revs.verbose_header = 1;
@@ -2485,7 +2493,8 @@ int sequencer_make_script(FILE *out, int argc, const char **argv,
strbuf_reset(&buf);
if (!keep_empty && is_original_commit_empty(commit))
strbuf_addf(&buf, "%c ", comment_line_char);
- strbuf_addf(&buf, "pick %s ", oid_to_hex(&commit->object.oid));
+ strbuf_addf(&buf, "%s %s ", insn,
+ oid_to_hex(&commit->object.oid));
pretty_print_commit(&pp, commit, &buf);
strbuf_addch(&buf, '\n');
fputs(buf.buf, out);
@@ -2558,7 +2567,10 @@ int transform_todos(unsigned flags)
}
/* add command to the buffer */
- strbuf_addstr(&buf, command_to_string(item->command));
+ if (flags & TODO_LIST_ABBREVIATE_CMDS)
+ strbuf_addch(&buf, command_to_char(item->command));
+ else
+ strbuf_addstr(&buf, command_to_string(item->command));
/* add commit id */
if (item->commit) {