Skip to content

pgxntool-sync.sh / update-setup-files.sh fail inside a git worktree #38

Description

@jnasbyupgrade

update-setup-files.sh (and pgxntool-sync.sh) guard on the project root being a git repo with:

[[ -d ".git" ]] || die 1 "Not in a git repository."

In a git worktree (git worktree add), .git is a file (a gitdir: pointer), not a directory, so the check fails and the script aborts with "Not in a git repository." — even though it's a perfectly valid working tree. All the actual git operations the scripts use (git show, git merge-file, git add, etc.) work fine in a worktree; only this guard is too strict.

Repro

git worktree add ../wt-test HEAD
cd ../wt-test
pgxntool/update-setup-files.sh <old-commit>   # -> ERROR: Not in a git repository.

Suggested fix

Detect the repo with a worktree-safe check instead of [ -d .git ], e.g.:

git rev-parse --git-dir >/dev/null 2>&1 || die 1 "Not in a git repository."

Same guard appears in setup.sh ([ -d .git ] || git init), which would also misbehave in a worktree.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions