Blob


1 .\"
2 .\" Copyright (c) 2017 Martin Pieuchot
3 .\" Copyright (c) 2018, 2019 Stefan Sperling
4 .\"
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
8 .\"
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\"
17 .Dd $Mdocdate$
18 .Dt GOT 1
19 .Os
20 .Sh NAME
21 .Nm got
22 .Nd game of trees
23 .Sh SYNOPSIS
24 .Nm
25 .Ar command
26 .Op Fl h
27 .Op Ar arg ...
28 .Sh DESCRIPTION
29 .Nm
30 is a version control system which stores the history of tracked files
31 in a Git repository, as used by the Git version control system.
32 This repository format is described in
33 .Xr git-repository 5 .
34 .Pp
35 .Nm
36 is a
37 .Dq distributed
38 version control system because every copy of a repository is writeable.
39 Modifications made to files can be synchronized between repositories
40 at any time.
41 .Pp
42 Files managed by
43 .Nm
44 must be checked out from the repository for modification.
45 Checked out files are stored in a
46 .Em work tree
47 which can be placed at an arbitrary directory in the filesystem hierarchy.
48 The on-disk format of this work tree is described in
49 .Xr got-worktree 5 .
50 .Pp
51 .Nm
52 provides global and command-specific options.
53 Global options must preceed the command name, and are as follows:
54 .Bl -tag -width tenletters
55 .It Fl h
56 Display usage information.
57 .El
58 .Pp
59 The commands for
60 .Nm
61 are as follows:
62 .Bl -tag -width checkout
63 .It Cm init Ar path
64 Create a new empty repository at the specified
65 .Ar path .
66 .It Cm checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
67 Copy files from a repository into a new work tree.
68 If the
69 .Ar work tree path
70 is not specified, either use the last component of
71 .Ar repository path ,
72 or if a
73 .Ar path prefix
74 was specified use the last component of
75 .Ar path prefix .
76 .Pp
77 The options for
78 .Cm got checkout
79 are as follows:
80 .Bl -tag -width Ds
81 .It Fl b Ar branch
82 Check out files from the specified
83 .Ar branch .
84 If this option is not specified, a branch resolved via the repository's HEAD
85 reference will be used.
86 .It Fl c Ar commit
87 Check out files from the specified
88 .Ar commit .
89 The expected argument is a commit ID SHA1 hash.
90 An abbreviated hash argument will be expanded to a full SHA1 hash
91 automatically, provided the abbreviation is unique.
92 If this option is not specified, the most recent commit on the selected
93 branch will be used.
94 .It Fl p Ar path-prefix
95 Restrict the work tree to a subset of the repository's tree hierarchy.
96 Only files beneath the specified
97 .Ar path-prefix
98 will be checked out.
99 .El
100 .It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
101 Update an existing work tree to a different commit.
102 Show the status of each affected file, using the following status codes:
103 .Bl -column YXZ description
104 .It U Ta file was updated and contained no local changes
105 .It G Ta file was updated and local changes were merged cleanly
106 .It C Ta file was updated and conflicts occurred during merge
107 .It D Ta file was deleted
108 .It A Ta new file was added
109 .It ~ Ta versioned file is obstructed by a non-regular file
110 .It ! Ta a missing versioned file was restored
111 .El
112 .Pp
113 If a
114 .Ar path
115 is specified, restrict the update operation to files at or within this path.
116 The path is required to exist in the update operation's target commit.
117 Files in the work tree outside this path will remain unchanged and will
118 retain their previously recorded base commit.
119 Some
120 .Nm
121 commands may refuse to run while the work tree contains files from
122 multiple base commits.
123 The base commit of such a work tree can be made consistent by running
124 .Cm got update
125 across the entire work tree.
126 Specifying a
127 .Ar path
128 is incompatible with the
129 .Fl b
130 option.
131 .Pp
132 The options for
133 .Cm got update
134 are as follows:
135 .Bl -tag -width Ds
136 .It Fl b Ar branch
137 Switch the work tree's branch reference to the specified
138 .Ar branch
139 before updating the work tree.
140 This option requires that all paths in the work tree are updated.
141 .It Fl c Ar commit
142 Update the work tree to the specified
143 .Ar commit .
144 The expected argument is a commit ID SHA1 hash.
145 An abbreviated hash argument will be expanded to a full SHA1 hash
146 automatically, provided the abbreviation is unique.
147 If this option is not specified, the most recent commit on the work tree's
148 branch will be used.
149 .El
150 .It Cm status [ Ar path ]
151 Show the current modification status of files in a work tree,
152 using the following status codes:
153 .Bl -column YXZ description
154 .It M Ta modified file
155 .It A Ta file scheduled for addition in next commit
156 .It D Ta file scheduled for deletion in next commit
157 .It C Ta modified or added file which contains merge conflicts
158 .It ! Ta versioned file was expected on disk but is missing
159 .It ~ Ta versioned file is obstructed by a non-regular file
160 .It ? Ta unversioned item not tracked by
161 .Nm
162 .El
163 .Pp
164 If a
165 .Ar path
166 is specified, only show modifications within this path.
167 .It Cm log [ Fl b ] [ Fl c Ar commit ] [ Fl C Ar number ] [ Fl l Ar N ] [ Fl p ] [ Fl r Ar repository-path ] [ path ]
168 Display history of a repository.
169 If a
170 .Ar path
171 is specified, show only commits which modified this path.
172 .Pp
173 The options for
174 .Cm got log
175 are as follows:
176 .Bl -tag -width Ds
177 .It Fl b
178 Show the linear line of history of the current branch.
179 This option restricts history traversal to the first parent of each commit.
180 Commits which the branch was based on and merge commits which affected the
181 branch will be shown, but individual commits created on parallel branches
182 will be omitted.
183 .It Fl c Ar commit
184 Start traversing history at the specified
185 .Ar commit .
186 The expected argument is the name of a branch or a commit ID SHA1 hash.
187 An abbreviated hash argument will be expanded to a full SHA1 hash
188 automatically, provided the abbreviation is unique.
189 If this option is not specified, default to the work tree's current branch
190 if invoked in a work tree, or to the repository's HEAD reference.
191 .It Fl C Ar number
192 Set the number of context lines shown in diffs with
193 .Fl p .
194 By default, 3 lines of context are shown.
195 .It Fl l Ar N
196 Limit history traversal to a given number of commits.
197 .It Fl p
198 Display the patch of modifications made in each commit.
199 .It Fl r Ar repository-path
200 Use the repository at the specified path.
201 If not specified, assume the repository is located at or above the current
202 working directory.
203 If this directory is a
204 .Nm
205 work tree, use the repository path associated with this work tree.
206 .El
207 .It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
208 When invoked within a work tree with less than two arguments, display
209 uncommitted changes in the work tree.
210 If a
211 .Ar path
212 is specified, only show changes within this path.
213 .Pp
214 If two arguments are provided, treat each argument as a reference,
215 or an object ID SHA1 hash, and display differences between these objects.
216 Both objects must be of the same type (blobs, trees, or commits).
217 An abbreviated hash argument will be expanded to a full SHA1 hash
218 automatically, provided the abbreviation is unique.
219 .Pp
220 The options for
221 .Cm got diff
222 are as follows:
223 .Bl -tag -width Ds
224 .It Fl C Ar number
225 Set the number of context lines shown in the diff.
226 By default, 3 lines of context are shown.
227 .It Fl r Ar repository-path
228 Use the repository at the specified path.
229 If not specified, assume the repository is located at or above the current
230 working directory.
231 If this directory is a
232 .Nm
233 work tree, use the repository path associated with this work tree.
234 .El
235 .It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
236 Display line-by-line history of a file at the specified path.
237 .Pp
238 The options for
239 .Cm got blame
240 are as follows:
241 .Bl -tag -width Ds
242 .It Fl c Ar commit
243 Start traversing history at the specified
244 .Ar commit .
245 The expected argument is the name of a branch or a commit ID SHA1 hash.
246 An abbreviated hash argument will be expanded to a full SHA1 hash
247 automatically, provided the abbreviation is unique.
248 .It Fl r Ar repository-path
249 Use the repository at the specified path.
250 If not specified, assume the repository is located at or above the current
251 working directory.
252 If this directory is a
253 .Nm
254 work tree, use the repository path associated with this work tree.
255 .El
256 .It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
257 Display a listing of files and directories at the specified
258 directory path in the repository.
259 Entries shown in this listing may carry one of the following trailing
260 annotations:
261 .Bl -column YXZ description
262 .It / Ta entry is a directory
263 .It * Ta entry is an executable file
264 .El
265 .Pp
266 If no
267 .Ar path
268 is specified, list the repository path corresponding to the current
269 directory of the work tree, or the root directory of the repository
270 if there is no work tree.
271 .Pp
272 The options for
273 .Cm got tree
274 are as follows:
275 .Bl -tag -width Ds
276 .It Fl c Ar commit
277 List files and directories as they appear in the specified
278 .Ar commit .
279 The expected argument is the name of a branch or a commit ID SHA1 hash.
280 An abbreviated hash argument will be expanded to a full SHA1 hash
281 automatically, provided the abbreviation is unique.
282 .It Fl r Ar repository-path
283 Use the repository at the specified path.
284 If not specified, assume the repository is located at or above the current
285 working directory.
286 If this directory is a
287 .Nm
288 work tree, use the repository path associated with this work tree.
289 .It Fl i
290 Show object IDs of files (blob objects) and directories (tree objects).
291 .It Fl R
292 Recurse into sub-directories in the repository.
293 .El
294 .It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
295 Manage references in a repository.
296 .Pp
297 If no options are passed, expect two arguments and attempt to create,
298 or update, the reference with the given
299 .Ar name ,
300 and make it point at the given
301 .Ar target .
302 The target may be an object ID SHA1 hash or an existing reference which
303 will be resolved to an object ID.
304 An abbreviated hash argument will be expanded to a full SHA1 hash
305 automatically, provided the abbreviation is unique.
306 .Pp
307 The options for
308 .Cm got ref
309 are as follows:
310 .Bl -tag -width Ds
311 .It Fl r Ar repository-path
312 Use the repository at the specified path.
313 If not specified, assume the repository is located at or above the current
314 working directory.
315 If this directory is a
316 .Nm
317 work tree, use the repository path associated with this work tree.
318 .It Fl l
319 List all existing references in the repository.
320 .It Fl d Ar name
321 Delete the reference with the specified name from the repository.
322 .El
323 .It Cm branch [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name [ Ar base-branch ] ]
324 Manage branches in a repository.
325 .Pp
326 Branches are managed via references which live in the
327 .Dq refs/heads/
328 reference namespace.
329 The
330 .Cm got branch
331 command operates on references in this namespace only.
332 .Pp
333 If no options are passed, expect one or two arguments and attempt to create
334 a branch with the given
335 .Ar name ,
336 and make it point at the given
337 .Ar base-branch .
338 If no
339 .Ar base-branch
340 is specified, default to the work tree's current branch if invoked in a
341 work tree, or to the repository's HEAD reference.
342 .Pp
343 The options for
344 .Cm got branch
345 are as follows:
346 .Bl -tag -width Ds
347 .It Fl r Ar repository-path
348 Use the repository at the specified path.
349 If not specified, assume the repository is located at or above the current
350 working directory.
351 If this directory is a
352 .Nm
353 work tree, use the repository path associated with this work tree.
354 .It Fl l
355 List all existing branches in the repository.
356 .It Fl d Ar name
357 Delete the branch with the specified name from the repository.
358 .El
359 .It Cm add Ar file-path ...
360 Schedule unversioned files in a work tree for addition to the
361 repository in the next commit.
362 .It Cm rm Ar file-path ...
363 Remove versioned files from a work tree and schedule them for deletion
364 from the repository in the next commit.
365 .Pp
366 The options for
367 .Cm got rm
368 are as follows:
369 .Bl -tag -width Ds
370 .It Fl f
371 Perform the operation even if a file contains uncommitted modifications.
372 .El
373 .It Cm revert Ar file-path ...
374 Revert any uncommited changes in files at the specified paths.
375 File contents will be overwritten with those contained in the
376 work tree's base commit. There is no way to bring discarded
377 changes back after
378 .Cm got revert !
379 .Pp
380 If a file was added with
381 .Cm got add
382 it will become an unversioned file again.
383 If a file was deleted with
384 .Cm got rm
385 it will be restored.
386 .It Cm commit [ Fl m Ar message ] [ file-path ]
387 Create a new commit in the repository from local changes in a work tree
388 and use this commit as the new base commit for the work tree.
389 .Pp
390 Show the status of each affected file, using the following status codes:
391 .Bl -column YXZ description
392 .It M Ta modified file
393 .It D Ta file was deleted
394 .It A Ta new file was added
395 .El
396 .Pp
397 Files without local changes will retain their previously recorded base
398 commit.
399 Some
400 .Nm
401 commands may refuse to run while the work tree contains files from
402 multiple base commits.
403 The base commit of such a work tree can be made consistent by running
404 .Cm got update
405 across the entire work tree.
406 .Pp
407 The
408 .Cm got commit
409 command requires the
410 .Ev GOT_AUTHOR
411 environment variable to be set.
412 .Pp
413 The options for
414 .Cm got commit
415 are as follows:
416 .Bl -tag -width Ds
417 .It Fl m Ar message
418 Use the specified log message when creating the new commit.
419 Without the
420 .Fl m
421 option,
422 .Cm got commit
423 opens a temporary file in an editor where a log message can be written.
424 .El
425 .It Cm cherrypick Ar commit
426 Merge changes from a single
427 .Ar commit
428 into the work tree.
429 The specified
430 .Ar commit
431 must be on a different branch than the work tree's base commit.
432 The expected argument is a reference or a commit ID SHA1 hash.
433 An abbreviated hash argument will be expanded to a full SHA1 hash
434 automatically, provided the abbreviation is unique.
435 .Pp
436 Show the status of each affected file, using the following status codes:
437 .Bl -column YXZ description
438 .It G Ta file was merged
439 .It C Ta file was merged and conflicts occurred during merge
440 .It ! Ta changes destined for a missing file were not merged
441 .It D Ta file was deleted
442 .It d Ta file's deletion was obstructed by local modifications
443 .It A Ta new file was added
444 .It ~ Ta changes destined for a non-regular file were not merged
445 .El
446 .Pp
447 The merged changes will appear as local changes in the work tree, which
448 may be viewed with
449 .Cm got diff ,
450 amended manually or with further
451 .Cm got cherrypick
452 comands,
453 committed with
454 .Cm got commit ,
455 or discarded again with
456 .Cm got revert .
457 .Pp
458 .Cm got cherrypick
459 will refuse to run if certain preconditions are not met.
460 If the work tree contains multiple base commits it must first be updated
461 to a single base commit with
462 .Cm got update .
463 If the work tree already contains files with merge conflicts, these
464 conflicts must be resolved first.
465 .It Cm backout Ar commit
466 Reverse-merge changes from a single
467 .Ar commit
468 into the work tree.
469 The specified
470 .Ar commit
471 must be on the same branch as the work tree's base commit.
472 The expected argument is a reference or a commit ID SHA1 hash.
473 An abbreviated hash argument will be expanded to a full SHA1 hash
474 automatically, provided the abbreviation is unique.
475 .Pp
476 Show the status of each affected file, using the following status codes:
477 .Bl -column YXZ description
478 .It G Ta file was merged
479 .It C Ta file was merged and conflicts occurred during merge
480 .It ! Ta changes destined for a missing file were not merged
481 .It D Ta file was deleted
482 .It d Ta file's deletion was obstructed by local modifications
483 .It A Ta new file was added
484 .It ~ Ta changes destined for a non-regular file were not merged
485 .El
486 .Pp
487 The reverse-merged changes will appear as local changes in the work tree,
488 which may be viewed with
489 .Cm got diff ,
490 amended manually or with further
491 .Cm got cherrypick
492 comands,
493 committed with
494 .Cm got commit ,
495 or discarded again with
496 .Cm got revert .
497 .Pp
498 .Cm got backout
499 will refuse to run if certain preconditions are not met.
500 If the work tree contains multiple base commits it must first be updated
501 to a single base commit with
502 .Cm got update .
503 If the work tree already contains files with merge conflicts, these
504 conflicts must be resolved first.
505 .El
506 .Sh ENVIRONMENT
507 .Bl -tag -width GOT_AUTHOR
508 .It Ev GOT_AUTHOR
509 The author's name and email address for
510 .Cm got commit ,
511 for example:
512 .An Stefan Sperling Aq Mt stsp@openbsd.org
513 .It Ev VISUAL, Ev EDITOR
514 The editor spawned by
515 .Cm got commit .
516 .El
517 .Sh EXIT STATUS
518 .Ex -std got
519 .Sh EXAMPLES
520 .Pp
521 Clone an existing Git repository for use with
522 .Nm .
523 This step currently requires
524 .Xr git 1 :
525 .Pp
526 .Dl $ cd /var/git/
527 .Dl $ git clone --bare https://github.com/openbsd/src.git
528 .Pp
529 Check out a work tree from this Git repository to /usr/src:
530 .Pp
531 .Dl $ got checkout /var/git/src.git /usr/src
532 .Pp
533 View local changes in a work tree directory:
534 .Pp
535 .Dl $ got status
536 .Dl $ got diff | less
537 .Pp
538 In a work tree or a git repository directory, list all branch references:
539 .Pp
540 .Dl $ got branch -l
541 .Pp
542 In a work tree or a git repository directory, create a new branch called
543 .Dq unified-buffer-cache
544 which is forked off the
545 .Dq master
546 branch:
547 .Pp
548 .Dl $ got branch unified-buffer-cache master
549 .Pp
550 Switch an existing work tree to the branch
551 .Dq unified-buffer-cache .
552 Local changes in the work tree will be preserved and merged if necessary:
553 .Pp
554 .Dl $ got update -b unified-buffer-cache
555 .Pp
556 Create a new commit from local changes in a work tree directory.
557 This new commit will become the head commit of the work tree's current branch:
558 .Pp
559 .Dl $ got commit
560 .Pp
561 In a work tree or a git repository directory, view changes committed in
562 the 3 most recent commits to the work tree's branch, or the branch resolved
563 via the repository's HEAD reference, respectively:
564 .Pp
565 .Dl $ got log -p -l 3 -b
566 .Pp
567 Add new files and remove obsolete files in a work tree directory:
568 .Pp
569 .Dl $ got add sys/uvm/uvm_ubc.c
570 .Dl $ got rm sys/uvm/uvm_vnode.c
571 .Pp
572 Create a new commit from local changes in a work tree directory
573 with a pre-defined log message.
574 .Pp
575 .Dl $ got commit -m 'unify the buffer cache'
576 .Pp
577 Update any work tree checked out from the
578 .Dq unified-buffer-cache
579 branch to the latest commit on this branch:
580 .Pp
581 .Dl $ got update
582 .Pp
583 Fetch new upstream commits into the local repository's master branch.
584 This step currently requires
585 .Xr git 1 :
586 .Pp
587 .Dl $ cd /var/git/src.git
588 .Dl $ git fetch origin master:master
589 .Pp
590 Rebase the
591 .Dq unified-buffer-cache
592 branch on top of the new head commit of the
593 .Dq master
594 branch.
595 This step currently requires
596 .Xr git 1 :
597 .Pp
598 .Dl $ git clone /var/git/src.git ~/src-git-wt
599 .Dl $ cd ~/src-git-wt
600 .Dl $ git checkout unified-buffer-cache
601 .Dl $ git rebase master
602 .Dl $ git push -f
603 .Pp
604 Update the work tree to the newly rebased
605 .Dq unified-buffer-cache
606 branch:
607 .Pp
608 .Dl $ got update -b unified-buffer-cache
609 .Sh SEE ALSO
610 .Xr git-repository 5
611 .Xr got-worktree 5
612 .Sh AUTHORS
613 .An Stefan Sperling Aq Mt stsp@openbsd.org
614 .An Martin Pieuchot Aq Mt mpi@openbsd.org
615 .An joshua stein Aq Mt jcs@openbsd.org
616 .Sh CAVEATS
617 .Nm
618 is a work-in-progress and many commands remain to be implemented.
619 At present, the user has to fall back on
620 .Xr git 1
621 to perform many basic tasks.
622 .Pp
623 When working against a repository created with
624 .Dq git clone --bare ,
625 local commits to the
626 .Dq master
627 branch are discouraged, for now, if changes committed to the upstream
628 repository need to be tracked.
629 See the EXAMPLES section.