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

git rev-parse --is-inside-work-tree does not handle bare Git repositories correctly #1054

Open
ido123net opened this issue Jun 30, 2023 · 0 comments

Comments

@ido123net
Copy link

The current implementation of the prompt_git() function does not handle bare Git repositories correctly. When the function checks if the current directory is inside a Git repository using the command git rev-parse --is-inside-work-tree, it expects a return code of 0 and a corresponding output of "true" to indicate that the current directory is in a Git repository.

However, in the case of a bare Git repository, the command git rev-parse --is-inside-work-tree returns a return code of 0, but the output is "false". This leads to incorrect behavior in the function, as it does not properly handle bare repositories and does not return as expected.

Steps to Reproduce:

  1. Create a bare Git repository using git init --bare.
  2. Execute the prompt_git() function within the bare repository.

Actual Behavior:

The prompt_git() function does not handle bare Git repositories correctly.
leading to fatal errors after. from git diff-files --quiet --ignore-submodules -- and git ls-files --others --exclude-standard.

Proposed Solution:

  1. Check the repository type using git rev-parse --is-bare-repository command or another suitable method, and return early if it detects a bare repository.
  2. Check if the output of git rev-parse --is-inside-work-tree is false.

Additional Information:

Operating System: Linux
Git version: 2.37.3
Shell environment: Bash

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 a pull request may close this issue.

1 participant