diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2012-10-21 08:13:14 -0700 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2012-10-21 08:13:14 -0700 |
commit | 0e90a8f61cf8c8eb346ad6dc0460cc00417733c7 (patch) | |
tree | 0bb12d8bd5e7c7e42ca1dfb0142db97677f2d90d /git/test/test_cmd.py | |
parent | 011d89d3187f4436383f7e7159c105b96a83bb80 (diff) | |
parent | a300e32dc8d965c8552a0cfdfb5f8734347b582e (diff) | |
download | gitpython-0e90a8f61cf8c8eb346ad6dc0460cc00417733c7.tar.gz |
Merge pull request #79 from znerol/feature/master/cmd-output-strip
Add an output_strip kwarg to Git.execute
Diffstat (limited to 'git/test/test_cmd.py')
-rw-r--r-- | git/test/test_cmd.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/git/test/test_cmd.py b/git/test/test_cmd.py index 2d38e0a8..b5732339 100644 --- a/git/test/test_cmd.py +++ b/git/test/test_cmd.py @@ -108,3 +108,25 @@ class TestGit(TestBase): finally: type(self.git).GIT_PYTHON_GIT_EXECUTABLE = prev_cmd #END undo adjustment + + def test_output_strip(self): + import subprocess as sp + hexsha = "b2339455342180c7cc1e9bba3e9f181f7baa5167" + + # Verify that a trailing newline is stripped from the output of a git + # command. + content = self.git.cat_file('blob', hexsha) + g = self.git.hash_object(istream=sp.PIPE, as_process=True, stdin=True) + g.stdin.write(content) + g.stdin.close() + newsha = g.stdout.readline().strip() + self.assertNotEquals(newsha, hexsha) + + # Verify that output of a git command which ends with an empty + # line is not modified when the output_strip flag is cleared. + content = self.git.cat_file('blob', hexsha, output_strip=False) + g = self.git.hash_object(istream=sp.PIPE, as_process=True, stdin=True) + g.stdin.write(content) + g.stdin.close() + newsha = g.stdout.readline().strip() + self.assertEquals(newsha, hexsha) |