Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo set-default: support bare git repos #6880

Merged
merged 1 commit into from Jan 19, 2023
Merged

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
@cliAutomation cliAutomation added this to Needs review 🤔 in The GitHub CLI Jan 18, 2023
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.

The GitHub CLI automation moved this from Needs review 🤔 to Needs to be merged 🎉 Jan 18, 2023
@mislav mislav merged commit 06ae07f into trunk Jan 19, 2023
The GitHub CLI automation moved this from Needs to be merged 🎉 to Pending Release 🥚 Jan 19, 2023
@mislav mislav deleted the setdefault-bare-repo branch January 19, 2023 15:25
@Wesfluegel762

This comment was marked as spam.

@github-actions github-actions bot moved this from Pending Release 🥚 to Done 💤 in The GitHub CLI Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
The GitHub CLI
  
Done 💤
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