Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you arc diff against a particular git branch?

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.

like image 309
Will Avatar asked Nov 06 '13 17:11

Will


People also ask

What does arc diff do?

In Mercurial, arc diff sends all commits in a range for review. By default, this range is changes between the first non-outgoing parent of any revision in history and the directory state. This is a fancy way of saying "every outgoing change since the last merge".

What are stacked diffs?

The basic idea of stacked diffs is that you have a local checkout of the repository which you can mangle to your heart's content. The only thing that the world needs to care about is what you want to push out for review. This means you decide what view of your local checkout the reviewers see.


2 Answers

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/

like image 59
Evan Priestley Avatar answered Oct 17 '22 04:10

Evan Priestley


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.

like image 34
Will Avatar answered Oct 17 '22 04:10

Will