1.\" 2.\" SPDX-License-Identifier: BSD-2-Clause 3.\" 4.\" Copyright (c) 2021 Daniel Ebdrup Jensen 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25.\" SUCH DAMAGE. 26.\" 27.Dd May 5, 2023 28.Dt GIT-ARC 1 29.Os 30.Sh NAME 31.Nm git arc 32.Nd a wrapper to improve integration between git and arcanist 33.Sh SYNOPSIS 34.Nm 35.Cm create 36.Op Fl l 37.Op Fl r Ar reviewer1 Ns Op Cm \&, Ns Ar reviewer2 ... 38.Op Fl s Ar subscriber1 Ns Op Cm \&, Ns Ar subscriber2 ... 39.Op Fl p Ar parent 40.Op Ar commit ... Ns | Ns Ar commit-range 41.Nm 42.Cm list Ar commit ... Ns | Ns Ar commit-range 43.Nm 44.Cm patch 45.Op Fl c 46.Ar diff1 Ns Op Cm \&, Ns Ar diff2 47.Nm 48.Cm stage 49.Op Fl b Ar branch 50.Op Ar commit ... Ns | Ns Ar commit-range 51.Nm 52.Cm update 53.Op Fl l 54.Op Fl m Ar message 55.Op Ar commit ... Ns | Ns Ar commit-range 56.Sh DESCRIPTION 57The 58.Nm 59utility creates and manages 60.Fx 61Phabricator reviews based on git commits. 62It requires the 63.Pa devel/arcanist 64port or package. 65.Pp 66.Nm 67assumes a one-to-one relationship between git commits and 68Differential Revisions, and the Differential Revision title must match 69the summary line of the corresponding commit. 70In particular, the commit summaries must be unique across all open 71Differential Revisions authored by the submitter. 72.Pp 73The first parameter must be a verb. 74The available verbs are: 75.Bl -tag -width "create" 76.It Cm create 77Create new Differential Revisions from the specified commits. 78Accepts options: 79.Bl -tag -width "-s subscriber" 80.It Fl l 81Before processing commit(s) display list of commits to be processed 82and wait for confirmation. 83.It Fl r Ar reviewer 84Add one or more reviewers, separated by commas, to revision(s) being created. 85Each argument must be an existing Phabricator user or group. 86.It Fl s Ar subscriber 87Add one or more subscribers, separated by commas, to revision(s) being created. 88Each argument must be an existing Phabricator user or group. 89.It Fl p Ar parent 90Specify the parent of the first commit in the list. 91This is useful when adding more commits on top of an already existing 92stack in Phabricator. 93.El 94.It Cm list 95Print the associated Differential Revisions for the specified commits. 96.It Cm patch 97Try to apply a patch from a Differential Revision to the currently 98checked out tree. 99.It Cm stage 100Prepare a series of commits to be pushed to the upstream 101.Fx 102repository. 103The commits are cherry-picked to a branch (by default the 104.Dq main 105branch), review tags are added to the commit log message, and 106the log message is opened in an editor for any last-minute 107updates. 108The commits need not have associated Differential 109Revisions. 110.It Cm update 111Synchronize the Differential Revisions associated with the 112specified commits. 113Currently only the diff is updated; the review description and other 114metadata are not synchronized. 115If a message is specified with 116.Fl m , 117that message is added as a note to the Differential Revision. 118If no message is supplied, 119the user's editor will be opened to provide an update message for 120each revision. 121If an empty message is supplied via 122.Fl m , 123then no notes will be added when updating Differential Revisions. 124.Pp 125If 126.Fl l 127is used, display list of commits to be updated and wait for confirmation 128of the list rather than prompting for each commit. 129.El 130.Sh CONFIGURATION 131These are manipulated by 132.Nm git-config : 133.Bl -tag -width "arc.assume_yes" 134.It Va arc.assume_yes 135Assume a 136.Dq yes 137answer to all prompts instead of 138prompting the user. 139Equivalent to the 140.Fl y 141flag. 142Defaults to false. 143.It Va arc.browse 144Try to open newly created reviews in a browser tab. 145Defaults to false. 146.It Va arc.list 147Always use 148.Dq list mode 149.Pq Fl l 150with create and update. 151In this mode, the list of git revisions to use 152is listed with a single prompt before creating or updating reviews. 153The diffs for individual commits are not shown. 154Defaults to false. 155.It Va arc.verbose 156Always use verbose output. 157Equivalent to the 158.Fl v 159flag. 160Defaults to false. 161.El 162.Sh EXAMPLES 163The typical end-to-end usage looks something like this. 164.Pp 165Commit changes with a message and create a Differential Review: 166.Bd -literal -offset indent 167$ git commit -m "kern: Rewrite in Rust" 168$ git arc create HEAD 169.Ed 170.Pp 171Make changes to the diff based on review feedback, then amend the 172changes to the existing commit and update the Differential Review: 173.Bd -literal -offset indent 174$ git commit --amend 175$ git arc update HEAD 176.Ed 177.Pp 178Now that all reviewers are happy, it is time to stage the commit and 179push it: 180.Bd -literal -offset indent 181$ git arc stage HEAD 182$ git push freebsd HEAD:main 183.Ed 184.Pp 185Create a Phabricator review using the contents of the most recent 186commit in your git checkout: 187.Bd -literal -offset indent 188$ git arc create -r markj,#jails HEAD 189.Ed 190.Pp 191The commit title is used as the review title, the commit log 192message is used as the review description, and 193.Aq Mt markj@FreeBSD.org 194is added as a reviewer. 195Also, the 196.Dq Jails 197reviewer group is added using its hashtag. 198.Pp 199Create a series of Phabricator reviews for each of HEAD~2, HEAD~ and 200HEAD: 201.Bd -literal -offset indent 202$ git arc create HEAD~3..HEAD 203.Ed 204.Pp 205Pairs of consecutive commits are linked into a patch stack. 206Note that the first commit in the specified range is excluded. 207.Pp 208Create a series of separate reviews for each of the following commits: 209.Bd -literal -offset indent 210$ git arc create b409afcfedcdda ca03ed1345aff0 211.Ed 212.Pp 213Update the review corresponding to commit b409afcfedcdda: 214.Bd -literal -offset indent 215$ git arc update b409afcfedcdda 216.Ed 217.Pp 218The title of the commit must be the same as it was when the review 219was created. 220Note that the review description is not automatically updated. 221.Pp 222Apply the patch in review D12345 to the currently checked-out tree, 223and stage it: 224.Bd -literal -offset indent 225$ git arc patch D12345 226.Ed 227.Pp 228Apply the patch in review D23456 to the currently checked-out tree, 229and commit it to the tree with the commit message in the review and 230make the best guess for what to use for author. 231If the guess is considered unreliable, the user is prompted to see 232if they wish to use it (or abort). 233.Bd -literal -offset indent 234$ git arc patch -c D23456 235.Ed 236.Pp 237List the status of reviews for all the commits in the branch 238.Dq feature : 239.Bd -literal -offset indent 240$ git arc list main..feature 241.Ed 242.Pp 243Update reviews for all commits in the branch 244.Dq feature 245after rebasing: 246.Bd -literal -offset indent 247$ git arc update -lm "Rebase" main..feature 248.Ed 249.Sh SEE ALSO 250.Xr build 7 , 251.Xr development 7 252.Sh HISTORY 253The 254.Nm 255utility appeared in the src tools collection in 256.Fx 14.0 . 257.Sh AUTHORS 258The 259.Nm 260utility was written by 261.An -nosplit 262.An Mark Johnston Aq Mt markj@FreeBSD.org 263and the manual page was written by 264.An Daniel Ebdrup Jensen Aq Mt debdrup@FreeBSD.org . 265