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_DIR is not respected #58

Closed
kwbr opened this issue Nov 23, 2016 · 5 comments
Closed

GIT_DIR is not respected #58

kwbr opened this issue Nov 23, 2016 · 5 comments

Comments

@kwbr
Copy link

kwbr commented Nov 23, 2016

The way git-up tries to get the path to the repository is not working when the GIT_WORK_TREE and GIT_DIR are different.

get_git_dir() tries to get the repository with

return execute(['git', 'rev-parse', '--show-toplevel'])

As far as I understand --git-dir should be used.

http://stackoverflow.com/a/21085415

@astitcher
Copy link

I'm assuming this issue is raised because git up doesn't work correctly if you are working in a work tree created by git worktree ....

In this case I'm not sure if the correct way to get the repository is --git-dir or --git-common-dir.

From a little experimentation --git-dir gives a location deep inside the repository whereas --git-common-dir gives the actual repository root.

@kwbr
Copy link
Author

kwbr commented Nov 29, 2016

You are correct. I use vcsh (https://github.com/RichiH/vcsh) which separates the worktree from the git-dir. After reading the documentation --git-common-dir seem to be the correct way

@msiemens
Copy link
Owner

Thanks for the bug report and the details everyone! I've implemented a fix, but it seems like the git version on Travis doesn't support git's worktree. @kwbr Could you install the latest dev version (should work using pip install https://github.com/msiemens/PyGitUp) and report if it's actually fixed?

@kwbr
Copy link
Author

kwbr commented Nov 30, 2016

Seems to work now. 👍

Installed it with pip install git+https://github.com/msiemens/PyGitUp.

@msiemens
Copy link
Owner

Awesome! Version 1.4.4 has been released now :)

msiemens added a commit that referenced this issue Dec 9, 2016
Should fix #59. The bugfix to #58 was faulty when PyGitUp was run from
a subfolder as `git rev-parse --git-common-dir` is not equivalent to
`git rev-parse --show-toplevel` when run in a subfolder as it returns
a relative path in cases like this. Now `--git-common-dir` is used when
executed in a worktree, otherwise `--show-toplevel` is used.
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

No branches or pull requests

3 participants