xref: /freebsd/tools/tools/git/git-arc.1 (revision bd66c1b43e33540205dbc1187c2f2a15c58b57ba)
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 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.
195.Pp
196Create a series of Phabricator reviews for each of HEAD~2, HEAD~ and
197HEAD:
198.Bd -literal -offset indent
199$ git arc create HEAD~3..HEAD
200.Ed
201.Pp
202Pairs of consecutive commits are linked into a patch stack.
203Note that the first commit in the specified range is excluded.
204.Pp
205Create a series of separate reviews for each of the following commits:
206.Bd -literal -offset indent
207$ git arc create b409afcfedcdda ca03ed1345aff0
208.Ed
209.Pp
210Update the review corresponding to commit b409afcfedcdda:
211.Bd -literal -offset indent
212$ git arc update b409afcfedcdda
213.Ed
214.Pp
215The title of the commit must be the same as it was when the review
216was created.
217Note that the review description is not automatically updated.
218.Pp
219Apply the patch in review D12345 to the currently checked-out tree,
220and stage it:
221.Bd -literal -offset indent
222$ git arc patch D12345
223.Ed
224.Pp
225Apply the patch in review D23456 to the currently checked-out tree,
226and commit it to the tree with the commit message in the review and
227make the best guess for what to use for author.
228If the guess is considered unreliable, the user is prompted to see
229if they wish to use it (or abort).
230.Bd -literal -offset indent
231$ git arc patch -c D23456
232.Ed
233.Pp
234List the status of reviews for all the commits in the branch
235.Dq feature :
236.Bd -literal -offset indent
237$ git arc list main..feature
238.Ed
239.Pp
240Update reviews for all commits in the branch
241.Dq feature
242after rebasing:
243.Bd -literal -offset indent
244$ git arc update -lm "Rebase" main..feature
245.Ed
246.Sh SEE ALSO
247.Xr build 7 ,
248.Xr development 7
249.Sh HISTORY
250The
251.Nm
252utility appeared in the src tools collection in
253.Fx 14.0 .
254.Sh AUTHORS
255The
256.Nm
257utility was written by
258.An -nosplit
259.An Mark Johnston Aq Mt markj@FreeBSD.org
260and the manual page was written by
261.An Daniel Ebdrup Jensen Aq Mt debdrup@FreeBSD.org .
262