Skip to content

Commit 80f49f2

Browse files
committed
Merge branch 'en/sequencer-comment-messages'
Prefix '#' to the commit title in the "rebase -i" todo file, just like a merge commit being replayed. * en/sequencer-comment-messages: sequencer: make it clearer that commit descriptions are just comments
2 parents f9cdaa2 + e426672 commit 80f49f2

File tree

6 files changed

+94
-88
lines changed

6 files changed

+94
-88
lines changed

sequencer.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5902,11 +5902,11 @@ static int make_script_with_merges(struct pretty_print_context *pp,
59025902

59035903
/* Create a label from the commit message */
59045904
strbuf_reset(&label_from_message);
5905-
if (skip_prefix(oneline.buf, "Merge ", &p1) &&
5905+
if (skip_prefix(oneline.buf, "# Merge ", &p1) &&
59065906
(p1 = strchr(p1, '\'')) &&
59075907
(p2 = strchr(++p1, '\'')))
59085908
strbuf_add(&label_from_message, p1, p2 - p1);
5909-
else if (skip_prefix(oneline.buf, "Merge pull request ",
5909+
else if (skip_prefix(oneline.buf, "# Merge pull request ",
59105910
&p1) &&
59115911
(p1 = strstr(p1, " from ")))
59125912
strbuf_addstr(&label_from_message, p1 + strlen(" from "));
@@ -5941,7 +5941,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
59415941

59425942
strbuf_addstr(&buf, label_oid(oid, label, &state));
59435943
}
5944-
strbuf_addf(&buf, " # %s", oneline.buf);
5944+
strbuf_addf(&buf, " %s", oneline.buf);
59455945

59465946
FLEX_ALLOC_STR(entry, string, buf.buf);
59475947
oidcpy(&entry->entry.oid, &commit->object.oid);
@@ -6023,7 +6023,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
60236023
else {
60246024
strbuf_reset(&oneline);
60256025
pretty_print_commit(pp, commit, &oneline);
6026-
strbuf_addf(out, "%s %s # %s\n",
6026+
strbuf_addf(out, "%s %s %s\n",
60276027
cmd_reset, to, oneline.buf);
60286028
}
60296029
}
@@ -6091,8 +6091,14 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
60916091
git_config_get_string("rebase.instructionFormat", &format);
60926092
if (!format || !*format) {
60936093
free(format);
6094-
format = xstrdup("%s");
6094+
format = xstrdup("# %s");
60956095
}
6096+
if (*format != '#') {
6097+
char *temp = format;
6098+
format = xstrfmt("# %s", temp);
6099+
free(temp);
6100+
}
6101+
60966102
get_commit_format(format, &revs);
60976103
free(format);
60986104
pp.fmt = revs.commit_format;

t/t3404-rebase-interactive.sh

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
14681468
cat >expect <<-EOF &&
14691469
Warning: some commits may have been dropped accidentally.
14701470
Dropped commits (newer to older):
1471-
- $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1471+
- $(git log --format="%h # %s" -1 primary)
14721472
To avoid this message, use "drop" to explicitly remove a commit.
14731473
EOF
14741474
test_config rebase.missingCommitsCheck warn &&
@@ -1486,8 +1486,8 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
14861486
cat >expect <<-EOF &&
14871487
Warning: some commits may have been dropped accidentally.
14881488
Dropped commits (newer to older):
1489-
- $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1490-
- $(git rev-list --pretty=oneline --abbrev-commit -1 primary~2)
1489+
- $(git log --format="%h # %s" -1 primary)
1490+
- $(git log --format="%h # %s" -1 primary~2)
14911491
To avoid this message, use "drop" to explicitly remove a commit.
14921492
14931493
Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
@@ -1530,11 +1530,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ig
15301530
test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' '
15311531
cat >expect <<-EOF &&
15321532
error: invalid command '\''pickled'\''
1533-
error: invalid line 1: pickled $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1533+
error: invalid line 1: pickled $(git log --format="%h # %s" -1 primary~4)
15341534
Warning: some commits may have been dropped accidentally.
15351535
Dropped commits (newer to older):
1536-
- $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1537-
- $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1536+
- $(git log --format="%h # %s" -1 primary)
1537+
- $(git log --format="%h # %s" -1 primary~4)
15381538
To avoid this message, use "drop" to explicitly remove a commit.
15391539
EOF
15401540
head -n5 expect >expect.2 &&
@@ -1565,11 +1565,11 @@ test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = wa
15651565
test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' '
15661566
cat >expect <<-EOF &&
15671567
error: invalid command '\''pickled'\''
1568-
error: invalid line 1: pickled $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1568+
error: invalid line 1: pickled $(git log --format="%h # %s" -1 primary~4)
15691569
Warning: some commits may have been dropped accidentally.
15701570
Dropped commits (newer to older):
1571-
- $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1572-
- $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1571+
- $(git log --format="%h # %s" -1 primary)
1572+
- $(git log --format="%h # %s" -1 primary~4)
15731573
To avoid this message, use "drop" to explicitly remove a commit.
15741574
15751575
Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
@@ -1642,11 +1642,11 @@ test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and e
16421642
test_commit "fixup! first" file2.txt "first line again" first_fixup &&
16431643
test_commit "squash! second" file1.txt "another line here" second_squash &&
16441644
cat >expected <<-EOF &&
1645-
p $(git rev-list --abbrev-commit -1 first) first
1646-
f $(git rev-list --abbrev-commit -1 first_fixup) fixup! first
1645+
p $(git rev-list --abbrev-commit -1 first) # first
1646+
f $(git rev-list --abbrev-commit -1 first_fixup) # fixup! first
16471647
x git show HEAD
1648-
p $(git rev-list --abbrev-commit -1 second) second
1649-
s $(git rev-list --abbrev-commit -1 second_squash) squash! second
1648+
p $(git rev-list --abbrev-commit -1 second) # second
1649+
s $(git rev-list --abbrev-commit -1 second_squash) # squash! second
16501650
x git show HEAD
16511651
EOF
16521652
git checkout abbrevcmd &&
@@ -1665,7 +1665,7 @@ test_expect_success 'static check of bad command' '
16651665
set_fake_editor &&
16661666
test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
16671667
git rebase -i --root 2>actual &&
1668-
test_grep "pickled $(git rev-list --oneline -1 primary~1)" \
1668+
test_grep "pickled $(git log --format="%h # %s" -1 primary~1)" \
16691669
actual &&
16701670
test_grep "You can fix this with .git rebase --edit-todo.." \
16711671
actual &&
@@ -1865,15 +1865,15 @@ test_expect_success '--update-refs adds label and update-ref commands' '
18651865
set_cat_todo_editor &&
18661866
18671867
cat >expect <<-EOF &&
1868-
pick $(git log -1 --format=%h J) J
1869-
fixup $(git log -1 --format=%h update-refs) fixup! J # empty
1868+
pick $(git log -1 --format=%h J) # J
1869+
fixup $(git log -1 --format=%h update-refs) # fixup! J # empty
18701870
update-ref refs/heads/second
18711871
update-ref refs/heads/first
1872-
pick $(git log -1 --format=%h K) K
1873-
pick $(git log -1 --format=%h L) L
1874-
fixup $(git log -1 --format=%h is-not-reordered) fixup! L # empty
1872+
pick $(git log -1 --format=%h K) # K
1873+
pick $(git log -1 --format=%h L) # L
1874+
fixup $(git log -1 --format=%h is-not-reordered) # fixup! L # empty
18751875
update-ref refs/heads/third
1876-
pick $(git log -1 --format=%h M) M
1876+
pick $(git log -1 --format=%h M) # M
18771877
update-ref refs/heads/no-conflict-branch
18781878
update-ref refs/heads/is-not-reordered
18791879
update-ref refs/heads/shared-tip
@@ -1905,19 +1905,19 @@ test_expect_success '--update-refs adds commands with --rebase-merges' '
19051905
cat >expect <<-EOF &&
19061906
label onto
19071907
reset onto
1908-
pick $(git log -1 --format=%h branch2~1) F
1909-
pick $(git log -1 --format=%h branch2) I
1908+
pick $(git log -1 --format=%h branch2~1) # F
1909+
pick $(git log -1 --format=%h branch2) # I
19101910
update-ref refs/heads/branch2
19111911
label branch2
19121912
reset onto
1913-
pick $(git log -1 --format=%h refs/heads/second) J
1913+
pick $(git log -1 --format=%h refs/heads/second) # J
19141914
update-ref refs/heads/second
19151915
update-ref refs/heads/first
1916-
pick $(git log -1 --format=%h refs/heads/third~1) K
1917-
pick $(git log -1 --format=%h refs/heads/third) L
1918-
fixup $(git log -1 --format=%h update-refs-with-merge) fixup! L # empty
1916+
pick $(git log -1 --format=%h refs/heads/third~1) # K
1917+
pick $(git log -1 --format=%h refs/heads/third) # L
1918+
fixup $(git log -1 --format=%h update-refs-with-merge) # fixup! L # empty
19191919
update-ref refs/heads/third
1920-
pick $(git log -1 --format=%h HEAD~2) M
1920+
pick $(git log -1 --format=%h HEAD~2) # M
19211921
update-ref refs/heads/no-conflict-branch
19221922
merge -C $(git log -1 --format=%h HEAD~1) branch2 # merge
19231923
update-ref refs/heads/merge-branch

t/t3415-rebase-autosquash.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ test_expect_success 'auto squash of fixup commit that matches branch name which
257257
GIT_SEQUENCE_EDITOR="cat >tmp" git rebase --autosquash -i HEAD^^ &&
258258
sed -ne "/^[^#]/{s/[0-9a-f]\{7,\}/HASH/g;p;}" tmp >actual &&
259259
cat <<-EOF >expect &&
260-
pick HASH second commit
261-
pick HASH fixup! self-cycle # empty
260+
pick HASH # second commit
261+
pick HASH # fixup! self-cycle # empty
262262
EOF
263263
test_cmp expect actual
264264
'
@@ -311,10 +311,10 @@ test_auto_fixup_fixup () {
311311
parent2=$(git rev-parse --short HEAD^^) &&
312312
parent3=$(git rev-parse --short HEAD^^^) &&
313313
cat >expected <<-EOF &&
314-
pick $parent3 first commit
315-
$1 $parent1 $1! first
316-
$1 $head $1! $2! first
317-
pick $parent2 second commit
314+
pick $parent3 # first commit
315+
$1 $parent1 # $1! first
316+
$1 $head # $1! $2! first
317+
pick $parent2 # second commit
318318
EOF
319319
test_cmp expected actual
320320
) &&
@@ -389,7 +389,7 @@ test_expect_success 'autosquash with empty custom instructionFormat' '
389389
set_cat_todo_editor &&
390390
test_must_fail git -c rebase.instructionFormat= \
391391
rebase --autosquash --force-rebase -i HEAD^ >actual &&
392-
git log -1 --format="pick %h %s" >expect &&
392+
git log -1 --format="pick %h # %s" >expect &&
393393
test_cmp expect actual
394394
)
395395
'

t/t3430-rebase-merges.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ test_expect_success 'generate correct todo list' '
115115
label onto
116116
117117
reset onto
118-
pick $b B
118+
pick $b # B
119119
label first
120120
121121
reset onto
122-
pick $c C
122+
pick $c # C
123123
label branch-point
124-
pick $f F
125-
pick $g G
124+
pick $f # F
125+
pick $g # G
126126
label second
127127
128128
reset branch-point # C
129-
pick $d D
129+
pick $d # D
130130
merge -C $e first # E
131131
merge -C $h second # H
132132

t/t5520-pull.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ test_expect_success 'git pull --rebase does not reapply old patches' '
813813
cd dst &&
814814
test_must_fail git pull --rebase &&
815815
cat .git/rebase-merge/done .git/rebase-merge/git-rebase-todo >work &&
816-
grep -v -e \# -e ^$ work >patches &&
816+
grep -v -e ^\# -e ^$ work >patches &&
817817
test_line_count = 1 patches &&
818818
rm -f work
819819
)

0 commit comments

Comments
 (0)