summaryrefslogtreecommitdiff
path: root/git-review.1
blob: 15a4bd8319e926c04263fa4c35253ff597f3cd88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
.\" Uses mdoc(7). See `man 7 mdoc` for details about the syntax used here
.\"
.Dd 2021-02-09
.Dt GIT\-REVIEW 1
.Sh NAME
.Nm git\-review
.Nd Submit changes to Gerrit for review
.Sh SYNOPSIS
.Nm
.Op Fl r Ar remote
.Op Fl uv
.Fl d Ar change
.Op Ar branch
.Nm
.Op Fl r Ar remote
.Op Fl uv
.Fl x Ar change
.Op Ar branch
.Nm
.Op Fl r Ar remote
.Op Fl uv
.Fl N Ar change
.Op Ar branch
.Nm
.Op Fl r Ar remote
.Op Fl uv
.Fl X Ar change
.Op Ar branch
.Nm
.Op Fl r Ar remote
.Op Fl uv
.Fl m
.Ar change\-ps\-range
.Op Ar branch
.Nm
.Op Fl r Ar remote
.Op Fl fnuv
.Fl s
.Op Ar branch
.Nm
.Op Fl fnuvDRT
.Op Fl r Ar remote
.Op Fl t Ar topic
.Op Fl \-reviewers Ar reviewer ...
.Op Fl \-notify Ar type
.Op Ar branch
.Nm
.Fl l
.Nm
.Fl \-version
.Sh DESCRIPTION
.Nm
automates and streamlines some of the tasks involved with
submitting local changes to a Gerrit server for review. It is
designed to make it easier to comprehend Gerrit, especially for
users that have recently switched to Git from another version
control system.
.Pp
.Ar change
can be
.Ar changeNumber
as obtained using
.Fl \-list
option, or it can be
.Ar changeNumber,patchsetNumber
for fetching exact patchset from the change.
In that case local branch name will have a \-patch[patchsetNumber] suffix.
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl d Ar change , Fl \-download= Ns Ar change
Download
.Ar change
from Gerrit
into a local branch. The branch will be named after the patch author and the name of a topic.
If the local branch already exists, it will attempt to update with the latest patchset for this change.
.It Fl x Ar change , Fl \-cherrypick= Ns Ar change
Apply
.Ar change
from Gerrit and commit into the current local branch ("cherry pick").
No additional branch is created.
.Pp
This makes it possible to review a change without creating a local branch for
it. On the other hand, be aware: if you are not careful, this can easily result
in additional patch sets for dependent changes. Also, if the current branch is
different enough, the change may not apply at all or produce merge conflicts
that need to be resolved by hand.
.It Fl N Ar change , Fl \-cherrypickonly= Ns Ar change
Apply
.Ar change
from Gerrit
into the current working directory, add it to the staging area ("git index"), but do not commit it.
.Pp
This makes it possible to review a change without creating a local commit for
it. Useful if you want to merge several commits into one that will be submitted for review.
.Pp
If the current branch is different enough, the change may not apply at all
or produce merge conflicts that need to be resolved by hand.
.It Fl X Ar change , Fl \-cherrypickindicate= Ns Ar change
Apply
.Ar change
from Gerrit and commit into the current local branch ("cherry pick"),
indicating which commit this change was cherry\-picked from.
.Pp
This makes it possible to re\-review a change for a different branch without
creating a local branch for it.
.Pp
If the current branch is different enough, the change may not apply at all
or produce merge conflicts that need to be resolved by hand.
.It Fl i , Fl \-new\-changeid
Force the git-review to generate a new Change-Id, even if one already exists
in the changelog.
.It Fl m Ar change\-ps\-range , Fl \-compare= Ns Ar change\-ps\-range
Download the specified  patchsets for
.Ar change
from Gerrit, rebase both on master and display differences (git\-diff).
.Pp
.Ar change\-ps\-range
can be specified as
.Ar changeNumber, Ns Ar oldPatchSetNumber Ns Op Ns Ar \-newPatchSetNumber
.Pp
.Ar oldPatchSetNumber
is mandatory, and if
.Ar newPatchSetNumber
is not specified, the latest patchset will be used.
.Pp
This makes it possible to easily compare what has changed from last time you
reviewed the proposed change.
.Pp
If the master branch is different enough, the rebase can produce merge conflicts.
If that happens rebasing will be aborted and diff displayed for not\-rebased branches.
You can also use
.Ar \-\-no\-rebase ( Ar \-R )
to always skip the test rebase.
.It Fl f , Fl \-finish
Close down the local branch and switch back to the target branch on
successful submission.
.It Fl F , Fl \-force\-rebase
Force a rebase before doing anything else, even if not otherwise needed. Unlike
the normal test rebase, this rebase will be kept. Use if you know you want to
push a commit automatically rebased onto the current state of the target
branch. This is discouraged if amending an existing change, since it creates
unnecessary additional differences from the previous revision and so makes
things harder for reviewers of your changes.
.It Fl n , Fl \-dry\-run
Don\(aqt actually perform any commands that have direct effects. Print them
instead.
.It Fl r Ar remote , Fl \-remote= Ns Ar remote
Git remote to use for Gerrit.
.It Fl s , Fl \-setup
Just run the repo setup commands but don\(aqt submit anything.
.It Fl t Ar topic , Fl \-topic= Ns Ar topic
Sets the target topic for this change on the Gerrit server.
If not specified, a bug number from the commit summary will be used. Alternatively, the local branch name will be used if different from remote branch.
.It Fl T , Fl \-no\-topic
Submit review without topic.
.It Fl p , Fl \-private
Send patch as a private patch ready for review. Gerrit versions >= 2.15
.It Fl P , Fl \-remove\-private
Send patch which already in private state to normal patch. Gerrit versions >= 2.15
.It Fl w , Fl \-work\-in\-progress
Send patch as work in progress for Gerrit versions >= 2.15
.It Fl W , Fl \-ready
Send patch that is already work in progress as ready for review. Gerrit versions >= 2.15
.It Fl \-reviewers Ar reviewer ...
Subscribe one or more reviewers to the uploaded patch sets.  Reviewers should be identifiable by Gerrit (usually use their Gerrit username or email address).
.It Fl \-notify Ar type
Control to whom email notifications are sent.  Possible values are NONE, OWNER, OWNER_REVIEWERS, ALL (the last one is the default).
.It Fl u , Fl \-update
Skip cached local copies and force updates from network resources.
.It Fl l , Fl \-list
List the available reviews on the Gerrit server for this project.
.It Fl y , Fl \-yes
Indicate that you do, in fact, understand if you are submitting more than
one patch.
.It Fl v , Fl \-verbose
Turns on more verbose output.
.It Fl R , Fl \-no\-rebase
Don't test for possible merge conflicts with the target branch before pushing.
If the test rebase detects no merge conflicts then the rebase is undone and
your previous state is pushed. If merge conflicts are detected git\-review
exits with the rebase in progress allowing you to address it manually. By
default git\-review will never push the results of a rebase without your
explicit involvement.
.Pp
Use the this option to skip the merge conflict test, allowing you to push merge conflicts.
.Pp
Also can be used for
.Fl \-compare
to skip automatic rebase of fetched reviews.
.It Fl \-no-thin
Disable thin pushes when pushing to Gerrit. This should only be used if you
are currently experiencing unpack failures due to missing trees. It should
not be required in typical day to day use.
.It Fl \-color Ar always|never|auto
Enable or disable a color output. Default is "auto".
.It Fl \-no\-color
Same thing as \-\-color=never.
.It Fl \-no\-custom\-script
Do not run scripts, installed as hooks/{action}-review, where action
is one of "pre" or "post".
.It Fl \-track
Choose the branch to submit the change against (and, if
rebasing, to rebase against) from the branch being tracked
(if a branch is being tracked), and set the tracking branch
when downloading a change to point to the remote and branch
against which patches should be submitted.
See gitreview.track configuration.
.It Fl \-no\-track
Ignore any branch being tracked by the current branch,
overriding gitreview.track.
This option is implied by providing a specific branch name
on the command line.
.It Fl \-use-pushurl
Use the pushurl option for the origin remote rather than conventional
separate Gerrit remotes.
.It Fl \-license
Print the license text and exit.
.It Fl \-version
Print the version number and exit.
.It Fl \-help
Print the short help message and exit.
.El
.Sh CONFIGURATION
This utility can be configured by adding entries to Git configuration.
.Pp
The following configuration keys are supported:
.Bl -tag
.It gitreview.username
Default username used to access the repository. If not specified
in the Git configuration, Git remote or
.Pa .gitreview
file, the user will be prompted to specify the username.
.Pp
Example entry in the
.Pa .gitconfig
file:
.Bd -literal -offset indent
[gitreview]
username=\fImygerrituser\fP
.Ed
.It gitreview.scheme
This setting determines the default scheme (ssh/http/https) of gerrit remote
.It gitreview.host
This setting determines the default hostname of gerrit remote
.It gitreview.port
This setting determines the default port of gerrit remote
.It gitreview.project
This setting determines the default name of gerrit git repo
.It gitreview.remote
This setting determines the default name to use for gerrit remote
.It gitreview.branch
This setting determines the default branch
.It gitreview.notopic
Set to true to never submit with a default topic
.It gitreview.track
Determines whether to prefer the currently-tracked branch (if any)
and the branch against which the changeset was submitted to Gerrit
(if there is exactly one such branch) to the defaultremote and
defaultbranch for submitting and rebasing against.
If the local topic branch is tracking a remote branch, the remote
and branch that the local topic branch is tracking should be used
for submit and rebase operations, rather than the defaultremote
and defaultbranch.
.Pp
When downloading a patch, creates the local branch to track the
appropriate remote and branch in order to choose that branch by
default when submitting modifications to that changeset.
.Pp
A value of 'true' or 'false' should be specified.
.Bl -tag
.It true
Do prefer the currently-tracked branch (if any) \- equivalent
to setting
.Fl \-track
when submitting changes.
.It false
Ignore tracking branches \- equivalent to setting
.Fl \-no\-track
(the default) or providing an explicit branch name when submitting
changes. This is the default value unless overridden by
.Pa .gitreview
file, and is implied by providing a specific branch name on the
command line.
.El
.It gitreview.usepushurl
This setting determines whether to use a separate Git remote for
the Gerrit connection, or to set 'pushurl' on the remote 'origin'.
.Pp
A value of 'true' or 'false' should be specified.
.Bl -tag
.It false
Do not use 'pushurl' and instead use a separate remote.
.It true
Use 'pushurl' for interacting with Gerrit.
.El
.It gitreview.rebase
This setting determines whether changes submitted will
be rebased to the newest state of the branch.
.Pp
A value of 'true' or 'false' should be specified.
.Bl -tag
.It false
Do not rebase changes on submit \- equivalent to setting
.Fl R
when submitting changes.
.It true
Do rebase changes on submit. This is the default value unless
overridden by
.Pa .gitreview
file.
.El
.Pp
This setting takes precedence over repository\-specific configuration
in the
.Pa .gitreview
file.
.It gitreview.branchauthor
This setting changes the look of the author part when naming the local
branch of a downloaded change.  Value must be one of "name", "email",
or "username". Default is "name". See also the
.Fl \-download
option.
.El
.Bl -tag
.It color.review
Whether to use ANSI escape sequences to add color to the output displayed by
this command. Default value is determined by color.ui.
.Bl -tag
.It auto or true
If you want output to use color when written to the terminal (default with Git
1.8.4 and newer).
.It always
If you want all output to use color
.It never or false
If you wish not to use color for any output. (default with Git older than 1.8.4)
.El
.El
.Pp
.Nm
will query git credential system for Gerrit user/password when
authentication failed over http(s). Unlike git,
.Nm
does not persist Gerrit user/password in git credential system for security
purposes and git credential system configuration stays under user responsibility.
.Sh FILES
To use
.Nm
with your project, it is recommended that you create
a file at the root of the repository named
.Pa .gitreview
and place information about your Gerrit installation in it.  The format is similar to the Windows .ini file format:
.Bd -literal -offset indent
[gerrit]
host=\fIhostname\fP
port=\fITCP port number of gerrit\fP
project=\fIproject name\fP
defaultbranch=\fIbranch to work on\fP
.Ed
.Pp
It is also possible to specify optional default name for
the Git remote using the
.Cm defaultremote
configuration parameter.
.Pp
Setting
.Cm defaultrebase
to zero will make
.Nm
not to rebase changes by default (same as the
.Fl R
command line option)
.Bd -literal -offset indent
[gerrit]
scheme=ssh
host=review.example.com
port=29418
project=department/project.git
defaultbranch=master
defaultremote=review
defaultrebase=0
track=0
.Ed
.Pp
When the same option is provided through FILES and CONFIGURATION, the
CONFIGURATION value wins.
.Pp
.Sh DIAGNOSTICS
.Pp
Normally, exit status is 0 if executed successfully.
Exit status 1 indicates general error, sometimes more
specific error codes are available:
.Bl -tag -width 999
.It 2
Gerrit
.Ar commit\-msg
hook could not be successfully installed.
.It 3
Could not parse malformed argument value or user input.
.It 32
Cannot fetch list of open changesets from Gerrit.
.It 33
Cannot parse list of open changesets received from Gerrit.
.It 34
Cannot query information about changesets.
.It 35
Cannot fetch information about the changeset to be downloaded.
.It 36
Changeset not found.
.It 37
Particular patchset cannot be fetched from the remote git repository.
.It 38
Specified patchset number not found in the changeset.
.It 39
Invalid patchsets for comparison.
.It 40
Connection to Gerrit was closed.
.It 64
Cannot checkout downloaded patchset into the new branch.
.It 65
Cannot checkout downloaded patchset into existing branch.
.It 66
Cannot hard reset working directory and git index after download.
.It 67
Cannot switch to some other branch when trying to finish
the current branch.
.It 68
Cannot delete current branch.
.It 69
Requested patchset cannot be fully applied to the current branch.  This exit
status will be returned when there are merge conflicts with the current branch.
Possible reasons include an attempt to apply patchset from the different branch
or code.  This exit status will also be returned if the patchset is already
applied to the current branch.
.It 70
Cannot determine top level Git directory or .git subdirectory path.
.It 101
Unauthorized (401) http request done by git-review.
.It 104
Not Found (404) http request done by git-review.
.El
.Pp
Exit status larger than 31 indicates problem with
communication with Gerrit or remote Git repository,
exit status larger than 63 means there was a problem with
a local repository or a working copy.
.Pp
Exit status larger than or equal to 128 means internal
error in running the "git" command.
.Pp
.Sh EXAMPLES
To fetch a remote change number 3004:
.Pp
.Bd -literal -offset indent
$ git\-review \-d 3004
Downloading refs/changes/04/3004/1 from gerrit into
review/someone/topic_name
Switched to branch 'review/someone/topic_name
$ git branch
  master
* review/author/topic_name
.Ed
.Pp
Gerrit looks up both name of the author and the topic name from Gerrit
to name a local branch. This facilitates easier identification of changes.
.Pp
To fetch a remote patchset number 5 from change number 3004:
.Pp
.Bd -literal -offset indent
$ git\-review \-d 3004,5
Downloading refs/changes/04/3004/5 from gerrit into
review/someone/topic_name\-patch5
Switched to branch 'review/someone/topic_name\-patch5
$ git branch
  master
* review/author/topic_name\-patch5
.Ed
.Pp
To send a change for review and delete local branch afterwards:
.Bd -literal -offset indent
$ git\-review \-f
remote: Resolving deltas:   0% (0/8)
To ssh://username@review.example.com/department/project.git
 * [new branch]      HEAD \-> refs/for/master/topic_name
Switched to branch 'master'
Deleted branch 'review/someone/topic_name'
$ git branch
* master
.Ed
.Pp
An example
.Pa .gitreview
configuration file for a project
.Pa department/project
hosted on
.Cm review.example.com
port
.Cm 29418
in the branch
.Cm master
:
.Bd -literal -offset indent
[gerrit]
host=review.example.com
port=29418
project=department/project.git
defaultbranch=master
.Ed
.Sh BUGS
Bug reports can be submitted to
.Lk https://storyboard.openstack.org/#!/project/opendev/git\-review
.Sh AUTHORS
.Nm
is maintained by
.An "OpenDev Contributors"
.Pp
This manpage has been enhanced by:
.An "Antoine Musso" Aq hashar@free.fr
.An "Jeremy Stanley" Aq fungi@yuggoth.org
.An "Marcin Cieslak" Aq saper@saper.info
.An "Pavel Sedlák" Aq psedlak@redhat.com