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

Commitbdc38b8

Browse files
committed
Always add '--' to git reset
If a git repo has the misfortune to have a file with the name "HEAD"at the root level of the repo, git will return an error because itis unsure whether the file or ref is meant: File "/usr/local/lib/python2.7/dist-packages/git/refs/head.py", line 81, in reset self.repo.git.reset(mode, commit, add_arg, paths, **kwargs) File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 440, in <lambda> return lambda *args, **kwargs: self._call_process(name, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 834, in _call_process return self.execute(make_call(), **_kwargs) File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 627, in execute raise GitCommandError(command, status, stderr_value) GitCommandError: 'git reset --hard HEAD' returned with exit code 128 stderr: 'fatal: ambiguous argument 'HEAD': both revision and filename Use '--' to separate filenames from revisions'Implement its suggested fix by always passing '--' as an argument to"git reset". It is fine to pass it with no file specifiers afterwords.In that case, git knows that "HEAD" is always meant as the ref.
1 parent58c78e6 commitbdc38b8

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

‎git/refs/head.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def reset(self, commit='HEAD', index=True, working_tree=False,
5555
5656
:return: self"""
5757
mode="--soft"
58-
add_arg=None
5958
ifindex:
6059
mode="--mixed"
6160

@@ -73,12 +72,8 @@ def reset(self, commit='HEAD', index=True, working_tree=False,
7372

7473
# END working tree handling
7574

76-
ifpaths:
77-
add_arg="--"
78-
# END nicely separate paths from rest
79-
8075
try:
81-
self.repo.git.reset(mode,commit,add_arg,paths,**kwargs)
76+
self.repo.git.reset(mode,commit,'--',paths,**kwargs)
8277
exceptGitCommandErrorase:
8378
# git nowadays may use 1 as status to indicate there are still unstaged
8479
# modifications after the reset

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp