Hash :
1dd86744
Author :
Date :
2019-08-11T12:14:47
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
.\"
.\" Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
.\"
.\" 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-WORKTREE 5
.Os
.Sh NAME
.Nm got-worktree
.Nd Got worktree format
.Sh DESCRIPTION
A Got
.Em work tree
stores a file hierarchy which corresponds to a versioned
snapshot stored in a Git repository.
The work tree's meta data is stored in the
.Pa .got
directory.
A work tree is created with
.Cm got checkout
and is required to make changes to a Git repository with
.Xr got 1 .
.Pp
A work tree stores the path to its Git repository, the name of a reference
to the branch which files were checked out from, and the ID of a commit on
this branch known as the
.Em base commit .
.Pp
File meta-data is stored in a structured file called the
.Em file index
which tracks the status of file modifications, additions, and deletions,
relative to the base commit in the repository.
The file index contains a series of records, and each such record contains
the following status information for a particular file:
.Bl -tag -width Ds
.It Copy of filesystem meta-data
Timestamp, file size, and file ownership information from
.Xr stat 2 .
This is only used to detect file modifications and is never applied
back to the filesystem.
File permissions are not tracked, except for the executable bit.
When versioned files are checked out into the work tree, the current
.Xr umask 2
is heeded.
.It Blob object ID
The SHA1 hash of the blob object which corresponds to the contents
of this file in the repository.
The hash is stored as binary data.
.It Commit object ID
The SHA1 hash of the commit object the file was checked out from.
The hash is stored as binary data.
This data is used to detect past incomplete update operations.
Entries which do not match the work tree's base commit may still need
to be updated to match file content stored in the base commit.
.It Flags
This field contains the length, according to
.Xr strlen 3 ,
of path data which follows, and the following flags:
.Bl -tag -width Ds
.It STAGE
Reflects the added, modified, or deleted staged state of a path staged with
.Cm got stage .
.It NOT_FLUSHED
The entry was added to the file index in memory and does not exist in file
index data read from disk.
This happens to files which are added to the work tree while operations
such as
.Cm got checkout ,
.Cm got update ,
.Cm got cherrypick ,
.Cm got backout ,
.Cm got rebase ,
and
.Cm got histedit
are in progress.
This flag is always cleared before the entry is written to disk.
.It NO_BLOB
The entry's on-disk file content in the work tree is not based on
a blob in the repository.
The blob object ID of this entry must be considered invalid.
This happens when unversioned files are added with
.Cm got add
and when files are added to the work tree by operations such as
.Cm got cherrypick ,
.Cm got backout ,
.Cm got rebase ,
and
.Cm got histedit .
.It NO_COMMIT
The entry is not based on a commit in the repository.
The commit object ID of this entry must be considered invalid.
This happens when unversioned files are added with
.Cm got add
and when files are added to the work tree by operations such as
.Cm got cherrypick ,
.Cm got backout ,
.Cm got rebase ,
and
.Cm got histedit .
.It NO_FILE_ON_DISK
The entry has no corresponding on-disk file in the work tree.
This happens when files are removed with
.Cm got remove .
.El
.It Path data
The path of the entry, relative to the work tree root.
Path data is of variable length and NUL-padded to a multiple of 8 bytes.
.It Staged blob object ID
The SHA1 hash of a blob object containing file content which has been
staged for commit.
The hash is stored as binary data.
Only present if a file addition or modification has been staged with
.Cm got stage .
.El
.Pp
A corrupt or missing file index can be recreated on demand with
.Cm got update .
When the file index is modified, it is read into memory in its entirety,
modified in place, and written to a temporary file.
This temporary file is then moved on top of the old file index with
.Xr rename 2 .
This ensures that no other processes see an inconsistent file index
which is in the process of being written.
.Pp
Work tree meta data must only be modified while the work tree's
.Pa lock
file has been exclusively locked with
.Xr lockf 3 .
.Pp
Each work tree has a universal unique identifier.
When a work tree is checked out or updated, this identifier is used to
create a reference to the current base commit in the Git repository.
The presence of this reference prevents Git garbage collectors from
discarding the base commit and any objects it refers to.
When a work tree is no longer needed its reference can be deleted from
the Git repository with
.Cm got ref -d .
.Sh FILES
.Bl -tag -width path-prefix -compact
.It Pa .got
Meta-data directory where all files listed below reside.
.It Pa base-commit
SHA1 hex-string representation of the current base commit.
.It Pa file-index
File status information.
.It Pa format
Work tree format number.
.It Pa head-ref
Name of the reference to the current branch.
.It Pa lock
Lock file to obtain exclusive write access to meta data.
.It Pa path-prefix
Path inside repository the work tree was checked out from.
.It Pa repository
Path to the repository the work tree was checked out from.
.It Pa uuid
A universal unique identifier for the work tree.
.El
.Sh SEE ALSO
.Xr got 1 ,
.Xr rename 2 ,
.Xr stat 2 ,
.Xr umask 2 ,
.Xr lockf 3 ,
.Xr git-repository 5