Git fork

Merge branch 'kh/sequencer-comment-char'

The sequencer failed to honor core.commentString in some places.

* kh/sequencer-comment-char:
sequencer: comment commit messages properly
sequencer: comment `--reference` subject line properly
sequencer: comment checked-out branch properly

+64 -10
+16 -10
sequencer.c
··· 1941 1941 1942 1942 static void update_comment_bufs(struct strbuf *buf1, struct strbuf *buf2, int n) 1943 1943 { 1944 - strbuf_setlen(buf1, 2); 1944 + strbuf_setlen(buf1, strlen(comment_line_str) + 1); 1945 1945 strbuf_addf(buf1, _(nth_commit_msg_fmt), n); 1946 1946 strbuf_addch(buf1, '\n'); 1947 - strbuf_setlen(buf2, 2); 1947 + strbuf_setlen(buf2, strlen(comment_line_str) + 1); 1948 1948 strbuf_addf(buf2, _(skip_nth_commit_msg_fmt), n); 1949 1949 strbuf_addch(buf2, '\n'); 1950 1950 } ··· 1963 1963 size_t orig_msg_len; 1964 1964 int i = 1; 1965 1965 1966 - strbuf_addf(&buf1, "# %s\n", _(first_commit_msg_str)); 1967 - strbuf_addf(&buf2, "# %s\n", _(skip_first_commit_msg_str)); 1966 + strbuf_add_commented_lines(&buf1, _(first_commit_msg_str), 1967 + strlen(_(first_commit_msg_str)), 1968 + comment_line_str); 1969 + strbuf_add_commented_lines(&buf2, _(skip_first_commit_msg_str), 1970 + strlen(_(skip_first_commit_msg_str)), 1971 + comment_line_str); 1968 1972 s = start = orig_msg = strbuf_detach(msg, &orig_msg_len); 1969 1973 while (s) { 1970 1974 const char *next; ··· 2341 2345 next = parent; 2342 2346 next_label = msg.parent_label; 2343 2347 if (opts->commit_use_reference) { 2344 - strbuf_addstr(&ctx->message, 2345 - "# *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***"); 2348 + strbuf_commented_addf(&ctx->message, comment_line_str, 2349 + "*** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***"); 2346 2350 } else if (skip_prefix(msg.subject, "Revert \"", &orig_subject) && 2347 2351 /* 2348 2352 * We don't touch pre-existing repeated reverts, because ··· 2352 2356 !starts_with(orig_subject, "Revert \"")) { 2353 2357 strbuf_addstr(&ctx->message, "Reapply \""); 2354 2358 strbuf_addstr(&ctx->message, orig_subject); 2359 + strbuf_addstr(&ctx->message, "\n"); 2355 2360 } else { 2356 2361 strbuf_addstr(&ctx->message, "Revert \""); 2357 2362 strbuf_addstr(&ctx->message, msg.subject); 2358 - strbuf_addstr(&ctx->message, "\""); 2363 + strbuf_addstr(&ctx->message, "\"\n"); 2359 2364 } 2360 - strbuf_addstr(&ctx->message, "\n\nThis reverts commit "); 2365 + strbuf_addstr(&ctx->message, "\nThis reverts commit "); 2361 2366 refer_to_commit(opts, &ctx->message, commit); 2362 2367 2363 2368 if (commit->parents && commit->parents->next) { ··· 6382 6387 /* If the branch is checked out, then leave a comment instead. */ 6383 6388 if ((path = branch_checked_out(decoration->name))) { 6384 6389 item->command = TODO_COMMENT; 6385 - strbuf_addf(ctx->buf, "# Ref %s checked out at '%s'\n", 6386 - decoration->name, path); 6390 + strbuf_commented_addf(ctx->buf, comment_line_str, 6391 + "Ref %s checked out at '%s'\n", 6392 + decoration->name, path); 6387 6393 } else { 6388 6394 struct string_list_item *sti; 6389 6395 item->command = TODO_UPDATE_REF;
+19
t/t3400-rebase.sh
··· 455 455 ) 456 456 ' 457 457 458 + test_expect_success 'git rebase --update-ref with core.commentChar and branch on worktree' ' 459 + test_when_finished git branch -D base topic2 && 460 + test_when_finished git checkout main && 461 + test_when_finished git branch -D wt-topic && 462 + test_when_finished git worktree remove wt-topic && 463 + git checkout main && 464 + git checkout -b base && 465 + git checkout -b topic2 && 466 + test_commit msg2 && 467 + git worktree add wt-topic && 468 + git checkout base && 469 + test_commit msg3 && 470 + git checkout topic2 && 471 + GIT_SEQUENCE_EDITOR="cat >actual" git -c core.commentChar=% \ 472 + rebase -i --update-refs base && 473 + test_grep "% Ref refs/heads/wt-topic checked out at" actual && 474 + test_grep "% Ref refs/heads/topic2 checked out at" actual 475 + ' 476 + 458 477 test_done
+15
t/t3437-rebase-fixup-options.sh
··· 126 126 test_cmp expected-author actual-author 127 127 ' 128 128 129 + test_expect_success 'conflicting fixup -C after fixup with custom comment string' ' 130 + test_config core.commentString COMMENT && 131 + test_when_finished "test_might_fail git rebase --abort" && 132 + git checkout --detach A3 && 133 + test_must_fail env FAKE_LINES="1 fixup 2 fixup_-C 4" git rebase -i A && 134 + echo resolved >A && 135 + git add A && 136 + FAKE_COMMIT_AMEND=edited git rebase --continue && 137 + test_commit_message HEAD <<-\EOF 138 + A3 139 + 140 + edited 141 + EOF 142 + ' 143 + 129 144 test_expect_success 'skipping fixup -C after fixup gives correct message' ' 130 145 test_when_finished "test_might_fail git rebase --abort" && 131 146 git checkout --detach A3 &&
+14
t/t3501-revert-cherry-pick.sh
··· 227 227 test_cmp expect actual 228 228 ' 229 229 230 + test_expect_success 'git revert --reference with core.commentChar' ' 231 + test_when_finished "git reset --hard to-ident" && 232 + git checkout --detach to-ident && 233 + GIT_EDITOR="head -n4 >actual" git -c core.commentChar=% revert \ 234 + --edit --reference HEAD && 235 + cat <<-EOF >expect && 236 + % *** SAY WHY WE ARE REVERTING ON THE TITLE LINE *** 237 + 238 + This reverts commit $(git show -s --pretty=reference HEAD^). 239 + 240 + EOF 241 + test_cmp expect actual 242 + ' 243 + 230 244 test_expect_success 'identification of reverted commit (revert.reference)' ' 231 245 git checkout --detach to-ident && 232 246 git -c revert.reference=true revert --no-edit HEAD &&