Skip to content

.git as a regular file (worktrees, submodules) is rewritten and corrupted #19

@dolph

Description

@dolph

Summary

The skip list checks the directory base name .git, but only when entry.IsDir() is true:

if entry.IsDir() {
    if _, skip := skipDirs[name]; skip {
        return
    }
    fr.WalkDir(child)
} else if mode.IsRegular() {
    fr.rewriteContents(child, entry)
}

Git submodules and git worktree checkouts use a .git file (not directory) containing gitdir: <path>. find-replace will happily rewrite that file, breaking the worktree linkage.

Impact (Reliability: Low)

  • Find/replace runs in a worktree silently corrupt the .git linkage file.
  • The user has to manually restore it after the fact.

Suggested Fix

Skip any entry whose base name is .git, regardless of whether it's a file or a directory. Same for any other entries we choose to skip.

Files

  • find_replace.go:84-94 (handleEntry)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions