Fix IndexFile.from_tree on Windows by EliahKagan · Pull Request #1751 · gitpython-developers/GitPython
from git import ( BlobFilter, Diff, Git, IndexFile, Object, Repo, BlobFilter, UnmergedEntriesError, Tree, Object, Diff, GitCommandError, ) from git.exc import ( CheckoutError, GitCommandError, HookExecutionError, InvalidGitRepositoryError, UnmergedEntriesError, ) from git.exc import HookExecutionError, InvalidGitRepositoryError from git.index.fun import hook_path from git.index.typ import BaseIndexEntry, IndexEntry from git.objects import Blob
@pytest.mark.xfail( os.name == "nt", reason=( "IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n" "'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'." ), raises=GitCommandError, ) @with_rw_repo("0.1.6") def test_index_file_from_tree(self, rw_repo): common_ancestor_sha = "5117c9c8a4d3af19a9958677e45cda9269de1541"
@pytest.mark.xfail( os.name == "nt", reason=( "IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n" "'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'." ), raises=GitCommandError, ) @with_rw_repo("0.1.6") def test_index_merge_tree(self, rw_repo): # A bit out of place, but we need a different repo for this:
@pytest.mark.xfail( os.name == "nt", reason=( "IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n" "'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'." ), raises=GitCommandError, ) @with_rw_repo("0.1.6") def test_index_file_diffing(self, rw_repo): # Default Index instance points to our index.
@pytest.mark.xfail( os.name == "nt", reason=( "IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n" "'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'." ), raises=GitCommandError, os.name == "nt" and Git().config("core.symlinks") == "true", reason="Assumes symlinks are not created on Windows and opens a symlink to a nonexistent target.", raises=FileNotFoundError, ) @with_rw_repo("0.1.6") def test_index_mutation(self, rw_repo):
# Add fake symlink and assure it checks-our as symlink. # Add fake symlink and assure it checks out as a symlink. fake_symlink_relapath = "my_fake_symlink" link_target = "/etc/that" fake_symlink_path = self._make_file(fake_symlink_relapath, link_target, rw_repo)
# On Windows, we will never get symlinks. # On Windows, we currently assume we will never get symlinks. if os.name == "nt": # Symlinks should contain the link as text (which is what a # symlink actually is).
@pytest.mark.xfail( os.name == "nt", reason=( "IndexFile.from_tree is broken on Windows (related to NamedTemporaryFile), see #1630.\n" "'git read-tree --index-output=...' fails with 'fatal: unable to write new index file'." ), raises=GitCommandError, ) @with_rw_repo("HEAD") def test_compare_write_tree(self, rw_repo): """Test writing all trees, comparing them for equality."""