Skip to content

Commit 0899beb

Browse files
committed
Merge branch 'pb/complete-and-document-auto-merge-and-friends'
Document more pseudo-refs and teach the command line completion machinery to complete AUTO_MERGE. * pb/complete-and-document-auto-merge-and-friends: completion: complete AUTO_MERGE Documentation: document AUTO_MERGE git-merge.txt: modernize word choice in "True merge" section completion: complete REVERT_HEAD and BISECT_HEAD revisions.txt: document more special refs revisions.txt: use description list for special refs
2 parents 693bde4 + 982ff3a commit 0899beb

File tree

5 files changed

+79
-20
lines changed

5 files changed

+79
-20
lines changed

Documentation/git-diff.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ If --merge-base is given, use the merge base of the two commits for the
102102
Just in case you are doing something exotic, it should be
103103
noted that all of the <commit> in the above description, except
104104
in the `--merge-base` case and in the last two forms that use `..`
105-
notations, can be any <tree>.
105+
notations, can be any <tree>. A tree of interest is the one pointed to
106+
by the special ref `AUTO_MERGE`, which is written by the 'ort' merge
107+
strategy upon hitting merge conflicts (see linkgit:git-merge[1]).
108+
Comparing the working tree with `AUTO_MERGE` shows changes you've made
109+
so far to resolve textual conflicts (see the examples below).
106110

107111
For a more complete list of ways to spell <commit>, see
108112
"SPECIFYING REVISIONS" section in linkgit:gitrevisions[7].
@@ -152,13 +156,16 @@ Various ways to check your working tree::
152156
$ git diff <1>
153157
$ git diff --cached <2>
154158
$ git diff HEAD <3>
159+
$ git diff AUTO_MERGE <4>
155160
------------
156161
+
157162
<1> Changes in the working tree not yet staged for the next commit.
158163
<2> Changes between the index and your last commit; what you
159164
would be committing if you run `git commit` without `-a` option.
160165
<3> Changes in the working tree since your last commit; what you
161166
would be committing if you run `git commit -a`
167+
<4> Changes in the working tree you've made to resolve textual
168+
conflicts so far.
162169

163170
Comparing with arbitrary commits::
164171
+

Documentation/git-merge.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,13 @@ happens:
194194
versions: stage 1 stores the version from the common ancestor,
195195
stage 2 from `HEAD`, and stage 3 from `MERGE_HEAD` (you
196196
can inspect the stages with `git ls-files -u`). The working
197-
tree files contain the result of the "merge" program; i.e. 3-way
197+
tree files contain the result of the merge operation; i.e. 3-way
198198
merge results with familiar conflict markers `<<<` `===` `>>>`.
199-
5. No other changes are made. In particular, the local
199+
5. A special ref `AUTO_MERGE` is written, pointing to a tree
200+
corresponding to the current content of the working tree (including
201+
conflict markers for textual conflicts). Note that this ref is only
202+
written when the 'ort' merge strategy is used (the default).
203+
6. No other changes are made. In particular, the local
200204
modifications you had before you started merge will stay the
201205
same and the index entries for them stay as they were,
202206
i.e. matching `HEAD`.
@@ -336,7 +340,8 @@ You can work through the conflict with a number of tools:
336340

337341
* Look at the diffs. `git diff` will show a three-way diff,
338342
highlighting changes from both the `HEAD` and `MERGE_HEAD`
339-
versions.
343+
versions. `git diff AUTO_MERGE` will show what changes you've
344+
made so far to resolve textual conflicts.
340345

341346
* Look at the diffs from each branch. `git log --merge -p <path>`
342347
will show diffs first for the `HEAD` version and then the

Documentation/revisions.txt

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ characters and to avoid word splitting.
3030
explicitly say 'heads/master' to tell Git which one you mean.
3131
When ambiguous, a '<refname>' is disambiguated by taking the
3232
first match in the following rules:
33-
33+
+
3434
. If '$GIT_DIR/<refname>' exists, that is what you mean (this is usually
35-
useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD`, `MERGE_HEAD`
36-
and `CHERRY_PICK_HEAD`);
35+
useful only for `HEAD`, `FETCH_HEAD`, `ORIG_HEAD`, `MERGE_HEAD`,
36+
`REBASE_HEAD`, `REVERT_HEAD`, `CHERRY_PICK_HEAD`, `BISECT_HEAD`
37+
and `AUTO_MERGE`);
3738

3839
. otherwise, 'refs/<refname>' if it exists;
3940

@@ -44,19 +45,38 @@ characters and to avoid word splitting.
4445
. otherwise, 'refs/remotes/<refname>' if it exists;
4546

4647
. otherwise, 'refs/remotes/<refname>/HEAD' if it exists.
48+
4749
+
48-
`HEAD` names the commit on which you based the changes in the working tree.
49-
`FETCH_HEAD` records the branch which you fetched from a remote repository
50-
with your last `git fetch` invocation.
51-
`ORIG_HEAD` is created by commands that move your `HEAD` in a drastic
52-
way (`git am`, `git merge`, `git rebase`, `git reset`),
53-
to record the position of the `HEAD` before their operation, so that
54-
you can easily change the tip of the branch back to the state before you ran
55-
them.
56-
`MERGE_HEAD` records the commit(s) which you are merging into your branch
57-
when you run `git merge`.
58-
`CHERRY_PICK_HEAD` records the commit which you are cherry-picking
59-
when you run `git cherry-pick`.
50+
`HEAD`:::
51+
names the commit on which you based the changes in the working tree.
52+
`FETCH_HEAD`:::
53+
records the branch which you fetched from a remote repository with
54+
your last `git fetch` invocation.
55+
`ORIG_HEAD`:::
56+
is created by commands that move your `HEAD` in a drastic way (`git
57+
am`, `git merge`, `git rebase`, `git reset`), to record the position
58+
of the `HEAD` before their operation, so that you can easily change
59+
the tip of the branch back to the state before you ran them.
60+
`MERGE_HEAD`:::
61+
records the commit(s) which you are merging into your branch when you
62+
run `git merge`.
63+
`REBASE_HEAD`:::
64+
during a rebase, records the commit at which the operation is
65+
currently stopped, either because of conflicts or an `edit` command in
66+
an interactive rebase.
67+
`REVERT_HEAD`:::
68+
records the commit which you are reverting when you run `git revert`.
69+
`CHERRY_PICK_HEAD`:::
70+
records the commit which you are cherry-picking when you run `git
71+
cherry-pick`.
72+
`BISECT_HEAD`:::
73+
records the current commit to be tested when you run `git bisect
74+
--no-checkout`.
75+
`AUTO_MERGE`:::
76+
records a tree object corresponding to the state the
77+
'ort' merge strategy wrote to the working tree when a merge operation
78+
resulted in conflicts.
79+
6080
+
6181
Note that any of the 'refs/*' cases above may come either from
6282
the `$GIT_DIR/refs` directory or from the `$GIT_DIR/packed-refs` file.

Documentation/user-manual.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,33 @@ $ git diff -3 file.txt # diff against stage 3
13431343
$ git diff --theirs file.txt # same as the above.
13441344
-------------------------------------------------
13451345

1346+
When using the 'ort' merge strategy (the default), before updating the working
1347+
tree with the result of the merge, Git writes a special ref named AUTO_MERGE
1348+
reflecting the state of the tree it is about to write. Conflicted paths with
1349+
textual conflicts that could not be automatically merged are written to this
1350+
tree with conflict markers, just as in the working tree. AUTO_MERGE can thus be
1351+
used with linkgit:git-diff[1] to show the changes you've made so far to resolve
1352+
conflicts. Using the same example as above, after resolving the conflict we
1353+
get:
1354+
1355+
-------------------------------------------------
1356+
$ git diff AUTO_MERGE
1357+
diff --git a/file.txt b/file.txt
1358+
index cd10406..8bf5ae7 100644
1359+
--- a/file.txt
1360+
+++ b/file.txt
1361+
@@ -1,5 +1 @@
1362+
-<<<<<<< HEAD:file.txt
1363+
-Hello world
1364+
-=======
1365+
-Goodbye
1366+
->>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt
1367+
+Goodbye world
1368+
-------------------------------------------------
1369+
1370+
Notice that the diff shows we deleted the conflict markers and both versions of
1371+
the content line, and wrote "Goodbye world" instead.
1372+
13461373
The linkgit:git-log[1] and linkgit:gitk[1] commands also provide special help
13471374
for merges:
13481375

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ __git_refs ()
767767
track=""
768768
;;
769769
*)
770-
for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD; do
770+
for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD REVERT_HEAD BISECT_HEAD AUTO_MERGE; do
771771
case "$i" in
772772
$match*|$umatch*)
773773
if [ -e "$dir/$i" ]; then

0 commit comments

Comments
 (0)