Skip to content
15 changes: 14 additions & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,12 @@ def execute(self, command,
# end handle

try:
if sys.platform == 'win32':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally for these kinds of assignment, I believe it's easier to read by starting out like this:

creationflags = None
if sys.platform == 'win32':
    creationflags = CREATE_NO_WINDOW

CREATE_NO_WINDOW = 0x08000000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CREATE_NO_WINDOW is used twice, is there a reason it is not a constant on module or class level ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended to provide a obvious patch. You usually change my process control patches so I left that for you to decide on where you wished to define CREATE_NO_WINDOW.

creationflags = CREATE_NO_WINDOW
else:
creationflags = None

proc = Popen(command,
env=env,
cwd=cwd,
Expand All @@ -619,6 +625,7 @@ def execute(self, command,
shell=self.USE_SHELL,
close_fds=(os.name == 'posix'), # unsupported on windows
universal_newlines=universal_newlines,
creationflags=creationflags,
**subprocess_kwargs
)
except cmd_not_found_exception as err:
Expand All @@ -629,7 +636,13 @@ def execute(self, command,

def _kill_process(pid):
""" Callback method to kill a process. """
p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE)
if sys.platform == 'win32':
CREATE_NO_WINDOW = 0x08000000
creationflags = CREATE_NO_WINDOW
else:
creationflags = None

p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that using creationflags as positional argument doesn't actually end up in the correct spot. Also I thought that positional arguments after keyword args are not allowed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This concern is reflected in actual breakage as well: https://travis-ci.org/gitpython-developers/GitPython/jobs/148304657#L318

child_pids = []
for line in p.stdout:
if len(line.split()) > 0:
Expand Down
5 changes: 3 additions & 2 deletions git/refs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def from_line(cls, line):
newhexsha = info[41:81]
for hexsha in (oldhexsha, newhexsha):
if not cls._re_hexsha_only.match(hexsha):
raise ValueError("Invalid hexsha: %s" % hexsha)
raise ValueError("Invalid hexsha: %r" % (hexsha,))
# END if hexsha re doesn't match
# END for each hexsha

Expand Down Expand Up @@ -274,11 +274,12 @@ def append_entry(cls, config_reader, filepath, oldbinsha, newbinsha, message):
raise ValueError("Shas need to be given in binary format")
# END handle sha type
assure_directory_exists(filepath, is_file=True)
first_line = message.split('\n')[0]
committer = isinstance(config_reader, Actor) and config_reader or Actor.committer(config_reader)
entry = RefLogEntry((
bin_to_hex(oldbinsha).decode('ascii'),
bin_to_hex(newbinsha).decode('ascii'),
committer, (int(time.time()), time.altzone), message
committer, (int(time.time()), time.altzone), first_line
))

lf = LockFile(filepath)
Expand Down