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

Commit25a2ebf

Browse files
committed
Win,#519: Removegit.cmd failback - no longer exists.
+ Simplify call_process, no win-code case, no `make_call()` nested func.+ Del needless WinError try..catch, in `_call_process()` alreadyconverted as GitCommandNotFound by `execute()`.+ pyism: kw-loop-->comprehension, facilitate debug-stepping
1 parent1124e19 commit25a2ebf

File tree

1 file changed

+15
-54
lines changed

1 file changed

+15
-54
lines changed

‎git/cmd.py

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
)
4646
importio
4747

48-
execute_kwargs= ('istream','with_keep_cwd','with_extended_output',
49-
'with_exceptions','as_process','stdout_as_string',
50-
'output_stream','with_stdout','kill_after_timeout',
51-
'universal_newlines')
48+
execute_kwargs=set(('istream','with_keep_cwd','with_extended_output',
49+
'with_exceptions','as_process','stdout_as_string',
50+
'output_stream','with_stdout','kill_after_timeout',
51+
'universal_newlines'))
5252

5353
log=logging.getLogger('git.cmd')
5454
log.addHandler(logging.NullHandler())
@@ -275,7 +275,6 @@ def __setstate__(self, d):
275275
max_chunk_size=io.DEFAULT_BUFFER_SIZE
276276

277277
git_exec_name="git"# default that should work on linux and windows
278-
git_exec_name_win="git.cmd"# alternate command name, windows only
279278

280279
# Enables debugging of GitPython's git commands
281280
GIT_PYTHON_TRACE=os.environ.get("GIT_PYTHON_TRACE",False)
@@ -778,10 +777,7 @@ def update_environment(self, **kwargs):
778777
forkey,valueinkwargs.items():
779778
# set value if it is None
780779
ifvalueisnotNone:
781-
ifkeyinself._environment:
782-
old_env[key]=self._environment[key]
783-
else:
784-
old_env[key]=None
780+
old_env[key]=self._environment.get(key)
785781
self._environment[key]=value
786782
# remove key from environment if its value is None
787783
elifkeyinself._environment:
@@ -897,12 +893,8 @@ def _call_process(self, method, *args, **kwargs):
897893
:return: Same as ``execute``"""
898894
# Handle optional arguments prior to calling transform_kwargs
899895
# otherwise these'll end up in args, which is bad.
900-
_kwargs=dict()
901-
forkwarginexecute_kwargs:
902-
try:
903-
_kwargs[kwarg]=kwargs.pop(kwarg)
904-
exceptKeyError:
905-
pass
896+
_kwargs= {k:vfork,vinkwargs.items()ifkinexecute_kwargs}
897+
kwargs= {k:vfork,vinkwargs.items()ifknotinexecute_kwargs}
906898

907899
insert_after_this_arg=kwargs.pop('insert_kwargs_after',None)
908900

@@ -922,48 +914,17 @@ def _call_process(self, method, *args, **kwargs):
922914
args=ext_args[:index+1]+opt_args+ext_args[index+1:]
923915
# end handle kwargs
924916

925-
defmake_call():
926-
call= [self.GIT_PYTHON_GIT_EXECUTABLE]
917+
call= [self.GIT_PYTHON_GIT_EXECUTABLE]
927918

928-
# add the git options, the reset to empty
929-
# to avoid side_effects
930-
call.extend(self._git_options)
931-
self._git_options= ()
932-
933-
call.extend([dashify(method)])
934-
call.extend(args)
935-
returncall
936-
# END utility to recreate call after changes
919+
# add the git options, the reset to empty
920+
# to avoid side_effects
921+
call.extend(self._git_options)
922+
self._git_options= ()
937923

938-
ifis_win():
939-
try:
940-
try:
941-
returnself.execute(make_call(),**_kwargs)
942-
exceptWindowsError:
943-
# did we switch to git.cmd already, or was it changed from default ? permanently fail
944-
ifself.GIT_PYTHON_GIT_EXECUTABLE!=self.git_exec_name:
945-
raise
946-
# END handle overridden variable
947-
type(self).GIT_PYTHON_GIT_EXECUTABLE=self.git_exec_name_win
924+
call.append(dashify(method))
925+
call.extend(args)
948926

949-
try:
950-
returnself.execute(make_call(),**_kwargs)
951-
finally:
952-
importwarnings
953-
msg="WARNING: Automatically switched to use git.cmd as git executable"
954-
msg+=", which reduces performance by ~70%."
955-
msg+="It is recommended to put git.exe into the PATH or to "
956-
msg+="set the %s "%self._git_exec_env_var
957-
msg+="environment variable to the executable's location"
958-
warnings.warn(msg)
959-
# END print of warning
960-
# END catch first failure
961-
exceptWindowsError:
962-
raiseWindowsError("The system cannot find or execute the file at %r"%self.GIT_PYTHON_GIT_EXECUTABLE)
963-
# END provide better error message
964-
else:
965-
returnself.execute(make_call(),**_kwargs)
966-
# END handle windows default installation
927+
returnself.execute(call,**_kwargs)
967928

968929
def_parse_object_header(self,header_line):
969930
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp