Blob


1 .\"
2 .\" Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 .\"
4 .\" Permission to use, copy, modify, and distribute this software for any
5 .\" purpose with or without fee is hereby granted, provided that the above
6 .\" copyright notice and this permission notice appear in all copies.
7 .\"
8 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 .\"
16 .Dd $Mdocdate$
17 .Dt GOT-WORKTREE 5
18 .Os
19 .Sh NAME
20 .Nm got-worktree
21 .Nd Got worktree format
22 .Sh DESCRIPTION
23 A Got
24 .Em work tree
25 stores a file hierarchy which corresponds to a versioned
26 snapshot stored in a Git repository.
27 The work tree's meta data is stored in the
28 .Pa .got
29 directory.
30 A work tree is created with
31 .Cm got checkout
32 and is required to make changes to a Git repository with
33 .Xr got 1 .
34 .Pp
35 A work tree stores the path to its Git repository, the name of a reference
36 to the branch which files were checked out from, and the ID of a commit on
37 this branch known as the
38 .Em base commit .
39 .Pp
40 File meta-data is stored in a structured file called the
41 .Em file index
42 which tracks the status of file modifications, additions, and deletions,
43 relative to the base commit in the repository.
44 The file index contains a series of records, and each such record contains
45 the following status information for a particular file:
46 .Bl -tag -width Ds
47 .It Copy of filesystem meta-data
48 Timestamp, file size, and file ownership information from
49 .Xr stat 2 .
50 This is only used to detect file modifications and is never applied
51 back to the filesystem.
52 File permissions are not tracked, except for the executable bit.
53 When versioned files are checked out into the work tree, the current
54 .Xr umask 2
55 is heeded.
56 .It Blob object ID
57 The SHA1 hash of the blob object which corresponds to the contents
58 of this file in the repository.
59 The hash is stored as binary data.
60 .It Commit object ID
61 The SHA1 hash of the commit object the file was checked out from.
62 The hash is stored as binary data.
63 This data is used to detect past incomplete update operations.
64 Entries which do not match the work tree's base commit may still need
65 to be updated to match file content stored in the base commit.
66 .It Flags
67 This field contains the length, according to
68 .Xr strlen 3 ,
69 of path data which follows, and the following flags:
70 .Bl -tag -width Ds
71 .It STAGE
72 Reflects the added, modified, or deleted staged state of a path staged with
73 .Cm got stage .
74 .It NOT_FLUSHED
75 The entry was added to the file index in memory and does not exist in file
76 index data read from disk.
77 This happens to files which are added to the work tree while operations
78 such as
79 .Cm got checkout ,
80 .Cm got update ,
81 .Cm got cherrypick ,
82 .Cm got backout ,
83 .Cm got rebase ,
84 and
85 .Cm got histedit
86 are in progress.
87 This flag is always cleared before the entry is written to disk.
88 .It NO_BLOB
89 The entry's on-disk file content in the work tree is not based on
90 a blob in the repository.
91 The blob object ID of this entry must be considered invalid.
92 This happens when unversioned files are added with
93 .Cm got add
94 and when files are added to the work tree by operations such as
95 .Cm got cherrypick ,
96 .Cm got backout ,
97 .Cm got rebase ,
98 and
99 .Cm got histedit .
100 .It NO_COMMIT
101 The entry is not based on a commit in the repository.
102 The commit object ID of this entry must be considered invalid.
103 This happens when unversioned files are added with
104 .Cm got add
105 and when files are added to the work tree by operations such as
106 .Cm got cherrypick ,
107 .Cm got backout ,
108 .Cm got rebase ,
109 and
110 .Cm got histedit .
111 .It NO_FILE_ON_DISK
112 The entry has no corresponding on-disk file in the work tree.
113 This happens when files are removed with
114 .Cm got remove .
115 .El
116 .It Path data
117 The path of the entry, relative to the work tree root.
118 Path data is of variable length and NUL-padded to a multiple of 8 bytes.
119 .It Staged blob object ID
120 The SHA1 hash of a blob object containing file content which has been
121 staged for commit.
122 The hash is stored as binary data.
123 Only present if a file addition or modification has been staged with
124 .Cm got stage .
125 .El
126 .Pp
127 A corrupt or missing file index can be recreated on demand with
128 .Cm got update .
129 When the file index is modified, it is read into memory in its entirety,
130 modified in place, and written to a temporary file.
131 This temporary file is then moved on top of the old file index with
132 .Xr rename 2 .
133 This ensures that no other processes see an inconsistent file index
134 which is in the process of being written.
135 .Pp
136 Work tree meta data must only be modified while the work tree's
137 .Pa lock
138 file has been exclusively locked with
139 .Xr lockf 3 .
140 .Pp
141 Each work tree has a universal unique identifier.
142 When a work tree is checked out or updated, this identifier is used to
143 create a reference to the current base commit in the Git repository.
144 The presence of this reference prevents Git garbage collectors from
145 discarding the base commit and any objects it refers to.
146 When a work tree is no longer needed its reference can be deleted from
147 the Git repository with
148 .Cm got ref -d .
149 .Sh FILES
150 .Bl -tag -width path-prefix -compact
151 .It Pa .got
152 Meta-data directory where all files listed below reside.
153 .It Pa base-commit
154 SHA1 hex-string representation of the current base commit.
155 .It Pa file-index
156 File status information.
157 .It Pa format
158 Work tree format number.
159 .It Pa head-ref
160 Name of the reference to the current branch.
161 .It Pa lock
162 Lock file to obtain exclusive write access to meta data.
163 .It Pa path-prefix
164 Path inside repository the work tree was checked out from.
165 .It Pa repository
166 Path to the repository the work tree was checked out from.
167 .It Pa uuid
168 A universal unique identifier for the work tree.
169 .El
170 .Sh SEE ALSO
171 .Xr got 1 ,
172 .Xr rename 2 ,
173 .Xr stat 2 ,
174 .Xr umask 2 ,
175 .Xr lockf 3 ,
176 .Xr git-repository 5