Skip to content

Commit 83ebc65

Browse files
committed
Merge branch 'barry-scott-master'
2 parents a4ad7ce + df95898 commit 83ebc65

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

git/cmd.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ class Git(LazyMixin):
246246
# Enables debugging of GitPython's git commands
247247
GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False)
248248

249+
# value of Windows process creation flag taken from MSDN
250+
CREATE_NO_WINDOW = 0x08000000
251+
249252
# Provide the full path to the git executable. Otherwise it assumes git is in the path
250253
_git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE"
251254
GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name)
@@ -608,6 +611,7 @@ def execute(self, command,
608611
cmd_not_found_exception = OSError
609612
# end handle
610613

614+
creationflags = self.CREATE_NO_WINDOW if sys.platform == 'win32' else 0
611615
try:
612616
proc = Popen(command,
613617
env=env,
@@ -619,6 +623,7 @@ def execute(self, command,
619623
shell=self.USE_SHELL,
620624
close_fds=(os.name == 'posix'), # unsupported on windows
621625
universal_newlines=universal_newlines,
626+
creationflags=creationflags,
622627
**subprocess_kwargs
623628
)
624629
except cmd_not_found_exception as err:
@@ -629,7 +634,7 @@ def execute(self, command,
629634

630635
def _kill_process(pid):
631636
""" Callback method to kill a process. """
632-
p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE)
637+
p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags=creationflags)
633638
child_pids = []
634639
for line in p.stdout:
635640
if len(line.split()) > 0:

git/refs/log.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def from_line(cls, line):
114114
newhexsha = info[41:81]
115115
for hexsha in (oldhexsha, newhexsha):
116116
if not cls._re_hexsha_only.match(hexsha):
117-
raise ValueError("Invalid hexsha: %s" % hexsha)
117+
raise ValueError("Invalid hexsha: %r" % (hexsha,))
118118
# END if hexsha re doesn't match
119119
# END for each hexsha
120120

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

284285
lf = LockFile(filepath)

git/test/test_repo.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -775,12 +775,23 @@ def test_empty_repo(self, rw_dir):
775775
new_file_path = os.path.join(rw_dir, "new_file.ext")
776776
touch(new_file_path)
777777
r.index.add([new_file_path])
778-
r.index.commit("initial commit")
778+
r.index.commit("initial commit\nBAD MESSAGE 1\n")
779779

780780
# Now a branch should be creatable
781781
nb = r.create_head('foo')
782782
assert nb.is_valid()
783783

784+
with open(new_file_path, 'w') as f:
785+
f.write('Line 1\n')
786+
787+
r.index.add([new_file_path])
788+
r.index.commit("add line 1\nBAD MESSAGE 2\n")
789+
790+
with open('%s/.git/logs/refs/heads/master' % (rw_dir,), 'r') as f:
791+
contents = f.read()
792+
793+
assert 'BAD MESSAGE' not in contents, 'log is corrupt'
794+
784795
def test_merge_base(self):
785796
repo = self.rorepo
786797
c1 = 'f6aa8d1'

0 commit comments

Comments
 (0)