summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--git/cmd.py7
-rw-r--r--git/refs/log.py5
-rw-r--r--git/test/test_repo.py13
3 files changed, 21 insertions, 4 deletions
diff --git a/git/cmd.py b/git/cmd.py
index d8469565..62eef9e4 100644
--- a/git/cmd.py
+++ b/git/cmd.py
@@ -246,6 +246,9 @@ class Git(LazyMixin):
# Enables debugging of GitPython's git commands
GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False)
+ # value of Windows process creation flag taken from MSDN
+ CREATE_NO_WINDOW = 0x08000000
+
# Provide the full path to the git executable. Otherwise it assumes git is in the path
_git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE"
GIT_PYTHON_GIT_EXECUTABLE = os.environ.get(_git_exec_env_var, git_exec_name)
@@ -608,6 +611,7 @@ class Git(LazyMixin):
cmd_not_found_exception = OSError
# end handle
+ creationflags = self.CREATE_NO_WINDOW if sys.platform == 'win32' else 0
try:
proc = Popen(command,
env=env,
@@ -619,6 +623,7 @@ class Git(LazyMixin):
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:
@@ -629,7 +634,7 @@ class Git(LazyMixin):
def _kill_process(pid):
""" Callback method to kill a process. """
- p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE)
+ p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags=creationflags)
child_pids = []
for line in p.stdout:
if len(line.split()) > 0:
diff --git a/git/refs/log.py b/git/refs/log.py
index fed13608..3078355d 100644
--- a/git/refs/log.py
+++ b/git/refs/log.py
@@ -114,7 +114,7 @@ class RefLogEntry(tuple):
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
@@ -274,11 +274,12 @@ class RefLog(list, Serializable):
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)
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index 87887bad..48900c26 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -775,12 +775,23 @@ class TestRepo(TestBase):
new_file_path = os.path.join(rw_dir, "new_file.ext")
touch(new_file_path)
r.index.add([new_file_path])
- r.index.commit("initial commit")
+ r.index.commit("initial commit\nBAD MESSAGE 1\n")
# Now a branch should be creatable
nb = r.create_head('foo')
assert nb.is_valid()
+ with open(new_file_path, 'w') as f:
+ f.write('Line 1\n')
+
+ r.index.add([new_file_path])
+ r.index.commit("add line 1\nBAD MESSAGE 2\n")
+
+ with open('%s/.git/logs/refs/heads/master' % (rw_dir,), 'r') as f:
+ contents = f.read()
+
+ assert 'BAD MESSAGE' not in contents, 'log is corrupt'
+
def test_merge_base(self):
repo = self.rorepo
c1 = 'f6aa8d1'