From 8c0d2f64a733c61b7ba0c736686b6a9354a5b9df Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Fri, 10 Feb 2012 13:45:09 -0500 Subject: Don't strip leading space from the commit body If we strip leading space from the body, we'll unindent the first line of the body, which could break aligment. Based on a patch by Stef Walter --- git-bz | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/git-bz b/git-bz index 462df46..7d8d804 100755 --- a/git-bz +++ b/git-bz @@ -129,6 +129,7 @@ def git_run(command, *args, **kwargs): quiet = False input = None return_stderr = False + strip = True for (k,v) in kwargs.iteritems(): if k == '_quiet': quiet = True @@ -136,6 +137,8 @@ def git_run(command, *args, **kwargs): interactive = True elif k == '_return_stderr': return_stderr = True + elif k == '_strip': + strip = v elif k == '_input': input = v elif v is True: @@ -163,10 +166,15 @@ def git_run(command, *args, **kwargs): if interactive: return None - elif return_stderr: - return output.strip(), error.strip() else: - return output.strip() + if strip: + output = output.strip() + error = error.strip() + + if return_stderr: + return output, error + else: + return output # Wrapper to allow us to do git.(...) instead of git_run() class Git: @@ -228,7 +236,10 @@ def get_patch(commit): return git.format_patch(commit.id + "^.." + commit.id, stdout=True, M=True) def get_body(commit): - return git.log(commit.id + "^.." + commit.id, pretty="format:%b") + body = git.log(commit.id + "^.." + commit.id, pretty="format:%b", _strip=False) + # Preserve leading space, which tends to be indents, but strip off + # the trailing newline and any other insignificant space at the end. + return body.rstrip() def commit_is_merge(commit): contents = git.cat_file("commit", commit.id) -- cgit v1.2.3