Skip to content

Handle CRLF line endings when parsing porcelain worktree and remote lists #2

Description

@SuparvaCode

Hi Carl!

I noticed that in src/git.ts, gitMainWorktree, parseWorktreeList, and listRemotes split git output using \n. On environments where Git outputs CRLF line endings (or when core.autocrlf is enabled), trailing \r characters stay attached to worktree paths, branch names, and remote names.

Because of this:

  • staleWorktreeRecord fails the item.worktree === dir check because of the trailing carriage return.
  • existsAt(record.worktree) looks for a path containing \r.
  • listRemotes produces entries like \origin\r, which breaks
    efs/remotes//\ lookups.

Splitting by /\r?\n/ and trimming the parsed values resolves this cleanly. I'll open a pull request with the fix and test cases.


[Deutsche Übersetzung / German translation]
(Hallo Carl! Mir ist aufgefallen, dass in src/git.ts bei gitMainWorktree, parseWorktreeList und listRemotes die Git-Ausgabe mit \n getrennt wird. Auf Systemen, bei denen Git CRLF-Zeilenenden ausgibt, bleibt ein anhängendes \r an Worktree-Pfaden, Branch-Namen und Remote-Namen hängen. Dadurch schlagen Pfadvergleiche und Remote-Lookups fehl. Durch das Aufteilen nach /\r?\n/ und das Trimmen der Werte wird das Problem behoben. Ich reiche dazu gleich einen passenden Pull Request mit Tests ein.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions