Can you arc diff against a particular git branch?
Asked Answered
S

2

38

I'm pretty new to both Arcanist and git. I'd like to be able to create an arc diff (Phabricator Differential instance using Arcanist) against a git branch that I'm currently checked-out/working in (and I have one local un-pushed commit) rather than the master. To me the arc docs are unclear on this. Is it possible? How? It would be nice if the answer works for 2-3 local un-pushed commits as well.

Also "arc help diff" gives:

      diff [paths] (svn)
      diff [commit] (git, hg)
          Supports: git, svn, hg
          Generate a Differential diff or revision from local changes.

          Under git, you can specify a commit (like HEAD^^^ or master)
          and Differential will generate a diff against the merge base of that
          commit and HEAD.

Maybe I just need to do "arc diff [commit]" where [commit] is the tip of the target branch? But I'd like to be certain, because I don't want to pollute our Phabricator instance.

Also, I'm happy to receive "you're doing it wrong" answers if the answer explains how to do it right.

Storytelling answered 6/11, 2013 at 17:55 Comment(0)
M
54

In general, arc diff <branch> will do what you want. (If you're already on the branch, rather than a local topic branch, try arc diff origin/<branch> instead.)

When invoked like this, arc will actually diff against the merge-base of the branch's tip and the current commit in the working copy, but generally this is what you intend. If you really want to generate a diff against the branch tip you can use arc diff --base git:<branch>, but this diff will include changes which undo any commits on the branch which are descendants of the branch point, just like git diff <branch>..HEAD would.

In all cases, you can use arc which <commit> to preview what arc diff will do. This will explain which revision range would be selected, show you the command to see exactly which changes are included, and explain why that range is selected.

You can also use arc diff --preview to generate just a diff, without sending it for review. This will let you preview changes before submitting them to anyone else.

See also:

https://secure.phabricator.com/book/phabricator/article/arcanist_commit_ranges/

Messeigneurs answered 9/11, 2013 at 17:29 Comment(4)
link should be updated to secure.phabricator.com/book/phabricator/article/…Conflagration
for generating diff against the branch tip I used arc diff --base 'git:branch-unique(origin/master)' which generates a diff against the tip of origin/master running arc diff --preview --base git:<branch> did not match the results I wanted.Conflagration
Once <branch> has landed onto master, how do I land my revision onto master, not onto <branch>?Pantry
arc diff origin/<branch> this worked for me thanksAmedeo
S
4

Evan's answer is generally preferable because it is more reflective of best git workflow practices. I recommend following that if you can.

If you need a quick fix and are working in (checked out) the same branch that you want to push to, you can also do arc diff HEAD^ or HEAD~ for a single commit, or arc diff HEAD~N for N commits.

Storytelling answered 2/12, 2013 at 17:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.