Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit624eb28

Browse files
apatardByron
authored andcommitted
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 ambiguitySigned-off-by: Arnaud Patard <apatard@hupstream.com>
1 parent135e775 commit624eb28

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎git/repo/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False,
639639
ifnotsubmodules:
640640
default_args.append('--ignore-submodules')
641641
ifpath:
642-
default_args.append(path)
642+
default_args.extend(["--",path])
643643
ifindex:
644644
# diff index against HEAD
645645
ifosp.isfile(self.index.path)and \

‎test/test_repo.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,20 @@ def test_is_dirty(self):
357357
assertself.rorepo.is_dirty()isFalse
358358
self.rorepo._bare=orig_val
359359

360+
deftest_is_dirty_pathspec(self):
361+
self.rorepo._bare=False
362+
forindexin (0,1):
363+
forworking_treein (0,1):
364+
foruntracked_filesin (0,1):
365+
assertself.rorepo.is_dirty(index,working_tree,untracked_files,path=':!foo')in (True,False)
366+
# END untracked files
367+
# END working tree
368+
# END index
369+
orig_val=self.rorepo._bare
370+
self.rorepo._bare=True
371+
assertself.rorepo.is_dirty()isFalse
372+
self.rorepo._bare=orig_val
373+
360374
@with_rw_repo('HEAD')
361375
deftest_is_dirty_with_path(self,rwrepo):
362376
assertrwrepo.is_dirty(path="git")isFalse

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp