diff options
author | David Trowbridge <trowbrds@gmail.com> | 2009-10-05 01:12:15 -0700 |
---|---|---|
committer | David Trowbridge <trowbrds@gmail.com> | 2009-10-05 01:12:15 -0700 |
commit | 0d6c35a85b49a01663da48a2e9d54345dc684fbe (patch) | |
tree | d78c771bb3c4e78977b5b967fa6f5d3d61d2a30b | |
parent | 3b21dced3ab65b8fd309b5e51cd0c79ce32a57b5 (diff) |
Don't produce broken diff files with files that don't end in a newline.
Some people have source files that don't end in a newline. In this case, it's
possible for us to create a diff file where the end of one file is joined on the
same line as the header for the next file. This change adds an extra check to
_do_diff to make sure that we don't make broken diffs when people have broken
files.
Fixes bug 1340.
-rwxr-xr-x | rbtools/postreview.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/rbtools/postreview.py b/rbtools/postreview.py index fd98e7e..76c6be5 100755 --- a/rbtools/postreview.py +++ b/rbtools/postreview.py @@ -1756,6 +1756,11 @@ class PerforceClient(SCMClient): dl[0] = "--- %s\t%s#%s\n" % (local_path, depot_path, base_revision) dl[1] = "+++ %s\t%s\n" % (local_path, timestamp) + # Not everybody has files that end in a newline (ugh). This ensures + # that the resulting diff file isn't broken. + if dl[-1][-1] != '\n': + dl.append('\n') + return dl def _write_file(self, depot_path, tmpfile): |