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