xref: /freebsd/tools/tools/git/git-arc.1 (revision fa38579f317d5c2ff2926fab9b12ee6d429bd155)
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 Janurary 15, 2025
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.
86Note that group reviewers must be specified using their
87hashtag (e.g. #jails for the "Jails" group).
88.It Fl s Ar subscriber
89Add one or more subscribers, separated by commas, to revision(s) being created.
90Each argument must be an existing Phabricator user or group.
91.It Fl p Ar parent
92Specify the parent of the first commit in the list.
93This is useful when adding more commits on top of an already existing
94stack in Phabricator.
95.El
96.It Cm list
97Print the associated Differential Revisions for the specified commits.
98.It Cm patch
99Try to apply a patch from a Differential Revision to the currently
100checked out tree.
101.It Cm stage
102Prepare a series of commits to be pushed to the upstream
103.Fx
104repository.
105The commits are cherry-picked to a branch (by default the
106.Dq main
107branch), review tags are added to the commit log message, and
108the log message is opened in an editor for any last-minute
109updates.
110The commits need not have associated Differential
111Revisions.
112.It Cm update
113Synchronize the Differential Revisions associated with the
114specified commits.
115Currently only the diff is updated; the review description and other
116metadata are not synchronized.
117If a message is specified with
118.Fl m ,
119that message is added as a note to the Differential Revision.
120If no message is supplied,
121the user's editor will be opened to provide an update message for
122each revision.
123If an empty message is supplied via
124.Fl m ,
125then no notes will be added when updating Differential Revisions.
126.Pp
127If
128.Fl l
129is used, display list of commits to be updated and wait for confirmation
130of the list rather than prompting for each commit.
131.El
132.Sh CONFIGURATION
133These are manipulated by
134.Nm git-config :
135.Bl -tag -width "arc.assume_yes"
136.It Va arc.assume_yes
137Assume a
138.Dq yes
139answer to all prompts instead of
140prompting the user.
141Equivalent to the
142.Fl y
143flag.
144Defaults to false.
145.It Va arc.browse
146Try to open newly created reviews in a browser tab.
147Defaults to false.
148.It Va arc.list
149Always use
150.Dq list mode
151.Pq Fl l
152with create and update.
153In this mode, the list of git revisions to use
154is listed with a single prompt before creating or updating reviews.
155The diffs for individual commits are not shown.
156Defaults to false.
157.It Va arc.verbose
158Always use verbose output.
159Equivalent to the
160.Fl v
161flag.
162Defaults to false.
163.El
164.Sh EXAMPLES
165The typical end-to-end usage looks something like this.
166.Pp
167Commit changes with a message and create a Differential Review:
168.Bd -literal -offset indent
169$ git commit -m "kern: Rewrite in Rust"
170$ git arc create HEAD
171.Ed
172.Pp
173Make changes to the diff based on review feedback, then amend the
174changes to the existing commit and update the Differential Review:
175.Bd -literal -offset indent
176$ git commit --amend
177$ git arc update HEAD
178.Ed
179.Pp
180Now that all reviewers are happy, it is time to stage the commit and
181push it:
182.Bd -literal -offset indent
183$ git arc stage HEAD
184$ git push freebsd HEAD:main
185.Ed
186.Pp
187Create a Phabricator review using the contents of the most recent
188commit in your git checkout:
189.Bd -literal -offset indent
190$ git arc create -r markj,#jails HEAD
191.Ed
192.Pp
193The commit title is used as the review title, the commit log
194message is used as the review description, and
195.Aq Mt markj@FreeBSD.org
196is added as a reviewer.
197Also, the
198.Dq Jails
199reviewer group is added using its hashtag.
200.Pp
201Create a series of Phabricator reviews for each of HEAD~2, HEAD~ and
202HEAD:
203.Bd -literal -offset indent
204$ git arc create HEAD~3..HEAD
205.Ed
206.Pp
207Pairs of consecutive commits are linked into a patch stack.
208Note that the first commit in the specified range is excluded.
209.Pp
210Create a series of separate reviews for each of the following commits:
211.Bd -literal -offset indent
212$ git arc create b409afcfedcdda ca03ed1345aff0
213.Ed
214.Pp
215Update the review corresponding to commit b409afcfedcdda:
216.Bd -literal -offset indent
217$ git arc update b409afcfedcdda
218.Ed
219.Pp
220The title of the commit must be the same as it was when the review
221was created.
222Note that the review description is not automatically updated.
223.Pp
224Apply the patch in review D12345 to the currently checked-out tree,
225and stage it:
226.Bd -literal -offset indent
227$ git arc patch D12345
228.Ed
229.Pp
230Apply the patch in review D23456 to the currently checked-out tree,
231and commit it to the tree with the commit message in the review and
232make the best guess for what to use for author.
233If the guess is considered unreliable, the user is prompted to see
234if they wish to use it (or abort).
235.Bd -literal -offset indent
236$ git arc patch -c D23456
237.Ed
238.Pp
239List the status of reviews for all the commits in the branch
240.Dq feature :
241.Bd -literal -offset indent
242$ git arc list main..feature
243.Ed
244.Pp
245Update reviews for all commits in the branch
246.Dq feature
247after rebasing:
248.Bd -literal -offset indent
249$ git arc update -lm "Rebase" main..feature
250.Ed
251.Sh SEE ALSO
252.Xr build 7 ,
253.Xr development 7
254.Sh HISTORY
255The
256.Nm
257utility appeared in the src tools collection in
258.Fx 14.0 .
259.Sh AUTHORS
260The
261.Nm
262utility was written by
263.An -nosplit
264.An Mark Johnston Aq Mt markj@FreeBSD.org
265and the manual page was written by
266.An Daniel Ebdrup Jensen Aq Mt debdrup@FreeBSD.org .
267