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 and 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 A flags field (intentionally not documented).
68 .It Path data
69 The path of the entry, relative to the work tree root.
70 Path data is of variable length and NUL-padded to a multiple of 8 bytes.
71 .El
72 .Pp
73 A corrupt or missing file index can be recreated on demand with
74 .Cm got update .
75 When the file index is modified, it is read into memory in its entirety,
76 modified in place, and written to a temporary file.
77 This temporary file is then moved on top of the old file index with
78 .Xr rename 2 .
79 This ensures that no other processes see an inconsistent file index
80 which is in the process of being written.
81 .Pp
82 Work tree meta data must only be modified while the work tree's
83 .Pa lock
84 file has been exclusively locked with
85 .Xr lockf 3 .
86 .Pp
87 Each work tree has a universal unique identifier.
88 When a work tree is checked out or updated, this identifier is used to
89 create a reference to the current base commit in the Git repository.
90 The presence of this reference prevents Git garbage collectors from
91 discarding the base commit and any objects it refers to.
92 When a work tree is no longer needed its reference can be deleted from
93 the Git repository with
94 .Cm got ref -d .
95 .Sh FILES
96 .Bl -tag -width path-prefix -compact
97 .It Pa .got
98 Meta-data directory where all files listed below reside.
99 .It Pa base-commit
100 SHA1 hex-string representation of the current base commit.
101 .It Pa file-index
102 File status information.
103 .It Pa format
104 Work tree format number.
105 .It Pa head-ref
106 Name of the reference to the current branch.
107 .It Pa lock
108 Lock file to obtain exclusive write access to meta data.
109 .It Pa path-prefix
110 Path inside repository the work tree was checked out from.
111 .It Pa repository
112 Path to the repository the work tree was checked out from.
113 .It Pa uuid
114 A universal unique identifier for the work tree.
115 .El
116 .Sh SEE ALSO
117 .Xr got 1 ,
118 .Xr rename 2 ,
119 .Xr stat 2 ,
120 .Xr umask 2 ,
121 .Xr lockf 3 ,
122 .Xr git-repository 5