Skip to content

Fix broken worktree path with submodules on Windows #276

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 1 commit into from
Apr 7, 2015
Merged

Fix broken worktree path with submodules on Windows #276

merged 1 commit into from
Apr 7, 2015

Conversation

msiemens
Copy link
Contributor

@msiemens msiemens commented Apr 7, 2015

On Windows, repo.create_submodule(...) failed because git didn't recognize the worktree path set in .git/modules/sub/config (fatal: bad config file line 6 in ./config). This resulted in the following traceback:

Traceback (most recent call last):
  File "F:\Dokumente\Coding\python\PyGitUp\tests\test_submodules.py", line 42, in setup
    repo.create_submodule('sub', 'sub', master_path)
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\repo\base.py", line 295, in create_submodule
    return Submodule.add(self, *args, **kwargs)
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\objects\submodule\base.py", line 417, in add
    sm.binsha = mrepo.head.commit.binsha
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\refs\symbolic.py", line 182, in _get_commit
    obj = self._get_object()
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\refs\symbolic.py", line 175, in _get_object
    return Object.new_from_sha(self.repo, hex_to_bin(self.dereference_recursive(self.repo, self.path)))
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\objects\base.py", line 65, in new_from_sha
    oinfo = repo.odb.info(sha1)
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\db.py", line 40, in info
    hexsha, typename, size = self._git.get_object_header(bin_to_hex(sha))
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\cmd.py", line 866, in get_object_header
    return self.__get_object_header(cmd, ref)
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\cmd.py", line 855, in __get_object_header
    return self._parse_object_header(cmd.stdout.readline())
  File "F:\Dokumente\Coding\python\.virtualenv\PyGitUp\lib\site-packages\git\cmd.py", line 817, in _parse_object_header
    raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip()))
ValueError: SHA could not be resolved, git returned: ''

This PR makes _write_git_file_and_module_config convert the worktree path to the linux format (forward slashes) which git recognizes.

@msiemens msiemens changed the title Fix problem with submodules on Windows Fix broken worktree path with submodules on Windows Apr 7, 2015
@Byron Byron added this to the v0.3.7 - Fixes milestone Apr 7, 2015
@Byron
Copy link
Member

Byron commented Apr 7, 2015

Thank you.
Would you mind fixing this issue reported by flake8 ?

$ flake8
./git/objects/submodule/base.py:296:121: E501 line too long (123 > 120 characters)

Then I'd be glad to merge and release it this week. Thanks again.

On Windows, `repo.create_submodule(...)` failed because git didn't recognize
the worktree path set in `.git/modules/sub/config` (`fatal: bad config file
line 6 in ./config`). This commit makes `_write_git_file_and_module_config`
convert the worktree path to the linux format (forward slashes) which git
recognizes.
@msiemens
Copy link
Contributor Author

msiemens commented Apr 7, 2015

Sure! I've updated the PR now. The Travis tests failed, but it doesn't seem to be related to this change.

Byron added a commit that referenced this pull request Apr 7, 2015
Fix broken worktree path with submodules on Windows
@Byron Byron merged commit c27cd90 into gitpython-developers:master Apr 7, 2015
@msiemens msiemens deleted the patch-1 branch April 7, 2015 13:47
@Byron
Copy link
Member

Byron commented Apr 7, 2015

Indeed, the other travis issue will be on my plate.
Thank you !

@msiemens
Copy link
Contributor Author

msiemens commented Apr 7, 2015

That was quick! Thanks, @Byron!

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.

2 participants