Skip to content

Repo: handle worktrees better #638

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

Merged
merged 4 commits into from
Jul 1, 2017
Merged

Conversation

vathpela
Copy link
Contributor

This makes Repo("foo") work when foo/.git is a file of the form created
by "git worktree add", i.e. it's a text file that says:

gitdir: /home/me/project/.git/worktrees/bar

and where /home/me/project/.git/ is the nominal gitdir, but
/home/me/project/.git/worktrees/bar has this worktree's HEAD etc and a
"gitdir" file that contains the path of foo/.git .

Signed-off-by: Peter Jones [email protected]

@codecov-io
Copy link

codecov-io commented Jun 26, 2017

Codecov Report

Merging #638 into master will increase coverage by 1.43%.
The diff coverage is 91.78%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #638      +/-   ##
=========================================
+ Coverage   92.76%   94.2%   +1.43%     
=========================================
  Files          61      61              
  Lines        9910    9968      +58     
=========================================
+ Hits         9193    9390     +197     
+ Misses        717     578     -139
Impacted Files Coverage Δ
git/refs/symbolic.py 96.19% <100%> (+0.19%) ⬆️
git/test/test_submodule.py 98.83% <100%> (ø) ⬆️
git/test/test_repo.py 97.3% <100%> (+2.52%) ⬆️
git/repo/base.py 95.82% <100%> (+0.73%) ⬆️
git/repo/fun.py 92.55% <75%> (-1.64%) ⬇️
git/test/test_fun.py 98.41% <91.66%> (-0.4%) ⬇️
git/test/test_docs.py 100% <0%> (+0.39%) ⬆️
git/cmd.py 85.54% <0%> (+0.47%) ⬆️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4bd708d...afe947b. Read the comment docs.

@vathpela
Copy link
Contributor Author

vathpela commented Jun 27, 2017

I'm really not sure what's going on in the AppVeyor test cases here. It's not obvious to me that these are related to this change set, and locally on a Linux machine all tests with tox pass except all py34 ones, in which pip fails to install the test prerequisites correctly. That's clearly just py34 not working, rather than being this patch.

The test_git_submodules_and_add_sm_with_new_commit() test is failing from what appears to be an AppVeyor bug:

534 git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
535 cmdline: git commit -m new file added
536 stderr: '
537 *** Please tell me who you are.
538
539 Run
540
541 git config --global user.email "[email protected]"
542 git config --global user.name "Your Name"
543
544 to set your account's default identity.
545 Omit --global to set the identity only in this repository.
546
547 fatal: unable to auto-detect email address (got 'appveyor@APPVYR-WIN.(none)')'

Clearly '(none)' is None being formatted as a TLD, which is not valid. (Trying to work around this in 9667b7a, not sure if it'll work.)

I have no idea test_diff_with_staged_file() failures would be caused by this, and they do seem to be present in AppVeyor runs on the PRs before this one. Staring at the code and the backtrace, my best guess is that polish_url() should be returning a backslash-version instead of slashes, and so the filesystem paths aren't working? But I don't know how that all works in cygwin/windows, and I don't have a windows machine to reproduce locally.

This makes Repo("foo") work when foo/.git is a file of the form created
by "git worktree add", i.e. it's a text file that says:

gitdir: /home/me/project/.git/worktrees/bar

and where /home/me/project/.git/ is the nominal gitdir, but
/home/me/project/.git/worktrees/bar has this worktree's HEAD etc and a
"gitdir" file that contains the path of foo/.git .

Signed-off-by: Peter Jones <[email protected]>
One of the submodule tests says:

Traceback (most recent call last):
  File "C:\projects\gitpython\git\test\lib\helper.py", line 92, in wrapper
    return func(self, path)
  File "C:\projects\gitpython\git\test\test_submodule.py", line 706, in test_git_submodules_and_add_sm_with_new_commit
    smm.git.commit(m="new file added")
  File "C:\projects\gitpython\git\cmd.py", line 425, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "C:\projects\gitpython\git\cmd.py", line 877, in _call_process
    return self.execute(call, **exec_kwargs)
  File "C:\projects\gitpython\git\cmd.py", line 688, in execute
    raise GitCommandError(command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git commit -m new file added
  stderr: '
*** Please tell me who you are.
Run
  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'appveyor@APPVYR-WIN.(none)')'

Clearly this is failing because (none) isn't a valid TLD, but I figure
I'll try to set a fake value and see if that works around it.
@Byron Byron self-requested a review July 1, 2017 11:29
Byron added 2 commits July 1, 2017 13:49
Here is the error log we see:

======================================================================
ERROR: test_git_submodules_and_add_sm_with_new_commit (git.test.test_submodule.TestSubmodule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\gitpython\git\test\lib\helper.py", line 92, in wrapper
    return func(self, path)
  File "C:\projects\gitpython\git\test\test_submodule.py", line 709, in test_git_submodules_and_add_sm_with_new_commit
    smm.git.commit(m="new file added")
  File "C:\projects\gitpython\git\cmd.py", line 425, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "C:\projects\gitpython\git\cmd.py", line 877, in _call_process
    return self.execute(call, **exec_kwargs)
  File "C:\projects\gitpython\git\cmd.py", line 688, in execute
    raise GitCommandError(command, status, stderr_value, stdout_value)
GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git commit -m new file added
  stderr: '
*** Please tell me who you are.
@Byron
Copy link
Member

Byron commented Jul 1, 2017

Hi @vathpela , thanks a lot for your contribution, and for making it such a gorgeous one!

I can feel the pain that appveyor can cause, which is why I chose to go down the easy path and try to skip the test there, just to save time to be spent more productively :). Also it looks like Appveyor was breaking for a while, as you noted, which shouldn't have happened in the first place.

Once the CI's are happy, this one will be merged.
Thanks again

@Byron Byron merged commit cf8dc25 into gitpython-developers:master Jul 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants