Hash :
4a68c90c
Author :
Date :
2019-06-17T14:24:57
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 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
.\"
.\" Copyright (c) 2017 Martin Pieuchot
.\" Copyright (c) 2018, 2019 Stefan Sperling
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
.Dt GOT 1
.Os
.Sh NAME
.Nm got
.Nd game of trees
.Sh SYNOPSIS
.Nm
.Ar command
.Op Fl h
.Op Ar arg ...
.Sh DESCRIPTION
.Nm
is a version control system which stores the history of tracked files
in a Git repository, as used by the Git version control system.
This repository format is described in
.Xr git-repository 5 .
.Pp
.Nm
is a
.Dq distributed
version control system because every copy of a repository is writeable.
Modifications made to files can be synchronized between repositories
at any time.
.Pp
Files managed by
.Nm
must be checked out from the repository for modification.
Checked out files are stored in a
.Em work tree
which can be placed at an arbitrary directory in the filesystem hierarchy.
The on-disk format of this work tree is described in
.Xr got-worktree 5 .
.Pp
.Nm
provides global and command-specific options.
Global options must preceed the command name, and are as follows:
.Bl -tag -width tenletters
.It Fl h
Display usage information.
.El
.Pp
The commands for
.Nm
are as follows:
.Bl -tag -width checkout
.It Cm init Ar path
Create a new empty repository at the specified
.Ar path .
.It Cm checkout [ Fl b Ar branch ] [ Fl c Ar commit ] [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
Copy files from a repository into a new work tree.
If the
.Ar work tree path
is not specified, either use the last component of
.Ar repository path ,
or if a
.Ar path prefix
was specified use the last component of
.Ar path prefix .
.Pp
The options for
.Cm got checkout
are as follows:
.Bl -tag -width Ds
.It Fl b Ar branch
Check out files from the specified
.Ar branch .
If this option is not specified, a branch resolved via the repository's HEAD
reference will be used.
.It Fl c Ar commit
Check out files from the specified
.Ar commit .
If this option is not specified, the most recent commit on the selected
branch will be used.
.It Fl p Ar path-prefix
Restrict the work tree to a subset of the repository's tree hierarchy.
Only files beneath the specified
.Ar path-prefix
will be checked out.
.El
.It Cm update [ Fl b Ar branch ] [ Fl c Ar commit ] [ Ar path ]
Update an existing work tree to a different commit.
Show the status of each affected file, using the following status codes:
.Bl -column YXZ description
.It U Ta file was updated and contained no local changes
.It G Ta file was updated and local changes were merged cleanly
.It C Ta file was updated and conflicts occurred during merge
.It D Ta file was deleted
.It A Ta new file was added
.It ~ Ta versioned file is obstructed by a non-regular file
.It ! Ta a missing versioned file was restored
.El
.Pp
If a
.Ar path
is specified, restrict the update operation to files at or within this path.
The path is required to exist in the update operation's target commit.
Files in the work tree outside this path will remain unchanged and will
retain their previously recorded base commit.
Some
.Nm
commands may refuse to run while the work tree contains files from
multiple base commits.
The base commit of such a work tree can be made consistent by running
.Cm got update
across the entire work tree.
Specifying a
.Ar path
is incompatible with the
.Fl b
option.
.Pp
The options for
.Cm got update
are as follows:
.Bl -tag -width Ds
.It Fl b Ar branch
Switch the work tree's branch reference to the specified
.Ar branch
before updating the work tree.
This option requires that all paths in the work tree are updated.
.It Fl c Ar commit
Update the work tree to the specified
.Ar commit .
The expected argument is a SHA1 hash which corresponds to a commit object.
If this option is not specified, the most recent commit on the work tree's
branch will be used.
.El
.It Cm status [ Ar path ]
Show the current modification status of files in a work tree,
using the following status codes:
.Bl -column YXZ description
.It M Ta modified file
.It A Ta file scheduled for addition in next commit
.It D Ta file scheduled for deletion in next commit
.It C Ta modified or added file which contains merge conflicts
.It ! Ta versioned file was expected on disk but is missing
.It ~ Ta versioned file is obstructed by a non-regular file
.It ? Ta unversioned item not tracked by
.Nm
.El
.Pp
If a
.Ar path
is specified, only show modifications within this path.
.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 ]
Display history of a repository.
If a
.Ar path
is specified, show only commits which modified this path.
.Pp
The options for
.Cm got log
are as follows:
.Bl -tag -width Ds
.It Fl b
Show the linear line of history of the current branch.
This option restricts history traversal to the first parent of each commit.
Commits which the branch was based on and merge commits which affected the
branch will be shown, but individual commits created on parallel branches
will be omitted.
.It Fl c Ar commit
Start traversing history at the specified
.Ar commit .
The expected argument is the name of a branch or a SHA1 hash which corresponds
to a commit object.
If this option is not specified, default to the work tree's current branch
if invoked in a work tree, or to the repository's HEAD reference.
.It Fl C Ar number
Set the number of context lines shown in diffs with
.Fl p .
By default, 3 lines of context are shown.
.It Fl l Ar N
Limit history traversal to a given number of commits.
.It Fl p
Display the patch of modifications made in each commit.
.It Fl r Ar repository-path
Use the repository at the specified path.
If not specified, assume the repository is located at or above the current
working directory.
If this directory is a
.Nm
work tree, use the repository path associated with this work tree.
.El
.It Cm diff [ Fl C Ar number ] [ Fl r Ar repository-path ] [ Ar object1 Ar object2 | Ar path ]
When invoked within a work tree with less than two arguments, display
uncommitted changes in the work tree.
If a
.Ar path
is specified, only show changes within this path.
.Pp
If two arguments are provided, treat each argument as a reference,
or a SHA1 hash, which corresponds to an object in the repository,
and display differences between these objects.
Both objects must be of the same type (blobs, trees, or commits).
.Pp
The options for
.Cm got diff
are as follows:
.Bl -tag -width Ds
.It Fl C Ar number
Set the number of context lines shown in the diff.
By default, 3 lines of context are shown.
.It Fl r Ar repository-path
Use the repository at the specified path.
If not specified, assume the repository is located at or above the current
working directory.
If this directory is a
.Nm
work tree, use the repository path associated with this work tree.
.El
.It Cm blame [ Fl c Ar commit ] [ Fl r Ar repository-path ] Ar path
Display line-by-line history of a file at the specified path.
.Pp
The options for
.Cm got blame
are as follows:
.Bl -tag -width Ds
.It Fl c Ar commit
Start traversing history at the specified
.Ar commit .
The expected argument is the name of a branch or a SHA1 hash which corresponds
to a commit object.
.It Fl r Ar repository-path
Use the repository at the specified path.
If not specified, assume the repository is located at or above the current
working directory.
If this directory is a
.Nm
work tree, use the repository path associated with this work tree.
.El
.It Cm tree [ Fl c Ar commit ] [ Fl r Ar repository-path ] [ Fl i ] [ Fl R] [ Ar path ]
Display a listing of files and directories at the specified
directory path in the repository.
Entries shown in this listing may carry one of the following trailing
annotations:
.Bl -column YXZ description
.It / Ta entry is a directory
.It * Ta entry is an executable file
.El
.Pp
If no
.Ar path
is specified, list the repository path corresponding to the current
directory of the work tree, or the root directory of the repository
if there is no work tree.
.Pp
The options for
.Cm got tree
are as follows:
.Bl -tag -width Ds
.It Fl c Ar commit
List files and directories as they appear in the specified
.Ar commit .
The expected argument is the name of a branch or a SHA1 hash which corresponds
to a commit object.
.It Fl r Ar repository-path
Use the repository at the specified path.
If not specified, assume the repository is located at or above the current
working directory.
If this directory is a
.Nm
work tree, use the repository path associated with this work tree.
.It Fl i
Show object IDs of files (blob objects) and directories (tree objects).
.It Fl R
Recurse into sub-directories in the repository.
.El
.It Cm ref [ Fl r Ar repository-path ] [ Fl l ] [ Fl d Ar name ] [ Ar name Ar target ]
Manage references in a repository.
.Pp
If no options are passed, expect two arguments and attempt to create,
or update, the reference with the given
.Ar name ,
and make it point at the given
.Ar target .
The target may be a SHA1 hash which corresponds to an existing object ID
in the repository, or an existing reference which will be resolved to an
object ID.
.Pp
The options for
.Cm got ref
are as follows:
.Bl -tag -width Ds
.It Fl r Ar repository-path
Use the repository at the specified path.
If not specified, assume the repository is located at or above the current
working directory.
If this directory is a
.Nm
work tree, use the repository path associated with this work tree.
.It Fl l
List all existing references in the repository.
.It Fl d Ar name
Delete the reference with the specified name from the repository.
.El
.It Cm add Ar file-path ...
Schedule unversioned files in a work tree for addition to the
repository in the next commit.
.It Cm rm Ar file-path ...
Remove versioned files from a work tree and schedule them for deletion
from the repository in the next commit.
.Pp
The options for
.Cm got rm
are as follows:
.Bl -tag -width Ds
.It Fl f
Perform the operation even if a file contains uncommitted modifications.
.El
.It Cm revert Ar file-path ...
Revert any uncommited changes in files at the specified paths.
File contents will be overwritten with those contained in the
work tree's base commit. There is no way to bring discarded
changes back after
.Cm got revert !
.Pp
If a file was added with
.Cm got add
it will become an unversioned file again.
If a file was deleted with
.Cm got rm
it will be restored.
.It Cm commit [ Fl m Ar msg ] [ file-path ]
Create a new commit in the repository from local changes in a work tree
and use this commit as the new base commit for the work tree.
.Pp
Show the status of each affected file, using the following status codes:
.Bl -column YXZ description
.It M Ta modified file
.It D Ta file was deleted
.It A Ta new file was added
.El
.Pp
Files without local changes will retain their previously recorded base
commit.
Some
.Nm
commands may refuse to run while the work tree contains files from
multiple base commits.
The base commit of such a work tree can be made consistent by running
.Cm got update
across the entire work tree.
.Pp
The
.Cm got commit
command requires the
.Ev GOT_AUTHOR
environment variable to be set.
.Pp
The options for
.Cm got commit
are as follows:
.Bl -tag -width Ds
.It Fl m Ar msg
Use the specified log message when creating the new commit.
Without the
.Fl m
option,
.Cm got commit
opens a temporary file in an editor where a log message can be written.
.El
.It Cm cherrypick Ar commit
Merge changes from a single
.Ar commit
into the work tree.
The specified
.Ar commit
must be on a different branch than the work tree's base commit.
The expected argument is a reference or a SHA1 hash which corresponds to
a commit object.
.Pp
Show the status of each affected file, using the following status codes:
.Bl -column YXZ description
.It G Ta file was merged
.It C Ta file was merged and conflicts occurred during merge
.It ! Ta changes destined for a missing file were not merged
.It D Ta file was deleted
.It d Ta file's deletion was obstructed by local modifications
.It A Ta new file was added
.It ~ Ta changes destined for a non-regular file were not merged
.El
.Pp
The merged changes will appear as local changes in the work tree, which
may be viewed with
.Cm got diff ,
amended manually or with further
.Cm got cherrypick
comands,
committed with
.Cm got commit ,
or discarded again with
.Cm got revert .
.Pp
.Cm got cherrypick
will refuse to run if certain preconditions are not met.
If the work tree contains multiple base commits it must first be updated
to a single base commit with
.Cm got update .
If the work tree already contains files with merge conflicts, these
conflicts must be resolved first.
.It Cm backout Ar commit
Reverse-merge changes from a single
.Ar commit
into the work tree.
The specified
.Ar commit
must be on the same branch as the work tree's base commit.
The expected argument is a reference or a SHA1 hash which corresponds to
a commit object.
.Pp
Show the status of each affected file, using the following status codes:
.Bl -column YXZ description
.It G Ta file was merged
.It C Ta file was merged and conflicts occurred during merge
.It ! Ta changes destined for a missing file were not merged
.It D Ta file was deleted
.It d Ta file's deletion was obstructed by local modifications
.It A Ta new file was added
.It ~ Ta changes destined for a non-regular file were not merged
.El
.Pp
The reverse-merged changes will appear as local changes in the work tree,
which may be viewed with
.Cm got diff ,
amended manually or with further
.Cm got cherrypick
comands,
committed with
.Cm got commit ,
or discarded again with
.Cm got revert .
.Pp
.Cm got backout
will refuse to run if certain preconditions are not met.
If the work tree contains multiple base commits it must first be updated
to a single base commit with
.Cm got update .
If the work tree already contains files with merge conflicts, these
conflicts must be resolved first.
.El
.Sh ENVIRONMENT
.Bl -tag -width GOT_AUTHOR
.It Ev GOT_AUTHOR
The author's name and email address for
.Cm got commit ,
for example:
.An Stefan Sperling Aq Mt stsp@openbsd.org
.It Ev VISUAL, Ev EDITOR
The editor spawned by
.Cm got commit .
.El
.Sh EXIT STATUS
.Ex -std got
.Sh EXAMPLES
.Pp
Clone an existing Git repository for use with
.Nm .
This step currently requires
.Xr git 1 :
.Pp
.Dl $ cd /var/git/
.Dl $ git clone --bare https://github.com/openbsd/src.git
.Pp
Check out a work tree from this Git repository to /usr/src:
.Pp
.Dl $ got checkout /var/git/src.git /usr/src
.Pp
View local changes in a work tree directory:
.Pp
.Dl $ got status
.Dl $ got diff | less
.Pp
In a work tree or a git repository directory, list all branch references:
.Pp
.Dl $ got ref -l | grep ^refs/heads
.Pp
In a work tree or a git repository directory, create a new branch called
.Dq unified-buffer-cache
which is forked off the
.Dq master
branch:
.Pp
.Dl $ got ref refs/heads/unified-buffer-cache refs/heads/master
.Pp
Switch an existing work tree to the branch
.Dq unified-buffer-cache .
Local changes in the work tree will be preserved and merged if necessary:
.Pp
.Dl $ got update -b unified-buffer-cache
.Pp
Create a new commit from local changes in a work tree directory.
This new commit will become the head commit of the work tree's current branch:
.Pp
.Dl $ got commit
.Pp
In a work tree or a git repository directory, view changes committed in
the 3 most recent commits to the work tree's branch, or the branch resolved
via the repository's HEAD reference, respectively:
.Pp
.Dl $ got log -p -l 3 -b
.Pp
Add new files and remove obsolete files in a work tree directory:
.Pp
.Dl $ got add sys/uvm/uvm_ubc.c
.Dl $ got rm sys/uvm/uvm_vnode.c
.Pp
Create a new commit from local changes in a work tree directory
with a pre-defined log message.
.Pp
.Dl $ got commit -m 'unify the buffer cache'
.Pp
Update any work tree checked out from the
.Dq unified-buffer-cache
branch to the latest commit on this branch:
.Pp
.Dl $ got update
.Pp
Fetch new upstream commits into the local repository's master branch:
.Pp
.Dl $ cd /var/git/src.git
.Dl $ git fetch origin master:master
.Pp
Rebase the
.Dq unified-buffer-cache
branch on top of the new head commit of the
.Dq master
branch.
This step currently requires
.Xr git 1 :
.Pp
.Dl $ git clone /var/git/src.git ~/src-git-wt
.Dl $ cd ~/src-git-wt
.Dl $ git checkout unified-buffer-cache
.Dl $ git rebase master
.Dl $ git push -f
.Pp
Update the work tree to the newly rebased
.Dq unified-buffer-cache
branch:
.Pp
.Dl $ got update -b unified-buffer-cache
.Sh SEE ALSO
.Xr git-repository 5
.Xr got-worktree 5
.Sh AUTHORS
.An Stefan Sperling Aq Mt stsp@openbsd.org
.An Martin Pieuchot Aq Mt mpi@openbsd.org
.An joshua stein Aq Mt jcs@openbsd.org
.Sh CAVEATS
.Nm
is a work-in-progress and many commands remain to be implemented.
At present, the user has to fall back on
.Xr git 1
to perform many basic tasks.
.Pp
When working against a repository created with
.Dq git clone --bare ,
local commits to the
.Dq master
branch are discouraged, for now, if changes committed to the upstream
repository need to be tracked.
See the EXAMPLES section.