Skip to content

Commit f72e067

Browse files
committed
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
2 parents a768f86 + de9f1d3 commit f72e067

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

sequencer.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,7 @@ static const char *command_to_string(const enum todo_command command)
15781578

15791579
static char command_to_char(const enum todo_command command)
15801580
{
1581-
if (command < TODO_COMMENT && todo_command_info[command].c)
1581+
if (command < TODO_COMMENT)
15821582
return todo_command_info[command].c;
15831583
return comment_line_char;
15841584
}
@@ -4963,6 +4963,8 @@ static void todo_list_to_strbuf(struct repository *r, struct todo_list *todo_lis
49634963
max = num;
49644964

49654965
for (item = todo_list->items, i = 0; i < max; i++, item++) {
4966+
char cmd;
4967+
49664968
/* if the item is not a command write it and continue */
49674969
if (item->command >= TODO_COMMENT) {
49684970
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
49714973
}
49724974

49734975
/* add command to the buffer */
4974-
if (flags & TODO_LIST_ABBREVIATE_CMDS)
4975-
strbuf_addch(buf, command_to_char(item->command));
4976+
cmd = command_to_char(item->command);
4977+
if ((flags & TODO_LIST_ABBREVIATE_CMDS) && cmd)
4978+
strbuf_addch(buf, cmd);
49764979
else
49774980
strbuf_addstr(buf, command_to_string(item->command));
49784981

t/t3432-rebase-fast-forward.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ test_rebase_same_head () {
2828
shift &&
2929
cmp_f="$1" &&
3030
shift &&
31-
test_rebase_same_head_ $status_n $what_n $cmp_n " --apply" "$*" &&
32-
test_rebase_same_head_ $status_f $what_f $cmp_f " --apply --no-ff" "$*"
33-
test_rebase_same_head_ $status_n $what_n $cmp_n " --merge" "$*" &&
34-
test_rebase_same_head_ $status_f $what_f $cmp_f " --merge --no-ff" "$*"
31+
test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --apply" "$*" &&
32+
test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --apply --no-ff" "$*"
33+
test_rebase_same_head_ $status_n $what_n $cmp_n 0 " --merge" "$*" &&
34+
test_rebase_same_head_ $status_f $what_f $cmp_f 0 " --merge --no-ff" "$*"
35+
test_rebase_same_head_ $status_n $what_n $cmp_n 1 " --merge" "$*" &&
36+
test_rebase_same_head_ $status_f $what_f $cmp_f 1 " --merge --no-ff" "$*"
3537
}
3638

3739
test_rebase_same_head_ () {
@@ -41,9 +43,21 @@ test_rebase_same_head_ () {
4143
shift &&
4244
cmp="$1" &&
4345
shift &&
46+
abbreviate="$1" &&
47+
shift &&
4448
flag="$1"
4549
shift &&
46-
test_expect_$status "git rebase$flag $* with $changes is $what with $cmp HEAD" "
50+
if test $abbreviate -eq 1
51+
then
52+
msg="git rebase$flag $* (rebase.abbreviateCommands = true) with $changes is $what with $cmp HEAD"
53+
else
54+
msg="git rebase$flag $* with $changes is $what with $cmp HEAD"
55+
fi &&
56+
test_expect_$status "$msg" "
57+
if test $abbreviate -eq 1
58+
then
59+
test_config rebase.abbreviateCommands true
60+
fi &&
4761
oldhead=\$(git rev-parse HEAD) &&
4862
test_when_finished 'git reset --hard \$oldhead' &&
4963
cp .git/logs/HEAD expect &&

0 commit comments

Comments
 (0)