xref: /freebsd/tools/tools/git/git-arc.1 (revision 902136e0fe112383ec64d2ef43a446063b5e6417)
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 February 10, 2026
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.Ar commit-ref Op Ar commit-ref ...
41.Nm
42.Cm list Ar commit-ref Op Ar commit-ref ...
43.Nm
44.Cm patch
45.Op Fl bcrs
46.Ar diff1 Op Cm Ar diff2 Op Ar ...
47.Nm
48.Cm stage
49.Op Fl b Ar branch
50.Ar commit-ref Op Ar commit-ref ...
51.Nm
52.Cm update
53.Op Fl l
54.Op Fl m Ar message
55.Ar commit-ref Op Ar commit-ref ...
56.Sh DESCRIPTION
57The
58.Nm
59utility creates and manages
60.Fx
61Phabricator reviews based on git commits.
62It is geared towards
63.Fx
64development.
65It requires the
66.Pa devel/git ,
67.Pa devel/arcanist-lib
68and
69.Pa textproc/jq
70packages; these will be installed automatically if
71.Nm
72is installed via the
73.Pa devel/freebsd-git-arc
74package.
75.Pp
76.Nm
77assumes a one-to-one relationship between git commits and
78Differential Revisions, and requires the titles in a pair to match.
79Commit titles must therefore be unique across all open
80Differential Revisions authored by the submitter.
81If the title of either a commit or its associated Differential Revision is
82changed, the other must be updated manually to maintain the match.
83.Pp
84The first parameter must be a verb.
85Most verbs accept one or more git commit references: commit hashes, branch
86names, commit ranges, and so on.
87A branch name refers to the single commit at its tip; use a commit range to
88operate on multiple commits.
89See
90.Xr git-rev-parse 1
91for details on specifying commit references.
92The available verbs are:
93.Bl -tag -width "create"
94.It Cm create
95Create new Differential Revisions from the specified commits.
96Accepts options:
97.Bl -tag -width "-s subscriber"
98.It Fl l
99Before processing commit(s) display list of commits to be processed
100and wait for confirmation.
101.It Fl r Ar reviewer
102Add one or more reviewers, separated by commas, to revision(s) being created.
103Each argument must be an existing Phabricator user or group.
104Note that group reviewers must be specified using their
105hashtag (e.g. #jails for the "Jails" group).
106.It Fl s Ar subscriber
107Add one or more subscribers, separated by commas, to revision(s) being created.
108Each argument must be an existing Phabricator user or group.
109.It Fl p Ar parent
110Specify the parent of the first commit in the list.
111This is useful when adding more commits on top of an already existing
112stack in Phabricator.
113.El
114.It Cm list
115Print the associated Differential Revisions for the specified commits.
116.It Cm patch
117Try to apply patches from one or more Differential Revision to the currently
118checked out tree.
119The following options are accepted:
120.Bl -tag -width "-b"
121.It Fl b
122Switch to a new branch before applying the patches.
123.It Fl c
124Commit each applied patch to the git checkout.
125The commit message and author are taken from the Differential Revision.
126.It Fl r
127Rather than using the
128.Sy arc
129command to apply the patch, download the raw patch file and apply it using
130.Xr git-apply 1 .
131This is useful for avoiding some misfeatures of
132.Sy arc ,
133particularly its behavior of trying to update all remotes in the tree in some
134cases.
135.It Fl s
136Recursively apply the parent revisions of the specified commit.
137This can be used to apply patch stacks by specifying the top-most, i.e.,
138most recent commit in the stack.
139.El
140.It Cm stage
141Prepare a series of commits to be pushed to the upstream
142.Fx
143repository.
144.Pp
145First, the target branch is checked out; by default this is the
146main branch but can be overridden with the
147.Fl b
148option.
149Then, the specified commits are cherry-picked with review tags added to the
150commit log message, and the log message is opened in an editor for any final
151updates.
152The commits need not have associated Differential Revisions.
153.Pp
154This is intended to be used after code review has been completed, and the
155commits are ready to be pushed to an upstream repository.
156.It Cm update
157Synchronize the Differential Revisions associated with the
158specified commits.
159Currently only the diff is updated; the review description and other
160metadata are not synchronized.
161If a message is specified with
162.Fl m ,
163that message is added as a note to the Differential Revision.
164If no message is supplied,
165the user's editor will be opened to provide an update message for
166each revision.
167If an empty message is supplied via
168.Fl m ,
169then no notes will be added when updating Differential Revisions.
170.Pp
171If
172.Fl l
173is used, display list of commits to be updated and wait for confirmation
174of the list rather than prompting for each commit.
175.El
176.Sh CONFIGURATION
177These are manipulated by
178.Nm git-config :
179.Bl -tag -width "arc.assume_yes"
180.It Va arc.assume_yes
181Assume a
182.Dq yes
183answer to all prompts instead of
184prompting the user.
185Equivalent to the
186.Fl y
187flag.
188Defaults to false.
189.It Va arc.browse
190Try to open newly created reviews in a browser tab.
191Defaults to false.
192.It Va arc.list
193Always use
194.Dq list mode
195.Pq Fl l
196with create and update.
197In this mode, the list of git revisions to use
198is listed with a single prompt before creating or updating reviews.
199The diffs for individual commits are not shown.
200Defaults to false.
201.It Va arc.verbose
202Always use verbose output.
203Equivalent to the
204.Fl v
205flag.
206Defaults to false.
207.El
208.Sh EXAMPLES
209The typical end-to-end usage looks something like this.
210.Pp
211Commit changes with a message and create a Differential Review:
212.Bd -literal -offset indent
213$ git commit -m "kern: Rewrite in Rust"
214$ git arc create HEAD
215.Ed
216.Pp
217Make changes to the diff based on review feedback, then amend the
218changes to the existing commit and update the Differential Review:
219.Bd -literal -offset indent
220$ git commit --amend
221$ git arc update HEAD
222.Ed
223.Pp
224Now that all reviewers are happy, it is time to stage the commit and
225push it:
226.Bd -literal -offset indent
227$ git arc stage HEAD
228$ git push freebsd HEAD:main
229.Ed
230.Pp
231Create a Phabricator review using the contents of the most recent
232commit in your git checkout:
233.Bd -literal -offset indent
234$ git arc create -r markj,#jails HEAD
235.Ed
236.Pp
237The commit title is used as the review title, the commit log
238message is used as the review description, and
239.Aq Mt markj@FreeBSD.org
240is added as a reviewer.
241Also, the
242.Dq Jails
243reviewer group is added using its hashtag.
244.Pp
245Create a series of Phabricator reviews for each of HEAD~2, HEAD~ and
246HEAD:
247.Bd -literal -offset indent
248$ git arc create HEAD~3..HEAD
249.Ed
250.Pp
251Pairs of consecutive commits are linked into a patch stack.
252Note that the first commit in the specified range is excluded.
253.Pp
254Create a series of separate reviews for each of the following commits:
255.Bd -literal -offset indent
256$ git arc create b409afcfedcdda ca03ed1345aff0
257.Ed
258.Pp
259Update the review corresponding to commit b409afcfedcdda:
260.Bd -literal -offset indent
261$ git arc update b409afcfedcdda
262.Ed
263.Pp
264The title of the commit must be the same as it was when the review
265was created.
266Note that the review description is not automatically updated.
267.Pp
268Apply the patch in review D12345 to the currently checked-out tree,
269and stage it:
270.Bd -literal -offset indent
271$ git arc patch D12345
272.Ed
273.Pp
274Apply the patch in review D23456 to the currently checked-out tree,
275and commit it to the tree with the commit message in the review and
276make the best guess for what to use for author.
277If the guess is considered unreliable, the user is prompted to see
278if they wish to use it (or abort).
279.Bd -literal -offset indent
280$ git arc patch -c D23456
281.Ed
282.Pp
283List the status of reviews for all the commits in the branch
284.Dq feature :
285.Bd -literal -offset indent
286$ git arc list main..feature
287.Ed
288.Pp
289Update reviews for all commits in the branch
290.Dq feature
291after rebasing:
292.Bd -literal -offset indent
293$ git arc update -lm "Rebase" main..feature
294.Ed
295.Sh SEE ALSO
296.Xr build 7 ,
297.Xr development 7
298.Sh HISTORY
299The
300.Nm
301utility appeared in the src tools collection in
302.Fx 14.0 .
303.Sh AUTHORS
304The
305.Nm
306utility was written by
307.An -nosplit
308.An Mark Johnston Aq Mt markj@FreeBSD.org
309and the manual page was written by
310.An Daniel Ebdrup Jensen Aq Mt debdrup@FreeBSD.org .
311