Skip to content

Conversation

mislav
Copy link
Contributor

@mislav mislav commented Jan 18, 2023

The command was using this to check for git repo context:

git rev-parse --is-inside-work-tree

With this change, this is used instead:

git rev-parse --git-dir

The latter approach works in the context of a bare git repository, which does not have a worktree, or in cases when the current directory is not a git repo but the GIT_DIR environment variable points to a git repository.

Fixes #6860

The command was using this to check for git repo context:

    git rev-parse --is-inside-work-tree

With this change, this is used instead:

    git rev-parse --git-dir

The latter approach works in the context of a bare git repository, which does not have a worktree.
@mislav mislav requested a review from a team as a code owner January 18, 2023 19:48
@mislav mislav requested review from vilmibm and removed request for a team January 18, 2023 19:48
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix. I like the errWithExitCode addition, will make testing git errors much easier in the future.

@mislav mislav merged commit 06ae07f into trunk Jan 19, 2023
@mislav mislav deleted the setdefault-bare-repo branch January 19, 2023 15:25
@Wesfluegel762

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"gh repo set-default" in a bare repo "must be run from inside a git repository"?
3 participants