{"thread":{"id":"66107","subject":"git rebase writes worktree \"Ref ... checked out at ...\" todo comments with a hardcoded '#', breaking parsing when core.commentChar is not '#'.","startedAt":"2026-08-03T07:53:32Z","lastAt":"2026-08-03T07:53:32Z","messageCount":1,"participants":["Markus Geiger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"549473","messageId":"20260803074639.0B7DB5946343@dd18010.kasserver.com","threadId":"66107","inReplyTo":null,"subject":"git rebase writes worktree \"Ref ... checked out at ...\" todo comments with a hardcoded '#', breaking parsing when core.commentChar is not '#'.","fromName":"Markus Geiger","fromEmail":"mgeiger@evolution515.net","sentAt":"2026-08-03T07:46:39Z","receivedAt":"2026-08-03T07:53:32Z","isPatch":false,"body":"When core.commentChar is set to a non-'#' value (e.g. ';') AND a branch that\nfalls within the rebased commit range is checked out in another worktree,\n`git rebase` generates a todo list in which the informational\n\"Ref ... checked out at ...\" lines are prefixed with a hardcoded '#' instead of\nthe configured comment character. Git's own sequencer then re-reads that todo,\ndoes not recognize '#' as a comment, and aborts with `error: invalid command '#'`.\n\nMinimal, self-contained reproduction:\n\n    T=$(mktemp -d); export HOME=\"$T\"\n    git config --global user.email t@t.t\n    git config --global user.name t\n    git config --global init.defaultBranch main\n\n    cd \"$T\"; git init -q super && cd super\n    echo a > f && git add f && git commit -qm base   # upstream (ancestor)\n    echo b >> f && git commit -qam A\n    echo c >> f && git commit -qam B\n    git branch feat\n    git checkout -q feat                             # primary worktree on 'feat'\n    git worktree add -q ../mainwt main               # 'main' (in range) checked out elsewhere\n\n    git config core.commentChar ';'                  # <-- the trigger\n    git rebase main~2                                # replay A, B onto 'base'\n\nWhat did you expect to happen? (Expected behavior)\n\nRebase succeeds, exactly as it does with the default core.commentChar='#'.\nThe \"Ref ... checked out at ...\" advisory lines are informational comments and\nshould be ignored by the sequencer.\n\nWhat happened instead? (Actual behavior)\n\n    error: invalid command '#'\n    error: invalid line 3: # Ref refs/heads/main checked out at '.../mainwt'\n    error: invalid command '#'\n    error: invalid line 5: # Ref refs/heads/feat checked out at '.../super'\n    You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'.\n\nExit code 1, with a half-initialized rebase left in progress.\n\nWhat's different between what you expected and what actually happened?\n\nThe generated rebase-merge/git-rebase-todo mixes two comment characters, which\nshows one code path respects core.commentChar while another hardcodes '#':\n\n    pick 2fbb49f A\n    pick 15691cb B\n    # Ref refs/heads/main checked out at '.../mainwt'    <-- hardcoded '#'  (BUG)\n    # Ref refs/heads/feat checked out at '.../super'     <-- hardcoded '#'  (BUG)\n    ; Rebase a0b3bf8..15691cb onto a0b3bf8 (2 commands)  <-- correct ';'   (respects config)\n\nOn re-read, todo_list_parse_insn_buffer() treats any line not starting with the\nconfigured comment char as an instruction, so '#' is parsed as a command.\n\nAnything else you want to add:\n\nRoot cause: the sequencer code (sequencer.c) that appends the\n\"Ref <ref> checked out at <path>\" advisory lines when a ref in the rebased range\nis checked out in another worktree prepends a literal '#' rather than the\nresolved comment_line_char. Suggested fix: use comment_line_char for those lines,\nas the surrounding template lines already do.\n\nTrigger conditions (both required):\n  1. core.commentChar set to a value other than '#' (also affects 'auto' when it\n     resolves to a non-'#' character).\n  2. A branch within the rebased range is checked out in another worktree.\n\nImpact: `git rebase` is unusable from the CLI for users who set a custom\ncore.commentChar (common for teams that begin commit-message lines with '#123'\nissue refs) as soon as they use worktrees.\n\nWorkarounds:\n  - git -c core.commentChar='#' rebase ...\n  - set core.commentChar='#' globally\n  - git rebase --edit-todo and delete the offending '#' lines by hand\n\nReproduced on git version 2.43.0 (details below). Not yet checked against master.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.43.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 7.0.0-28-generic #28~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul  1 15:50:57 UTC 2 x86_64\ncompiler info: gnuc: 13.3\nlibc info: glibc: 2.39\n$SHELL (typically, interactive shell): /usr/bin/zsh\n\n\n[Enabled Hooks]\n"}]}