summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-04-22 13:42:50 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-04-22 13:42:50 -0700
commitf72e06703b14b3bccaaeee97ac82257dff67749c (patch)
tree10bfc3810c6301b1ce4dd9a5d338c15e0640678a
parentMerge branch 'jk/oid-array-cleanups' (diff)
parentt3432: test `--merge' with `rebase.abbreviateCommands = true', too (diff)
downloadtgif-f72e06703b14b3bccaaeee97ac82257dff67749c.tar.xz
Merge branch 'ag/rebase-merge-allow-ff-under-abbrev-command'
"git rebase" with the merge backend did not work well when the rebase.abbreviateCommands configuration was set. * ag/rebase-merge-allow-ff-under-abbrev-command: t3432: test `--merge' with `rebase.abbreviateCommands = true', too sequencer: don't abbreviate a command if it doesn't have a short form
-rw-r--r--sequencer.c9
-rwxr-xr-xt/t3432-rebase-fast-forward.sh24
2 files changed, 25 insertions, 8 deletions
diff --git a/sequencer.c b/sequencer.c
index ba13a9a63b..461df364c0 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1578,7 +1578,7 @@ static const char *command_to_string(const enum todo_command command)
static char command_to_char(const enum todo_command command)
{
- if (command < TODO_COMMENT && todo_command_info[command].c)
+ if (command < TODO_COMMENT)
return todo_command_info[command].c;
return comment_line_char;
}
@@ -4963,6 +4963,8 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis
max = num;
for (item = todo_list->items, i = 0; i < max; i++, item++) {
+ char cmd;
+
/* if the item is not a command write it and continue */
if (item->command >= TODO_COMMENT) {
strbuf_addf(buf, "%.*s\n", item->arg_len,
@@ -4971,8 +4973,9 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis
}
/* add command to the buffer */
- if (flags & TODO_LIST_ABBREVIATE_CMDS)
- strbuf_addch(buf, command_to_char(item->command));
+ cmd = command_to_char(item->command);
+ if ((flags & TODO_LIST_ABBREVIATE_CMDS) && cmd)
+ strbuf_addch(buf, cmd);
else
strbuf_addstr(buf, command_to_string(item->command));
diff --git a/t/t3432-rebase-fast-forward.sh b/t/t3432-rebase-fast-forward.sh
index 6c9d4a1375..6f0452c0ea 100755
--- a/t/t3432-rebase-fast-forward.sh
+++ b/t/t3432-rebase-fast-forward.sh
@@ -28,10 +28,12 @@ test_rebase_same_head () {
shift &&
cmp_f="$1" &&
shift &&
- test_rebase_same_head_ $status_n $what_n $cmp_n " --apply" "$*" &&
- test_rebase_same_head_ $status_f $what_f $cmp_f " --apply --no-ff" "$*"
- test_rebase_same_head_ $status_n $what_n $cmp_n " --merge" "$*" &&
- test_rebase_same_head_ $status_f $what_f $cmp_f " --merge --no-ff" "$*"
+ test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --apply" "$*" &&
+ test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --apply --no-ff" "$*"
+ test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --merge" "$*" &&
+ test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --merge --no-ff" "$*"
+ test_rebase_same_head_ $status_n $what_n $cmp_n 1 " --merge" "$*" &&
+ test_rebase_same_head_ $status_f $what_f $cmp_f 1 " --merge --no-ff" "$*"
}
test_rebase_same_head_ () {
@@ -41,9 +43,21 @@ test_rebase_same_head_ () {
shift &&
cmp="$1" &&
shift &&
+ abbreviate="$1" &&
+ shift &&
flag="$1"
shift &&
- test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" "
+ if test $abbreviate -eq 1
+ then
+ msg="git rebase$flag $* (rebase.abbreviateCommands = true) with $changes is $what with $cmp HEAD"
+ else
+ msg="git rebase$flag $* with $changes is $what with $cmp HEAD"
+ fi &&
+ test_expect_$status "$msg" "
+ if test $abbreviate -eq 1
+ then
+ test_config rebase.abbreviateCommands true
+ fi &&
oldhead=\$(git rev-parse HEAD) &&
test_when_finished 'git reset --hard \$oldhead' &&
cp .git/logs/HEAD expect &&