Skip to content

Instantly share code, notes, and snippets.

@zackdever
Created January 30, 2014 02:23
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save zackdever/8701478 to your computer and use it in GitHub Desktop.
Save zackdever/8701478 to your computer and use it in GitHub Desktop.
arc diff off another diff
taken directly from https://sites.google.com/a/khanacademy.org/forge/for-developers/code-review-policy/using-phabricator
Advanced topic: Dependent Phabricator reviews
Say you have an upstream called master, and a feature branch F1, and a second change that depends on F1, (call it F2).
git checkout master
git checkout -b F1
# work work
git commit -a
arc diff
git checkout -b F2 # Note that F1 is set as the upstream of F1
# work work
git commit -a
arc diff # arc will now check to see diffs against the upstream, so only the change from F1 to F2 will be posted
Now let's say you had issues in F1 from a review and you need to update the Phabricator diff.
git co F1
# fix the stuff
git commit -a --amend
arc diff # upload updated patch
git co F2
git rebase -i F1 # rebase the contents of F2 on top of the *new* F1. You should only select the actual change on F2
F1 has set its upstream to master. So let's say you want to land F1. After landing F1, you'll want to rebase F2 onto master and change its git upstream to master.
git co master
git pull
git co F1
git rebase master
arc land --onto master # this lands F1. at this point, F2's upstream has disappeared. we need to fix that
git co F2
git branch --set-upstream-to=master # Now F2's upstream is master, since we landed F1!
git rebase -i master
Now, F2 is like a normal branch pointed to master. arc diff uses the upstream to determine the diff to upload to the server.
@maxsang
Copy link

maxsang commented Feb 25, 2015

useful and concise. thanks

@hillarysanders
Copy link

Hrm. When I do my second arc diff, on branch F2, instead of a new phabricator diff being created, it keeps on trying to amend the diff from F1. Any idea why this might be? (When arc diff and arc diff --create are used, the commits from F1 continue to be included in the F2 diff summary)

EDIT: I think that at -u or -t is needed to ensure that F1 is set as upstream of F2
e.g.
git checkout -t -b F2 # for line 11

@benvium
Copy link

benvium commented Oct 4, 2016

Yeah, I find the same. Perhaps our setup is different somehow. Still haven't found a way to do this correctly :-(

@cederber
Copy link

I think the relevant setting is probably default-relative-commit. See here for more details (note this is an alternate workflow): https://medium.com/@kurtisnusbaum/stacked-diffs-keeping-phabricator-diffs-small-d9964f4dcfa6#.vuxvxwbwq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment