3198: Downloaded patch files contain hash values that don't match content

cea***@gmai***** (Google Code) (Is this you? Claim this profile.)
2916
What version are you running?
Review Board 1.7.13, RBTools 0.5.2

What's the URL of the page containing the problem?
The issue exists in downloaded patch files.

What steps will reproduce the problem?
1. In a Git repository, make a change to a file using CRLF line-endings.
2. Commit the change to your local repository.
3. Use post-review to post a review request for the change.
4. In review board, download the patch.

What is the expected output? What do you see instead?
It is expected that the hash values for changes in patch files match the hash values of the content represented. Because the line endings in the patch file are all LF line endings, the patch content hash does not match when a file is committed with CRLF line endings.

What operating system are you using? What browser?
Windows clients running Cygwin and using the Cygwin version of Git.

Please provide any additional information below.
I have written a Git commit hook to authorize push requests by verifying that the commits have been approved in Review Board. It expects to be called by the update hook as follows:

#!/bin/bash
python /usr/local/bin/verify-code-review.py $3 > ~/commit-test.txt
exit $?

I have attached the code for this, but the key problem is that the computed hashes in the code being committed, which is code applied by a developer downloading the patch from Review Board, applying it to a local Git branch and then pushing the changes to the central Git repository needs to have matching hash values for each file. This was the only way I could be sure that the patch that was approved in Review Board matches the patch being committed. So far, the only issue we have run into in the newlines not matching, unless LF newlines are used.

We have considered using Git settings to force LF newlines to be used for committed code, but there may come a time when a particular file requires CRLF line endings and then we would have a problem.
#!/usr/bin/python
import sys
import os
import subprocess
from rbtools.api.client import RBClient
revision_sha1 = sys.argv[1]
print "Verifying push for revision: ", revision_sha1
pushed_files = dict()
proc = subprocess.Popen(["git", "diff-tree", "--no-commit-id", "-r", revision_sha1], stdout=subprocess.PIPE)
for line in iter(proc.stdout.readline, ''):
    split1 = line.split('\t')
    split2 = split1[0].split(' ')
    sha1 = split2[3]
    filepath = split1[1].rstrip()
    pushed_files[filepath]=sha1
print "Theses are the files you pushed via Git."
for file in pushed_files:
    print "  ", file, "\t", pushed_files[file]
client = RBClient('http://reviewboard.internal.hostname.com/', username='admin', password='admin')
root = client.get_root()
repositories = root.get_repositories(max_results=200)
for repository in repositories:
    if repository.path == "ssh://reviewboard@scm.internal.hostname.com" + os.environ['PWD']:
        break;
# Make a request for the list of pending review 
#1 Yair

Seems the same as Ticket 2916?

david
#2 david