Skip to content

Commit 7325283

Browse files
Michael J Grubergitster
authored andcommitted
Documentation/git-read-tree: clarify 2-tree merge
Clarify the description of the 2-tree merge by defining the terms which are used in the table, and by applying some small linguistic changes. Signed-off-by: Michael J Gruber <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71928f7 commit 7325283

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

Documentation/git-read-tree.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Single Tree Merge
130130
~~~~~~~~~~~~~~~~~
131131
If only 1 tree is specified, 'git read-tree' operates as if the user did not
132132
specify `-m`, except that if the original index has an entry for a
133-
given pathname, and the contents of the path matches with the tree
133+
given pathname, and the contents of the path match with the tree
134134
being read, the stat info from the index is used. (In other words, the
135135
index's stat()s take precedence over the merged tree's).
136136

@@ -154,22 +154,24 @@ When two trees are specified, the user is telling 'git read-tree'
154154
the following:
155155

156156
1. The current index and work tree is derived from $H, but
157-
the user may have local changes in them since $H;
157+
the user may have local changes in them since $H.
158158

159159
2. The user wants to fast-forward to $M.
160160

161161
In this case, the `git read-tree -m $H $M` command makes sure
162162
that no local change is lost as the result of this "merge".
163-
Here are the "carry forward" rules:
163+
Here are the "carry forward" rules, where "I" denotes the index,
164+
"clean" means that index and work tree coincide, and "exists"/"nothing"
165+
refer to the presence of a path in the specified commit:
164166

165-
I (index) H M Result
167+
I H M Result
166168
-------------------------------------------------------
167169
0 nothing nothing nothing (does not happen)
168170
1 nothing nothing exists use M
169171
2 nothing exists nothing remove path from index
170-
3 nothing exists exists, use M if "initial checkout"
172+
3 nothing exists exists, use M if "initial checkout",
171173
H == M keep index otherwise
172-
exists fail
174+
exists, fail
173175
H != M
174176

175177
clean I==H I==M
@@ -187,7 +189,7 @@ Here are the "carry forward" rules:
187189
12 yes no N/A exists nothing fail
188190
13 no no N/A exists nothing fail
189191

190-
clean (H=M)
192+
clean (H==M)
191193
------
192194
14 yes exists exists keep index
193195
15 no exists exists keep index
@@ -202,26 +204,26 @@ Here are the "carry forward" rules:
202204
21 no yes no exists exists fail
203205

204206
In all "keep index" cases, the index entry stays as in the
205-
original index file. If the entry were not up to date,
207+
original index file. If the entry is not up to date,
206208
'git read-tree' keeps the copy in the work tree intact when
207209
operating under the -u flag.
208210

209211
When this form of 'git read-tree' returns successfully, you can
210-
see what "local changes" you made are carried forward by running
212+
see which of the "local changes" that you made were carried forward by running
211213
`git diff-index --cached $M`. Note that this does not
212-
necessarily match `git diff-index --cached $H` would have
214+
necessarily match what `git diff-index --cached $H` would have
213215
produced before such a two tree merge. This is because of cases
214216
18 and 19 --- if you already had the changes in $M (e.g. maybe
215217
you picked it up via e-mail in a patch form), `git diff-index
216218
--cached $H` would have told you about the change before this
217219
merge, but it would not show in `git diff-index --cached $M`
218-
output after two-tree merge.
220+
output after the two-tree merge.
219221

220-
Case #3 is slightly tricky and needs explanation. The result from this
222+
Case 3 is slightly tricky and needs explanation. The result from this
221223
rule logically should be to remove the path if the user staged the removal
222224
of the path and then switching to a new branch. That however will prevent
223225
the initial checkout from happening, so the rule is modified to use M (new
224-
tree) only when the contents of the index is empty. Otherwise the removal
226+
tree) only when the content of the index is empty. Otherwise the removal
225227
of the path is kept as long as $H and $M are the same.
226228

227229
3-Way Merge

0 commit comments

Comments
 (0)