Diff is relative to tracking branch instead of to merge-base

39 views
Skip to first unread message

Noach Magedman

unread,
Jul 24, 2019, 10:12:14 AM7/24/19
to Review Board Community
The behavior of `rbt diff` changed between 0.7.11 and 1.0.2.
It used to work the way I expected, but now it does not.
How do I obtain the old behavior?

My .reviewboardrc contains
TRACKING_BRANCH = "origin/master"


With the commit graph below, `$ git merge-base origin/master feature-branch`
reports commit A.


    X---Y---Z origin/master
   
/
  A
   
\
    B
---C feature-branch, HEAD



Under 0.7.11, 
`$ rbt diff` gives the same output as `$ git diff A feature-branch`

Under 1.0.2, 
`$ rbt diff` gives the same output as `$ git diff origin/master feature-branch`


1. If this is an intentional design change, I don't understand the use-case.
2. How do I obtain the 0.7.11 behavior while using 1.0.2?


Thanks!

Noach Magedman

unread,
Jul 24, 2019, 5:30:58 PM7/24/19
to Review Board Community
I can get the behavior I want by adding the following to my .reviewboardrc:

# .reviewboardrc
_MERGE_BASE_CMD
= ["git", "merge-base", "origin/master", "HEAD", ]
_merge_base
= subprocess.Popen(_MERGE_BASE_CMD,
                               stdout
=subprocess.PIPE
                               
).communicate()[0].strip().decode('utf-8')
TRACKING_BRANCH
= _merge_base




... however it gives me an ugly (and I daresay, incorrect) warning message before showing the (correct!) diff output:

WARNING: Could not determine specific upstream remote to use for diffs. We recommend setting TRACKING_BRANCH in reviewboardrc to your nearest upstream remote branch.


David Trowbridge

unread,
Jul 25, 2019, 12:39:53 PM7/25/19
to reviewboard
The behavior did change, and it was an intentional change to make things consistent across all the different SCM implementations. The new behavior is, basically:

* When no revisions are specified, show the diff between HEAD and the TRACKING_BRANCH
* When one revision is specified, show the diff between that revision and its parent
* When two revisions are specified, show the diff between those two revisions.

Unfortunately, that does make your case more complicated. Aside from what you did with your _MERGE_BASE_CMD, there are a couple solutions I can think of:

1. Set TRACKING_BRANCH to "master" instead of "origin/master" and then avoid fast-forwarding the local head until your branch is done with review (you can still fetch from origin but leave master pointing to the base of your branch). This would work but really isn't great.
2. Much better, use "rbt post origin/master...HEAD" to post your branch (note the 3 dots between revs).
3. Best, create an alias for #2 (using ALIASES in .reviewboardrc) so that you can to something like "rbt p" and have it post what you want.

Hope this helps,
-David

--
Supercharge your Review Board with Power Pack: https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "Review Board Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard/be602eac-61c3-4d23-a1d3-2494b23c566d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages