3120: git diff not automatically detected for pre-commits

yane****@gmai***** (Google Code) (Is this you? Claim this profile.)
Dec. 17, 2013
What version are you running?

0.5.2-dev

What's the URL of the page containing the problem?

n/a

What steps will reproduce the problem?
1. Hack on a file in a git clone.
2. git diff it to make sure that there's some change in the file.
3. Try running post-review.

What is the expected output? What do you see instead?

It should go through posting the file (similar to what I'm used to with the SVN integration with the tool). Unfortunately it doesn't work because the revisions specified are wrong (please note that explicitly stating "HEAD" works):

garrett.cooper@ZL00757 ~/git/rbtools
$ git diff .
diff --git a/rbtools/clients/git.py b/rbtools/clients/git.py
index 4d7ace1..790d105 100644
--- a/rbtools/clients/git.py
+++ b/rbtools/clients/git.py
@@ -309,12 +309,15 @@ class GitClient(SCMClient):
             return self.make_perforce_diff(ancestor, diff_lines)
         elif self.type == "git":
             cmdline = [self.git, "diff", "--no-color", "--full-index",
-                       "--no-ext-diff", "--ignore-submodules", "--no-renames",
-                       rev_range]
+                       "--no-ext-diff", "--ignore-submodules"]

             if (self.capabilities is not None and
                 self.capabilities.has_capability('diffs', 'moved_files')):
-                cmdline.append('-M')
+                cmdline.append('--find-renames')
+            else:
+                cmdline.append('--no-renames')
+
+            cmdline += [rev_range]

             return execute(cmdline)
garrett.cooper@ZL00757 ~/git/rbtools
$ post-review
git diff --no-color --full-index --no-ext-diff --ignore-submodules --find-renames 9b502ee44382d53e956ae68bb6215cd2cc723ac0..refs/heads/master
There don't seem to be any diffs!

$ post-review --revision-range=HEAD
git diff --no-color --full-index --no-ext-diff --ignore-submodules --find-renames HEAD
Review request #4821 posted.

garrett.cooper@ZL00757 ~/git/rbtools
$ rbt post --revision-range=HEAD
git diff --no-color --full-index --no-ext-diff --ignore-submodules --find-renames HEAD
Review request #4822 posted.

http://reviews.reviewboard.org/r/4822/

garrett.cooper@ZL00757 ~/git/rbtools
$ rbt post
git diff --no-color --full-index --no-ext-diff --ignore-submodules --find-renames 9b502ee44382d53e956ae68bb6215cd2cc723ac0..refs/heads/master
ERROR:root:There don't seem to be any diffs!

What operating system are you using? What browser?

Cygwin.

Please provide any additional information below.
david
#1 david
Unlike with svn or cvs, where the working directory is the only place to store pending changes, the git/hg/etc backends in rbtools operate on local commits. There's probably a lot of improvements we can make with making this more clear, but for now, the best approach is to probably either commit to a topic branch, or do what you were doing with --revision-range.
david
#2 david
I've added a warning to rbtools master (66562bc). Thanks!
  • +Fixed