summaryrefslogtreecommitdiff
path: root/test/test_repo.py
diff options
context:
space:
mode:
authorArnaud Patard <apatard@hupstream.com>2020-09-28 12:24:33 +0000
committerSebastian Thiel <sebastian.thiel@icloud.com>2020-09-28 20:39:17 +0800
commit624eb284e0e6edc4aabf0afbdc1438e32d13f4c9 (patch)
tree13a8ccb9c89bf5a1e308da4e0521974eedb1076f /test/test_repo.py
parent135e7750f6b70702de6ce55633f2e508188a5c05 (diff)
downloadgitpython-624eb284e0e6edc4aabf0afbdc1438e32d13f4c9.tar.gz
git/repo/base.py: is_dirty(): Fix pathspec handling
It's possible to specify a pathspec (eg :!foo) to git diff/status/... but it currently fails with: git.exc.GitCommandError: Cmd('/usr/bin/git') failed due to: exit code(128) cmdline: /usr/bin/git diff --abbrev=40 --full-index --raw :!foo stderr: 'fatal: ambiguous argument ':!foo': unknown revision or path not in the working tree. Add missing '--' to the arguments to fix this ambiguity Signed-off-by: Arnaud Patard <apatard@hupstream.com>
Diffstat (limited to 'test/test_repo.py')
-rw-r--r--test/test_repo.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/test_repo.py b/test/test_repo.py
index 0809175f..d5ea8664 100644
--- a/test/test_repo.py
+++ b/test/test_repo.py
@@ -357,6 +357,20 @@ class TestRepo(TestBase):
assert self.rorepo.is_dirty() is False
self.rorepo._bare = orig_val
+ def test_is_dirty_pathspec(self):
+ self.rorepo._bare = False
+ for index in (0, 1):
+ for working_tree in (0, 1):
+ for untracked_files in (0, 1):
+ assert self.rorepo.is_dirty(index, working_tree, untracked_files, path=':!foo') in (True, False)
+ # END untracked files
+ # END working tree
+ # END index
+ orig_val = self.rorepo._bare
+ self.rorepo._bare = True
+ assert self.rorepo.is_dirty() is False
+ self.rorepo._bare = orig_val
+
@with_rw_repo('HEAD')
def test_is_dirty_with_path(self, rwrepo):
assert rwrepo.is_dirty(path="git") is False