Git fork

sequencer: comment checked-out branch properly

`git rebase --update-ref` does not insert commands for dependent/sub-
branches which are checked out.[1] Instead it leaves a comment about
that fact. The comment char is hardcoded (#). In turn the comment
line gets interpreted as an invalid command when `core.commentChar`/
`core.commentString` is in use.

† 1: See 900b50c242 (rebase: add --update-refs option, 2022-07-19)

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Kristoffer Haugsbakk and committed by
Junio C Hamano
94304b9f fd378533

+22 -2
+3 -2
sequencer.c
··· 6382 6382 /* If the branch is checked out, then leave a comment instead. */ 6383 6383 if ((path = branch_checked_out(decoration->name))) { 6384 6384 item->command = TODO_COMMENT; 6385 - strbuf_addf(ctx->buf, "# Ref %s checked out at '%s'\n", 6386 - decoration->name, path); 6385 + strbuf_commented_addf(ctx->buf, comment_line_str, 6386 + "Ref %s checked out at '%s'\n", 6387 + decoration->name, path); 6387 6388 } else { 6388 6389 struct string_list_item *sti; 6389 6390 item->command = TODO_UPDATE_REF;
+19
t/t3400-rebase.sh
··· 456 456 ) 457 457 ' 458 458 459 + test_expect_success 'git rebase --update-ref with core.commentChar and branch on worktree' ' 460 + test_when_finished git branch -D base topic2 && 461 + test_when_finished git checkout main && 462 + test_when_finished git branch -D wt-topic && 463 + test_when_finished git worktree remove wt-topic && 464 + git checkout main && 465 + git checkout -b base && 466 + git checkout -b topic2 && 467 + test_commit msg2 && 468 + git worktree add wt-topic && 469 + git checkout base && 470 + test_commit msg3 && 471 + git checkout topic2 && 472 + GIT_SEQUENCE_EDITOR="cat >actual" git -c core.commentChar=% \ 473 + rebase -i --update-refs base && 474 + test_grep "% Ref refs/heads/wt-topic checked out at" actual && 475 + test_grep "% Ref refs/heads/topic2 checked out at" actual 476 + ' 477 + 459 478 test_done