root refs vs pseudorefs
cover root refs vs pseudorefs
Since 993d57eded (refs: pseudorefs are no refs, 2024-05-15), the term "pseudoref" has been restricted to FETCH_HEAD and MERGE_HEAD, which are not stored in the ref backends, while other refs outside of "refs/", such as HEAD and ORIG_HEAD, are called root refs. However, a fair number of docs, comments, messages and tests still use "pseudoref" in its old sense. And while the glossary describes the rules for refs in the root of the hierarchy, it does not explicitly define the term, even though "git for-each-ref --include-root-refs" uses it.
This series adds a "root ref" entry to the glossary and clarifies the "pseudoref" entry, and then replaces the outdated uses of "pseudoref" in docs, code and tests. While at it, it also updates the long outdated glossary entry for per-worktree refs, and fixes a few inaccuracies found along the way, for example about which refs get a reflog in git-update-ref(1) and core.logAllRefUpdates.
I've left __git_pseudoref_exists() in the completion script alone apart from its comment, even though it's used for both pseudorefs and root refs. It could be renamed, keeping the old name as a deprecated wrapper like elsewhere in the script, but it's not obvious what to, because there is no term covering both.
Andy Koppe (5):
doc: glossary: add root ref and clarify pseudorefs
doc: glossary: update per-worktree refs
doc: stop calling root refs pseudorefs
refs: stop calling root refs pseudorefs
t: stop calling root refs pseudorefs
Documentation/config/core.adoc | 2 +-
Documentation/for-each-ref-options.adoc | 2 +-
Documentation/git-ls-remote.adoc | 4 +-
Documentation/git-update-ref.adoc | 13 ++-
Documentation/git-worktree.adoc | 9 +-
Documentation/glossary-content.adoc | 86 ++++++++++++-------
Documentation/rev-list-options.adoc | 4 +-
builtin/for-each-ref.c | 2 +-
contrib/completion/git-completion.bash | 7 +-
refs.h | 13 ++-
revision.c | 2 +-
t/show-ref-exists-tests.sh | 4 +-
t/t0600-reffiles-backend.sh | 2 +-
t/t0610-reftable-basics.sh | 2 +-
t/t1400-update-ref.sh | 66 +++++++-------
t/t1403-show-ref.sh | 2 +-
t/t1460-refs-migrate.sh | 4 +-
t/t4013-diff-various.sh | 6 +-
...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +-
t/t6302-for-each-ref-filter.sh | 4 +-
t/t9902-completion.sh | 4 +-
21 files changed, 129 insertions(+), 111 deletions(-)
rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)base-commit: 7e34d8174dcda3435d1404c9a30bef46afe6c13e
Signature · 1 line
2.56.0
PATCH 1/5 doc: glossary: add root ref and clarify pseudorefs
The glossary describes refs in the root of the ref hierarchy, but does not actually name them "root refs", even though the term is used elsewhere, for example by "git for-each-ref --include-root-refs". It also defines pseudorefs as refs, yet is_root_ref() deliberately excludes them, as they are not stored or handled by the ref backends.
Add a "root ref" entry, moving the naming rules and the list of irregular root refs there from the "ref" entry. State that pseudorefs are not root refs, and refer to gitrevisions(7) for descriptions of commonly used root refs and pseudorefs.
Reword the "pseudoref" entry so that it no longer calls them refs, add git-for-each-ref(1) as another example of how they are not proper refs, and explain that using a pseudoref containing multiple object IDs yields the first one.
--- Documentation/glossary-content.adoc | 68 +++++++++++++++++------------ 1 file changed, 41 insertions(+), 27 deletions(-)
Documentation/glossary-content.adoc +41 -27
@@ -500,9 +500,10 @@ exclude;; unusual refs. [[def_pseudoref]]pseudoref:: - A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to + <<def_object,objects>>, but that is not stored in the same way as refs. + For example, pseudorefs cannot be written by linkgit:git-update-ref[1] + or listed by linkgit:git-for-each-ref[1]. + The following pseudorefs are known to Git:
@@ -512,6 +513,9 @@ The following pseudorefs are known to Git: - `MERGE_HEAD` is written by linkgit:git-merge[1] when resolving merge conflicts. It contains all commit IDs which are being merged. ++ +When a pseudoref contains more than one object ID, using it to refer to an +object yields the first one. [[def_pull]]pull:: Pulling a <<def_branch,branch>> means to <<def_fetch,fetch>> it and
@@ -562,33 +566,12 @@ The following pseudorefs are known to Git: + The ref namespace is hierarchical. Ref names must either start with `refs/` or be located in the root of -the hierarchy. For the latter, their name must follow these rules: -+ --- - - The name consists of only upper-case characters or underscores. - - - The name ends with "`_HEAD`" or is equal to "`HEAD`". --- -+ -There are some irregular refs in the root of the hierarchy that do not -match these rules. The following list is exhaustive and shall not be -extended in the future: -+ --- - - `AUTO_MERGE` - - - `BISECT_EXPECTED_REV` - - - `NOTES_MERGE_PARTIAL` - - - `NOTES_MERGE_REF` - - - `MERGE_AUTOSTASH` --- +the hierarchy, in which case they must follow the naming rules for +<<def_root_ref,root refs>>. + Different subhierarchies are used for different purposes. For example, the `refs/heads/` hierarchy is used to represent local branches whereas -the `refs/tags/` hierarchy is used to represent local tags.. +the `refs/tags/` hierarchy is used to represent local tags. + See also "REFERENCES" in linkgit:gitdatamodel[7].
@@ -640,6 +623,37 @@ format. See linkgit:git-reflog[1] for details. To throw away part of the development, i.e. to assign the <<def_head,head>> to an earlier <<def_revision,revision>>. +[[def_root_ref]]root ref:: + A <<def_ref,ref>> located in the root of the ref hierarchy, outside + `refs/`. Root ref names must follow these rules: ++ +-- + - The name consists of only upper-case characters or underscores. + + - The name ends with "`_HEAD`" or is equal to "`HEAD`". +-- ++ +The following irregular root refs are exceptions to these rules. This +list is exhaustive and shall not be extended in future: ++ +-- + - `AUTO_MERGE` + + - `BISECT_EXPECTED_REV` + + - `NOTES_MERGE_PARTIAL` + + - `NOTES_MERGE_REF` + + - `MERGE_AUTOSTASH` +-- ++ +<<def_pseudoref,Pseudorefs>> are not considered root refs, even though +they follow the naming rules. ++ +See linkgit:gitrevisions[7] for descriptions of commonly used root refs +and pseudorefs. + [[def_SCM]]SCM:: Source code management (tool).
Signature · 1 line
2.56.0
Re: [PATCH 1/5] doc: glossary: add root ref and clarify pseudorefs
Quoted 26 lines · Andy Koppe
The glossary describes refs in the root of the ref hierarchy, but does not actually name them "root refs", even though the term is used elsewhere, for example by "git for-each-ref --include-root-refs". It also defines pseudorefs as refs, yet
is_root_ref()deliberately excludes them, as they are not stored or handled by the ref backends.Add a "root ref" entry, moving the naming rules and the list of irregular root refs there from the "ref" entry. State that pseudorefs are not root refs, and refer to gitrevisions(7) for descriptions of commonly used root refs and pseudorefs.
Reword the "pseudoref" entry so that it no longer calls them refs, add git-for-each-ref(1) as another example of how they are not proper refs, and explain that using a pseudoref containing multiple object IDs yields the first one.
Signed-off-by Andy Koppe <[email protected]>--- Documentation/glossary-content.adoc | 68 +++++++++++++++++------------ 1 file changed, 41 insertions(+), 27 deletions(-)Documentation/glossary-content.adoc +0
-0
Documentation/glossary-content.adoc exclude;; · line 506
Quoted 10 lines
Documentation/glossary-content.adoc +4
-3@@ -500,9 +500,10 @@ exclude;; unusual refs. [[def_pseudoref]]pseudoref:: - A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to + <<def_object,objects>>, but that is not stored in the same way as refs. + For example, pseudorefs cannot be written by linkgit:git-update-ref[1] + or listed by linkgit:git-for-each-ref[1].
I would love to get input from Patrick who wrote 993d57eded (refs:
pseudorefs are no refs, 2024-05-15), as I consider that the loss of "different semantics" from this description is a rather serious one. FETCH_HEAD and MERGE_HEAD cannot be written with update-ref simply because it is normal for them to record multiple object names, so it is not just "how" they are stored, but also "what" they can store, that makes them "strange", "pseudo", "different", and "special".
Documentation/glossary-content.adoc The following pseudorefs are known to Git: · line 518
Quoted 9 lines
Documentation/glossary-content.adoc +3
-0The following pseudorefs are known to Git:@@ -512,6 +513,9 @@ The following pseudorefs are known to Git: - `MERGE_HEAD` is written by linkgit:git-merge[1] when resolving merge conflicts. It contains all commit IDs which are being merged. ++ +When a pseudoref contains more than one object ID, using it to refer to an +object yields the first one.
This is an important addition.
Quoted 38 lines
Documentation/glossary-content.adoc +23
-1@@ -562,33 +566,12 @@ The following pseudorefs are known to Git: + The ref namespace is hierarchical. Ref names must either start with `refs/` or be located in the root of +the hierarchy, in which case they must follow the naming rules for +<<def_root_ref,root refs>>. + Different subhierarchies are used for different purposes. For example, the `refs/heads/` hierarchy is used to represent local branches whereas -the `refs/tags/` hierarchy is used to represent local tags.. +the `refs/tags/` hierarchy is used to represent local tags. + See also "REFERENCES" in linkgit:gitdatamodel[7].@@ -640,6 +623,37 @@ format. See linkgit:git-reflog[1] for details. To throw away part of the development, i.e. to assign the <<def_head,head>> to an earlier <<def_revision,revision>>. +[[def_root_ref]]root ref:: + A <<def_ref,ref>> located in the root of the ref hierarchy, outside + `refs/`. Root ref names must follow these rules: ++ +-- + - The name consists of only upper-case characters or underscores. + + - The name ends with "`_HEAD`" or is equal to "`HEAD`". +-- ++ +The following irregular root refs are exceptions to these rules. This +list is exhaustive and shall not be extended in future: ++ +-- + - `AUTO_MERGE` + + - `BISECT_EXPECTED_REV` + + - `NOTES_MERGE_PARTIAL` +
Documentation/glossary-content.adoc format. See linkgit:git-reflog[1] for details. · line 655
Quoted 10 lines
Documentation/glossary-content.adoc +10
-0+ - `NOTES_MERGE_REF` + + - `MERGE_AUTOSTASH` +-- ++ +<<def_pseudoref,Pseudorefs>> are not considered root refs, even though +they follow the naming rules. ++ +See linkgit:gitrevisions[7] for descriptions of commonly used root refs +and pseudorefs.
I think this is a great reorganization to split out the "these are exceptions" into its own section.
Re: [PATCH 1/5] doc: glossary: add root ref and clarify pseudorefs
In reply to Andy KoppeQuoted 5 lines · Andy Koppe
Documentation/glossary-content.adoc +0
-0
Documentation/glossary-content.adoc exclude;; · line 506
Quoted 10 lines
Documentation/glossary-content.adoc +4
-3@@ -500,9 +500,10 @@ exclude;; unusual refs. [[def_pseudoref]]pseudoref:: - A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to + <<def_object,objects>>, but that is not stored in the same way as refs. + For example, pseudorefs cannot be written by linkgit:git-update-ref[1] + or listed by linkgit:git-for-each-ref[1].
As Junio already mentioned, I think we should retain the information about different semantics.
I also think that the previous guidance around how pseudorefs can be used is weakened, because now you only list examples of how they cannot be used. Previously though we explicitly specified that the only supported operation is reading the refs directly. So instead of giving examples of how they cannot be used, I think we should continue to list the few operations that _are_ possible.
Documentation/glossary-content.adoc The following pseudorefs are known to Git: · line 518
Quoted 7 lines
Documentation/glossary-content.adoc +3
-0@@ -512,6 +513,9 @@ The following pseudorefs are known to Git: - `MERGE_HEAD` is written by linkgit:git-merge[1] when resolving merge conflicts. It contains all commit IDs which are being merged. ++ +When a pseudoref contains more than one object ID, using it to refer to an +object yields the first one.
This is indeed a good addition.
Documentation/glossary-content.adoc format. See linkgit:git-reflog[1] for details. · line 626
Quoted 5 lines
Documentation/glossary-content.adoc +1
-0@@ -640,6 +623,37 @@ format. See linkgit:git-reflog[1] for details. To throw away part of the development, i.e. to assign the <<def_head,head>> to an earlier <<def_revision,revision>>. +[[def_root_ref]]root ref::
And splitting this out makes sense, as well.
Documentation/glossary-content.adoc format. See linkgit:git-reflog[1] for details. · line 637
Quoted 11 lines
Documentation/glossary-content.adoc +11
-0+ A <<def_ref,ref>> located in the root of the ref hierarchy, outside + `refs/`. Root ref names must follow these rules: ++ +-- + - The name consists of only upper-case characters or underscores. + + - The name ends with "`_HEAD`" or is equal to "`HEAD`". +-- ++ +The following irregular root refs are exceptions to these rules. This +list is exhaustive and shall not be extended in future:
Okay, this paragraph has been shortened a bit, which I think is a good change.
Thanks!
Patrick
Re: [PATCH 1/5] doc: glossary: add root ref and clarify pseudorefs
Quoted 20 lines · Patrick Steinhardt
Quoted 5 lines · Andy Koppe
Documentation/glossary-content.adoc +0
-0Documentation/glossary-content.adoc exclude;; · line 506
Quoted 10 lines
Documentation/glossary-content.adoc +4
-3@@ -500,9 +500,10 @@ exclude;; unusual refs. [[def_pseudoref]]pseudoref:: - A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to + <<def_object,objects>>, but that is not stored in the same way as refs. + For example, pseudorefs cannot be written by linkgit:git-update-ref[1] + or listed by linkgit:git-for-each-ref[1].As Junio already mentioned, I think we should retain the information about different semantics.
Quoted 6 lines
I also think that the previous guidance around how pseudorefs can be used is weakened, because now you only list examples of how they cannot be used. Previously though we explicitly specified that the only supported operation is reading the refs directly. So instead of giving examples of how they cannot be used, I think we should continue to list the few operations that _are_ possible.
Instead of saying that they are different, I tried to describe how they are different . But, yep, I struggled a bit with that.
In v2, I have added git-log and git-diff as examples of where pseudorefs can be used like references.
Thanks,
Andy
PATCH 2/5 doc: glossary: update per-worktree refs
In reply to Andy KoppeThe "per-worktree ref" entry says that these are only HEAD and refs under "refs/bisect/", but that has been out of date since a9be29c981 (sequencer: make refs generated by the label command worktree-local, 2018-04-25). All root refs are per-worktree, as are refs under "refs/worktree/" and "refs/rewritten/". Pseudorefs are specific to each worktree too.
Bring the list up to date, and refer to git-worktree(1) for how to access per-worktree refs of other worktrees. In the "worktree" entry, describe HEAD as a per-worktree ref and MERGE_HEAD as a pseudoref, rather than listing them separately from per-worktree refs.
--- Documentation/glossary-content.adoc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
Documentation/glossary-content.adoc +12 -6
@@ -494,10 +494,16 @@ exclude;; interface than the <<def_plumbing,plumbing>>. [[def_per_worktree_ref]]per-worktree ref:: - Refs that are per-<<def_worktree,worktree>>, rather than - global. This is presently only <<def_HEAD,HEAD>> and any refs - that start with `refs/bisect/`, but might later include other - unusual refs. + A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>, + rather than shared between all worktrees. All + <<def_root_ref,root refs>>, such as <<def_HEAD,HEAD>>, are + per-worktree, as are refs that start with `refs/bisect/`, + `refs/worktree/` or `refs/rewritten/`. ++ +<<def_pseudoref,Pseudorefs>> are also specific to each worktree. ++ +See "REFS" in linkgit:git-worktree[1] for how to access the +per-worktree refs of other worktrees. [[def_pseudoref]]pseudoref:: A name that can be used like a <<def_ref,ref>> to refer to
@@ -788,5 +794,5 @@ and pseudorefs. "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree - (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, - per-worktree refs and per-worktree configuration file). + (e.g. the index, per-worktree refs such as HEAD, pseudorefs + such as MERGE_HEAD, and the per-worktree configuration file).
Signature · 1 line
2.56.0
Re: [PATCH 2/5] doc: glossary: update per-worktree refs
Quoted 9 lines · Andy Koppe
Documentation/glossary-content.adoc +0
-1@@ -494,10 +494,16 @@ exclude;; interface than the <<def_plumbing,plumbing>>. [[def_per_worktree_ref]]per-worktree ref:: - Refs that are per-<<def_worktree,worktree>>, rather than
Documentation/glossary-content.adoc exclude;; · line 503
Quoted 10 lines
Documentation/glossary-content.adoc +7
-3- global. This is presently only <<def_HEAD,HEAD>> and any refs - that start with `refs/bisect/`, but might later include other - unusual refs. + A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>, + rather than shared between all worktrees. All + <<def_root_ref,root refs>>, such as <<def_HEAD,HEAD>>, are + per-worktree, as are refs that start with `refs/bisect/`, + `refs/worktree/` or `refs/rewritten/`. ++ +<<def_pseudoref,Pseudorefs>> are also specific to each worktree.
Should we maybe also turn this into an itemized list? Makes it easier to see at a glance which rrefs are per-worktree, and it becomes easier to extend going forward.
Documentation/glossary-content.adoc and pseudorefs. · line 798
Quoted 13 lines
Documentation/glossary-content.adoc +4
-2+See "REFS" in linkgit:git-worktree[1] for how to access the +per-worktree refs of other worktrees. [[def_pseudoref]]pseudoref:: A name that can be used like a <<def_ref,ref>> to refer to@@ -788,5 +794,5 @@ and pseudorefs. "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree - (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, - per-worktree refs and per-worktree configuration file). + (e.g. the index, per-worktree refs such as HEAD, pseudorefs + such as MERGE_HEAD, and the per-worktree configuration file).
This is a bit curious as you distinguish between per-worktree refs and pseudorefs, even though you mention both of them as part of the per-worktree ref section. I wonder whether we should simply refer to that section without naming any examples.
Patrick
Re: [PATCH 2/5] doc: glossary: update per-worktree refs
Quoted 8 lines · Patrick Steinhardt
Quoted 7 lines · Andy Koppe
Documentation/glossary-content.adoc +0
-0@@ -494,10 +494,16 @@ exclude;; interface than the <<def_plumbing,plumbing>>.
Quoted 16 lines
Documentation/glossary-content.adoc exclude;; · line 503
Quoted 12 lines
Documentation/glossary-content.adoc +7
-4[[def_per_worktree_ref]]per-worktree ref:: - Refs that are per-<<def_worktree,worktree>>, rather than - global. This is presently only <<def_HEAD,HEAD>> and any refs - that start with `refs/bisect/`, but might later include other - unusual refs. + A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>, + rather than shared between all worktrees. All + <<def_root_ref,root refs>>, such as <<def_HEAD,HEAD>>, are + per-worktree, as are refs that start with `refs/bisect/`, + `refs/worktree/` or `refs/rewritten/`. ++ +<<def_pseudoref,Pseudorefs>> are also specific to each worktree.Should we maybe also turn this into an itemized list? Makes it easier to see at a glance which rrefs are per-worktree, and it becomes easier to extend going forward.
Done in v2.
Quoted 17 lines
Documentation/glossary-content.adoc and pseudorefs. · line 798
Quoted 13 lines
Documentation/glossary-content.adoc +4
-2+See "REFS" in linkgit:git-worktree[1] for how to access the +per-worktree refs of other worktrees. [[def_pseudoref]]pseudoref:: A name that can be used like a <<def_ref,ref>> to refer to@@ -788,5 +794,5 @@ and pseudorefs. "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree - (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, - per-worktree refs and per-worktree configuration file). + (e.g. the index, per-worktree refs such as HEAD, pseudorefs + such as MERGE_HEAD, and the per-worktree configuration file).This is a bit curious as you distinguish between per-worktree refs and pseudorefs, even though you mention both of them as part of the per-worktree ref section.
It's difficult, because pseudorefs are per-worktree, but they aren't refs. I thought they should still be mentioned under "per-worktree refs", without calling them refs.
Quoted 2 lines
I wonder whether we should simply refer to
that section without naming any examples.
Good idea. Done in v2.
Andy
PATCH 3/5 doc: stop calling root refs pseudorefs
In reply to Andy KoppeSeveral manual pages still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls a root ref. Pseudorefs have since been restricted to FETCH_HEAD and MERGE_HEAD, which are not considered root refs.
Replace "pseudoref" with "root ref" in those pages, giving HEAD and ORIG_HEAD as examples. In git-worktree(1), say that both root refs and pseudorefs are per-worktree, and drop the description of them as being directly under $GIT_DIR, because that does not apply to the reftable backend.
In git-ls-remote(1), describe --refs as omitting refs outside "refs/", since that is what it actually checks. In the example, refer to HEAD, which is the only root ref that git-upload-pack(1) advertises. While there, correct "symbolics" to "symbolic refs".
In git-update-ref(1), drop the incorrect mention of ORIG_HEAD. HEAD is the only root ref that gets a reflog by default. Also restructure the sentence to make it easier to parse.
In the description of core.logAllRefUpdates, correct the claim that "always" only applies to refs under "refs/". It applies to root refs too.
--- Documentation/config/core.adoc | 2 +- Documentation/for-each-ref-options.adoc | 2 +- Documentation/git-ls-remote.adoc | 4 ++-- Documentation/git-update-ref.adoc | 13 ++++++------- Documentation/git-worktree.adoc | 9 ++++----- Documentation/rev-list-options.adoc | 4 ++-- 6 files changed, 16 insertions(+), 18 deletions(-)
Documentation/config/core.adoc +1 -1
@@ -376,7 +376,7 @@ core.logAllRefUpdates:: `refs/heads/`), remote refs (i.e. under `refs/remotes/`), note refs (i.e. under `refs/notes/`), and the symbolic ref `HEAD`. If it is set to `always`, then a missing reflog is automatically - created for any ref under `refs/`. + created for any ref, including root refs such as `ORIG_HEAD`. + This information can be used to determine what commit was the tip of a branch "2 days ago".
Documentation/for-each-ref-options.adoc +1 -1
@@ -73,7 +73,7 @@ TAB %(refname)`. using the same rules as _<pattern>_ above. `--include-root-refs`:: - List root refs (`HEAD` and pseudorefs) apart from regular refs. + Also list root refs, such as `HEAD` or `ORIG_HEAD`. `--start-after=<marker>`:: Allows paginating the output by skipping references up to and including the
Documentation/git-ls-remote.adoc +2 -2
@@ -35,7 +35,7 @@ OPTIONS with other git subcommands. --refs:: - Do not show peeled tags or pseudorefs like `HEAD` in the output. + Do not show peeled tags or refs outside `refs/`. -q:: --quiet::
@@ -118,7 +118,7 @@ line shows the name of the object the tag points at. EXAMPLES -------- -* List all references (including symbolics and pseudorefs), peeling +* List all references (including `HEAD` and symbolic refs), peeling tags: + ----
Documentation/git-update-ref.adoc +6 -7
@@ -163,13 +163,12 @@ still see a subset of the modifications. LOGGING UPDATES --------------- -If config parameter "core.logAllRefUpdates" is true and the ref is one -under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref -like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then -`git update-ref` will append a line to the log file -"$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating -the log name) describing the change in ref value. Log lines are -formatted as: +If config parameter "core.logAllRefUpdates" is true and the ref is +HEAD or one under "refs/heads/", "refs/remotes/" or "refs/notes/", or +if the file "$GIT_DIR/logs/<ref>" exists, then `git update-ref` will +append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all +symbolic refs before creating the log name) describing the change in +ref value. Log lines are formatted as: oldsha1 SP newsha1 SP committer LF
Documentation/git-worktree.adoc +4 -5
@@ -303,11 +303,10 @@ but others are specific to an individual worktree. One example is `HEAD`, which is different for each worktree. This section is about the sharing rules and how to access refs of one worktree from another. -In general, all pseudo refs are per-worktree and all refs starting with -`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly -under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions, -however: refs inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are -not shared. +In general, all root refs and pseudorefs are per-worktree and all refs +starting with `refs/` are shared. There are exceptions, however: refs +inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are not +shared. Refs that are per-worktree can still be accessed from another worktree via two special paths, `main-worktree` and `worktrees`. The former gives
Documentation/rev-list-options.adoc +2 -2
@@ -350,8 +350,8 @@ Under `--pretty=reference`, this information will not be shown at all. `--merge`:: Show commits touching conflicted paths in the range `HEAD...<other>`, - where `<other>` is the first existing pseudoref in `MERGE_HEAD`, - `CHERRY_PICK_HEAD`, `REVERT_HEAD` or `REBASE_HEAD`. Only works + where `<other>` is the first of `MERGE_HEAD`, `CHERRY_PICK_HEAD`, + `REVERT_HEAD` or `REBASE_HEAD` that exists. Only works when the index has unmerged entries. This option can be used to show relevant commits when resolving conflicts from a 3-way merge.
Signature · 1 line
2.56.0
Re: [PATCH 3/5] doc: stop calling root refs pseudorefs
Quoted 8 lines · Andy Koppe
Documentation/git-update-ref.adoc +0
-0@@ -163,13 +163,12 @@ still see a subset of the modifications. LOGGING UPDATES ---------------
Documentation/git-update-ref.adoc still see a subset of the modifications. · line 168
Quoted 10 lines
Documentation/git-update-ref.adoc +3
-7-If config parameter "core.logAllRefUpdates" is true and the ref is one -under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref -like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then -`git update-ref` will append a line to the log file -"$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating -the log name) describing the change in ref value. Log lines are -formatted as: +If config parameter "core.logAllRefUpdates" is true and the ref is +HEAD or one under "refs/heads/", "refs/remotes/" or "refs/notes/", or +if the file "$GIT_DIR/logs/<ref>" exists, then `git update-ref` will
It's kind of hard to understand how the ANDs and ORs play together. Like, does the config parameter extend to all subsequent ORs? That's not really a new issue though.
Documentation/git-update-ref.adoc still see a subset of the modifications. · line 169
Quoted 1 line
Documentation/git-update-ref.adoc +1
-0+append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all
Also, this infomation about "$GIT_DIR/logs/<ref>" is out-of-date, as the reftable backend doesn't store its reflogs in there.
I wonder whether we should maybe just stop explaining how "core.logAllRefUpdates" works and instead refer to git-config(1).
Quoted 7 lines
Documentation/git-worktree.adoc +0
-0@@ -303,11 +303,10 @@ but others are specific to an individual worktree. One example is `HEAD`, which is different for each worktree. This section is about the sharing rules and how to access refs of one worktree from another.
Documentation/git-worktree.adoc but others are specific to an individual worktree. One example is `HEAD`, · line 309
Quoted 10 lines
Documentation/git-worktree.adoc +4
-5-In general, all pseudo refs are per-worktree and all refs starting with -`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly -under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions, -however: refs inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are -not shared. +In general, all root refs and pseudorefs are per-worktree and all refs +starting with `refs/` are shared. There are exceptions, however: refs +inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are not +shared.
It might make sense to have a bulleted list here, same as I proposed in a preceding patch.
Patrick
Re: [PATCH 3/5] doc: stop calling root refs pseudorefs
Quoted 24 lines · Patrick Steinhardt
Quoted 8 lines · Andy Koppe
Documentation/git-update-ref.adoc +0
-0@@ -163,13 +163,12 @@ still see a subset of the modifications. LOGGING UPDATES ---------------Documentation/git-update-ref.adoc still see a subset of the modifications. · line 168
Quoted 10 lines
Documentation/git-update-ref.adoc +3
-7-If config parameter "core.logAllRefUpdates" is true and the ref is one -under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref -like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then -`git update-ref` will append a line to the log file -"$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating -the log name) describing the change in ref value. Log lines are -formatted as: +If config parameter "core.logAllRefUpdates" is true and the ref is +HEAD or one under "refs/heads/", "refs/remotes/" or "refs/notes/", or +if the file "$GIT_DIR/logs/<ref>" exists, then `git update-ref` willIt's kind of hard to understand how the ANDs and ORs play together. Like, does the config parameter extend to all subsequent ORs? That's not really a new issue though.
Quoted 7 lines
Documentation/git-update-ref.adoc still see a subset of the modifications. · line 169
Quoted 1 line
Documentation/git-update-ref.adoc +1
-0+append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing allAlso, this infomation about "$GIT_DIR/logs/<ref>" is out-of-date, as the reftable backend doesn't store its reflogs in there.
I wonder whether we should maybe just stop explaining how "core.logAllRefUpdates" works and instead refer to git-config(1).
The whole LOGGING UPDATES section in git-update-ref(1) seems outdated as it assumes ref files and SHA-256, but I think that's out of scope of this patch series.
Quoted 8 lines
Quoted 8 lines
Documentation/git-worktree.adoc +0
-0@@ -303,11 +303,10 @@ but others are specific to an individual worktree. One example is `HEAD`, which is different for each worktree. This section is about the sharing rules and how to access refs of one worktree from another.
Quoted 12 lines
Documentation/git-worktree.adoc but others are specific to an individual worktree. One example is `HEAD`, · line 309
Quoted 9 lines
Documentation/git-worktree.adoc +4
-5-In general, all pseudo refs are per-worktree and all refs starting with -`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly -under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions, -however: refs inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are -not shared. +In general, all root refs and pseudorefs are per-worktree and all refs +starting with `refs/` are shared. There are exceptions, however: refs +inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are not +shared.It might make sense to have a bulleted list here, same as I proposed in a preceding patch.
Yep. Done in v2.
Andy
PATCH 4/5 refs: stop calling root refs pseudorefs
In reply to Andy KoppeSome messages and comments in the code still use "pseudoref" in its old sense of any ref outside of "refs/", whereas the glossary now calls those root refs and restricts pseudorefs to FETCH_HEAD and MERGE_HEAD.
Replace "pseudoref" with "root ref" in the help text for "git for-each-ref --include-root-refs", in comments in refs.h, and in comments in the bash completion script, including the one for __git_pseudoref_exists(), which is also used for root refs. The function itself is not renamed. There is no obvious term covering both root refs and pseudorefs, and the old name might need to be kept for third-party completion scripts.
Update the description of pseudorefs in refs.h to match the glossary.
--- builtin/for-each-ref.c | 2 +- contrib/completion/git-completion.bash | 7 ++++--- refs.h | 13 ++++++------- revision.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
builtin/for-each-ref.c +1 -1
@@ -48,7 +48,7 @@ int for_each_ref_core(int argc, const char **argv, const char *prefix, struct reOPT_NO_CONTAINS (&filter.no_commit,N_ ("print only refs which don't contain the commit" )),OPT_BOOL (0 ,"ignore-case" , &icase,N_ ("sorting and filtering are case insensitive" )),OPT_BOOL (0 ,"stdin" , &from_stdin,N_ ("read reference patterns from stdin" )), -OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include HEAD ref and pseudorefs" )), +OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include root refs" )), OPT_END(), };
contrib/completion/git-completion.bash +4 -3
@@ -147,8 +147,9 @@ __git_eread () test -r "$1" && IFS=$'\r\n' read -r "$2" <"$1" } -# Runs git in $__git_repo_path to determine whether a pseudoref exists. -# 1: The pseudo-ref to search +# Runs git in $__git_repo_path to determine whether a root ref or +# pseudoref exists. +# 1: The ref to check __git_pseudoref_exists () { local ref=$1
@@ -954,7 +955,7 @@ __git_refs () esac } -# Completes refs, short and long, local and remote, symbolic and pseudo. +# Completes refs, short and long, local and remote, symbolic, root and pseudo. # # Usage: __git_complete_refs [<option>]... # --remote=<remote>: The remote to list refs from, can be the name of a
refs.h +6 -7
@@ -85,7 +85,7 @@ enum ref_transaction_error {* Even with RESOLVE_REF_ALLOW_BAD_NAME, names that escape the refs/ * directory and do not consist of all caps and underscores cannot be * resolved. The function returns NULL for such ref names. -* Caps and underscores refers to the pseudorefs, such as HEAD, +* Caps and underscores refers to root refs and pseudorefs, such as HEAD, * FETCH_HEAD and friends, that all live outside of the refs/ directory. */ #define RESOLVE_REF_READING 0x01
@@ -448,8 +448,8 @@ enum refs_for_each_flag {REFS_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 <<2 ),/* -* Include root refs i.e. HEAD and pseudorefs along with the regular -* refs. +* Include root refs, such as HEAD and ORIG_HEAD, along with the +* regular refs. */ REFS_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3), };
@@ -1306,10 +1306,9 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref);int is_root_ref (const char *refname);/* -* Pseudorefs are refs that have different semantics compared to -* "normal" refs. These refs can thus not be stored in the ref backend, -* but must always be accessed via the filesystem. The following refs -* are pseudorefs: +* Pseudorefs are names that can be used like refs, but have different +* semantics. They cannot be stored in the ref backend, but must always +* be accessed via the filesystem. The following are pseudorefs: * * - FETCH_HEAD may contain multiple object IDs, and each one of them * carries additional metadata like where it came from.
revision.c +1 -1
@@ -2000,7 +2000,7 @@ static const char *lookup_other_head(struct object_id *oid)return other_head[i]; } -die (_ ("--merge requires one of the pseudorefs MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" )); +die (_ ("--merge requires one of MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" )); }static void prepare_show_merge (struct rev_info *revs)
Signature · 1 line
2.56.0
Re: [PATCH 4/5] refs: stop calling root refs pseudorefs
Quoted 8 lines · Andy Koppe
Some messages and comments in the code still use "pseudoref" in its old sense of any ref outside of "refs/", whereas the glossary now calls those root refs and restricts pseudorefs to
FETCH_HEADandMERGE_HEAD.Replace "pseudoref" with "root ref" in the help text for "git for-each-ref --include-root-refs", in comments in
refs.h, and in comments in the bash completion script, including the one for__git_pseudoref_exists(), which is also used for root refs.
I feel like this sentence is somewhat pointless, as you basically just explain the diff.
Quoted 4 lines
The function
itself is not renamed. There is no obvious term covering both root refs and pseudorefs, and the old name might need to be kept for third-party completion scripts.
This is useful though.
Quoted 1 line
Update the description of pseudorefs in
refs.hto match the glossary.
And this is again info that can simply be dropped.
Patrick
Re: [PATCH 4/5] refs: stop calling root refs pseudorefs
Quoted 6 lines · Patrick Steinhardt
Quoted 4 lines · Andy Koppe
Replace "pseudoref" with "root ref" in the help text for "git for-each-ref --include-root-refs", in comments in
refs.h, and in comments in the bash completion script, including the one for__git_pseudoref_exists(), which is also used for root refs.
Quoted 6 lines
I feel like this sentence is somewhat pointless, as you basically just explain the diff.
Quoted 1 line
Update the description of pseudorefs in
refs.hto match the glossary.And this is again info that can simply be dropped.
Fair. Dropped in v2.
Andy
PATCH 5/5 t: stop calling root refs pseudorefs
In reply to Andy KoppeSeveral test titles and comments still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls root refs.
Replace "pseudoref" with "root ref" there. In t1400 and t4013, rename the root refs that the tests create from PSEUDOREF to ROOT_REF_HEAD and from REVERSE to REVERSE_HEAD, so that they follow the naming rules for root refs. This includes renaming the expected output file in t4013.
Some tests also still refer to FETCH_HEAD and MERGE_HEAD as "special refs", which was the previous term for "pseudorefs". Correct them.
---
t/show-ref-exists-tests.sh | 4 +-
t/t0600-reffiles-backend.sh | 2 +-
t/t0610-reftable-basics.sh | 2 +-
t/t1400-update-ref.sh | 66 +++++++++----------
t/t1403-show-ref.sh | 2 +-
t/t1460-refs-migrate.sh | 4 +-
t/t4013-diff-various.sh | 6 +-
...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +-
t/t6302-for-each-ref-filter.sh | 4 +-
t/t9902-completion.sh | 4 +-
10 files changed, 48 insertions(+), 48 deletions(-)
rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)t/show-ref-exists-tests.sh +2 -2
@@ -64,11 +64,11 @@ test_expect_success '--exists with directory fails with generic error' ' test_cmp expect err ' -test_expect_success '--exists with non-existent special ref' ' +test_expect_success '--exists with non-existent pseudoref' ' test_expect_code 2 ${git_show_ref_exists} FETCH_HEAD ' -test_expect_success '--exists with existing special ref' ' +test_expect_success '--exists with existing pseudoref' ' test_when_finished "rm .git/FETCH_HEAD" && git rev-parse HEAD >.git/FETCH_HEAD && ${git_show_ref_exists} FETCH_HEAD
t/t0600-reffiles-backend.sh +1 -1
@@ -267,7 +267,7 @@ test_expect_success 'setup worktree' ' ) ' -# Some refs (refs/bisect/*, pseudorefs) are kept per worktree, so they should +# Some refs (refs/bisect/*, root refs) are kept per worktree, so they should # only appear in the for-each-reflog output if it is called from the correct # worktree, which is exercised in this test. This test is poorly written for # multiple reasons: 1) it creates invalidly formatted log entries. 2) it uses
t/t0610-reftable-basics.sh +1 -1
@@ -1156,7 +1156,7 @@ test_expect_success 'worktree: adds worktree with detached HEAD' ' test_cmp expect actual ' -test_expect_success 'fetch: accessing FETCH_HEAD special ref works' ' +test_expect_success 'fetch: accessing FETCH_HEAD pseudoref works' ' test_when_finished "rm -rf repo sub" && git init sub &&
t/t1400-update-ref.sh +33 -33
94 lines not on this page · raw message
t/t1403-show-ref.sh +1 -1
@@ -181,7 +181,7 @@ test_expect_success 'show-ref --verify HEAD' ' test_must_be_empty actual ' -test_expect_success 'show-ref --verify pseudorefs' ' +test_expect_success 'show-ref --verify root refs' ' git update-ref CHERRY_PICK_HEAD HEAD $ZERO_OID && test_when_finished "git update-ref -d CHERRY_PICK_HEAD" && git show-ref -s --verify HEAD >actual &&
t/t1460-refs-migrate.sh +2 -2
@@ -170,7 +170,7 @@ do test_cmp expect actual ' - test_expect_success "$from_format -> $to_format: pseudo-refs" ' + test_expect_success "$from_format -> $to_format: root refs" ' test_when_finished "rm -rf repo" && git init --ref-storage-format=$from_format repo && test_commit -C repo initial &&
@@ -178,7 +178,7 @@ do test_migration repo "$to_format" ' - test_expect_success "$from_format -> $to_format: special refs are left alone" ' + test_expect_success "$from_format -> $to_format: pseudorefs are left alone" ' test_when_finished "rm -rf repo" && git init --ref-storage-format=$from_format repo && test_commit -C repo initial &&
t/t4013-diff-various.sh +3 -3
@@ -115,10 +115,10 @@ test_expect_success setup ' git checkout -f main && # Same merge as main, but with parents reversed. Hide it in a - # pseudo-ref to avoid impacting tests with --all. + # root ref to avoid impacting tests with --all. commit=$(echo reverse | git commit-tree -p main^2 -p main^1 main^{tree}) && - git update-ref REVERSE $commit && + git update-ref REVERSE_HEAD $commit && git config diff.renames false &&
@@ -328,7 +328,7 @@ diff-tree --cc --stat --summary main diff-tree -c --stat --summary side diff-tree --cc --stat --summary side diff-tree --cc --shortstat main -diff-tree --cc --summary REVERSE +diff-tree --cc --summary REVERSE_HEAD # improved by Timo's patch diff-tree --cc --patch-with-stat main # improved by Timo's patch
t/t4013/diff.diff-tree_--cc_--summary_REVERSE_HEAD renamed from t/t4013/diff.diff-tree_--cc_--summary_REVERSE +1 -1
@@ -1,4 +1,4 @@ -$ git diff-tree --cc --summary REVERSE +$ git diff-tree --cc --summary REVERSE_HEAD 2562325a7ee916efb2481da93073b82cec801cbc create mode 100644 file1 delete mode 100644 file2
t/t6302-for-each-ref-filter.sh +2 -2
@@ -31,7 +31,7 @@ test_expect_success 'setup some history and refs' ' git update-ref refs/odd/spot main ' -test_expect_success '--include-root-refs pattern prints pseudorefs' ' +test_expect_success '--include-root-refs pattern prints root refs' ' cat >expect <<-\EOF && HEAD ORIG_HEAD
@@ -52,7 +52,7 @@ test_expect_success '--include-root-refs pattern prints pseudorefs' ' test_cmp expect actual ' -test_expect_success '--include-root-refs pattern does not print special refs' ' +test_expect_success '--include-root-refs pattern does not print pseudorefs' ' test_when_finished "rm -rf repo" && git init repo && (
t/t9902-completion.sh +2 -2
@@ -2693,13 +2693,13 @@ test_expect_success 'checkout matches case insensitively with GIT_COMPLETION_IGN ) ' -test_expect_success 'checkout completes pseudo refs' ' +test_expect_success 'checkout completes root refs' ' test_completion "git checkout H" <<-\EOF HEAD Z EOF ' -test_expect_success 'checkout completes pseudo refs case insensitively with GIT_COMPLETION_IGNORE_CASE' ' +test_expect_success 'checkout completes root refs case insensitively with GIT_COMPLETION_IGNORE_CASE' ' ( GIT_COMPLETION_IGNORE_CASE=1 && test_completion "git checkout h" <<-\EOF
Signature · 1 line
2.56.0
Quoted 8 lines · Andy Koppe
Since
993d57eded(refs: pseudorefs are no refs, 2024-05-15), the term "pseudoref" has been restricted toFETCH_HEADandMERGE_HEAD, which are not stored in the ref backends, while other refs outside of "refs/", such as HEAD andORIG_HEAD, are called root refs. However, a fair number of docs, comments, messages and tests still use "pseudoref" in its old sense. And while the glossary describes the rules for refs in the root of the hierarchy, it does not explicitly define the term, even though "git for-each-ref --include-root-refs" uses it.
Thanks. Overall this was a pleasant read.
Quoted 33 lines · Andy Koppe
Since
993d57eded(refs: pseudorefs are no refs, 2024-05-15), the term "pseudoref" has been restricted toFETCH_HEADandMERGE_HEAD, which are not stored in the ref backends, while other refs outside of "refs/", such as HEAD andORIG_HEAD, are called root refs. However, a fair number of docs, comments, messages and tests still use "pseudoref" in its old sense. And while the glossary describes the rules for refs in the root of the hierarchy, it does not explicitly define the term, even though "git for-each-ref --include-root-refs" uses it.This series adds a "root ref" entry to the glossary and clarifies the "pseudoref" entry, and then replaces the outdated uses of "pseudoref" in docs, code and tests. While at it, it also updates the long outdated glossary entry for per-worktree refs, and fixes a few inaccuracies found along the way, for example about which refs get a reflog in git-update-ref(1) and core.logAllRefUpdates.
I've left
__git_pseudoref_exists()in the completion script alone apart from its comment, even though it's used for both pseudorefs and root refs. It could be renamed, keeping the old name as a deprecated wrapper like elsewhere in the script, but it's not obvious what to, because there is no term covering both.Andy Koppe (5):
doc: glossary: add root ref and clarify pseudorefs
doc: glossary: update per-worktree refs
doc: stop calling root refs pseudorefs
refs: stop calling root refs pseudorefs
t: stop calling root refs pseudorefs
Quoted 7 lines
Documentation/config/core.adoc | 2 +- Documentation/for-each-ref-options.adoc | 2 +- Documentation/git-ls-remote.adoc | 4 +- Documentation/git-update-ref.adoc | 13 ++- Documentation/git-worktree.adoc | 9 +- Documentation/glossary-content.adoc | 86 ++++++++++++------- Documentation/rev-list-options.adoc | 4 +-
I wonder if gitdatamodel.adoc should also cover pseudorefs and root refs in the “References” section. Right now it only says something extremely short on the topic:
Git may also create references other than HEAD at the base of the hierarchy, like ORIG_HEAD.
Quoted 23 lines
builtin/for-each-ref.c | 2 +- contrib/completion/git-completion.bash | 7 +- refs.h | 13 ++- revision.c | 2 +- t/show-ref-exists-tests.sh | 4 +- t/t0600-reffiles-backend.sh | 2 +- t/t0610-reftable-basics.sh | 2 +- t/t1400-update-ref.sh | 66 +++++++------- t/t1403-show-ref.sh | 2 +- t/t1460-refs-migrate.sh | 4 +- t/t4013-diff-various.sh | 6 +- ...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +- t/t6302-for-each-ref-filter.sh | 4 +- t/t9902-completion.sh | 4 +- 21 files changed, 129 insertions(+), 111 deletions(-)rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)
base-commit:
7e34d8174dcda3435d1404c9a30bef46afe6c13eSignature · 1 line
2.56.0
Quoted 6 lines · Julia Evans
I wonder if gitdatamodel.adoc should also cover pseudorefs and root refs in the “References” section. Right now it only says something extremely short on the topic:
Git may also create references other than HEAD at the base of the hierarchy, like
ORIG_HEAD.
I've given it a go as part of commit 3 in v2.
Andy
v2 cover root refs vs pseudorefs
In reply to Andy KoppeChanges in v2:
- Tweak pseudoref definition.
- Add prefix lists for per-worktree refs.
- Wrap lists in '--'.
- Add root refs and pseudorefs to ref types in gitdatamodel(7).
- Trim messages of commits 3 and 4.
Andy Koppe (5):
doc: glossary: add root ref and clarify pseudorefs
doc: glossary: update per-worktree refs
doc: stop calling root refs pseudorefs
refs: stop calling root refs pseudorefs
t: stop calling root refs pseudorefs
Documentation/config/core.adoc | 2 +-
Documentation/for-each-ref-options.adoc | 2 +-
Documentation/git-ls-remote.adoc | 4 +-
Documentation/git-update-ref.adoc | 13 ++-
Documentation/git-worktree.adoc | 13 ++-
Documentation/gitdatamodel.adoc | 18 +++-
Documentation/glossary-content.adoc | 98 ++++++++++++-------
Documentation/rev-list-options.adoc | 4 +-
builtin/for-each-ref.c | 2 +-
contrib/completion/git-completion.bash | 7 +-
refs.h | 13 ++-
revision.c | 2 +-
t/show-ref-exists-tests.sh | 4 +-
t/t0600-reffiles-backend.sh | 2 +-
t/t0610-reftable-basics.sh | 2 +-
t/t1400-update-ref.sh | 66 ++++++-------
t/t1403-show-ref.sh | 2 +-
t/t1460-refs-migrate.sh | 4 +-
t/t4013-diff-various.sh | 6 +-
...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +-
t/t6302-for-each-ref-filter.sh | 4 +-
t/t9902-completion.sh | 4 +-
22 files changed, 158 insertions(+), 116 deletions(-)
rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)Range-diff against v1:
1: 9979ad1589 ! 1: 4734fa2f2e doc: glossary: add root ref and clarify pseudorefs
@@ Documentation/glossary-content.adoc: exclude;;
- A ref that has different semantics than normal refs. These refs can be
- read via normal Git commands, but cannot be written to by commands like
- linkgit:git-update-ref[1].
-+ A name that can be used like a <<def_ref,ref>> to refer to
-+ <<def_object,objects>>, but that is not stored in the same way as refs.
-+ For example, pseudorefs cannot be written by linkgit:git-update-ref[1]
-+ or listed by linkgit:git-for-each-ref[1].
++ A name that can be used like a <<def_ref,ref>> to refer to an
++ <<def_object,object>>, but that is not stored in the same way as refs.
++ For example, pseudorefs can be passed to linkgit:git-log[1] or
++ linkgit:git-diff[1], but they cannot be written by
++ linkgit:git-update-ref[1] or listed by linkgit:git-for-each-ref[1].
+
The following pseudorefs are known to Git:
-
-@@ Documentation/glossary-content.adoc: The following pseudorefs are known to Git:
+-
+++
++--
+ - FETCH_HEAD is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It
+ may refer to multiple object IDs. Each object ID is annotated with metadata
+ indicating where it was fetched from and its fetch status.
- MERGE_HEAD is written by linkgit:git-merge[1] when resolving merge conflicts. It contains all commit IDs which are being merged.
++--
++
+When a pseudoref contains more than one object ID, using it to refer to an +object yields the first one.
2: 8932691331 ! 2: 62f4ae009c doc: glossary: update per-worktree refs
@@ Documentation/glossary-content.adoc: exclude;;
- that start with refs/bisect/, but might later include other
- unusual refs.
+ A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>,
-+ rather than shared between all worktrees. All
-+ <<def_root_ref,root refs>>, such as <<def_HEAD,HEAD>>, are
-+ per-worktree, as are refs that start with refs/bisect/,
-+ refs/worktree/ or refs/rewritten/.
++ rather than shared between all worktrees. All <<def_root_ref,root refs>>,
++ for example <<def_HEAD,HEAD>> and ORIG_HEAD, are per-worktree, as are
++ refs with the following prefixes:
+++
++--
++ - refs/bisect/
++
++ - refs/rewritten/
++
++ - refs/worktree/
++--
++
+<<def_pseudoref,Pseudorefs>> are also specific to each worktree. ++
@@ Documentation/glossary-content.adoc: exclude;;
+per-worktree refs of other worktrees.
[[def_pseudoref]]pseudoref::
- A name that can be used like a <<def_ref,ref>> to refer to
+ A name that can be used like a <<def_ref,ref>> to refer to an
@@ Documentation/glossary-content.adoc: and pseudorefs.
"working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree
- (e.g. the index, HEAD and pseudorefs like MERGE_HEAD,
- per-worktree refs and per-worktree configuration file).
-+ (e.g. the index, per-worktree refs such as HEAD, pseudorefs
-+ such as MERGE_HEAD, and the per-worktree configuration file).
++ (e.g. the index, <<def_per_worktree_ref,per-worktree refs>>, and the
++ per-worktree configuration file).
3: 8cdd299c28 ! 3: 73dcb3d715 doc: stop calling root refs pseudorefs
@@ Commit message
there, correct "symbolics" to "symbolic refs".
In git-update-ref(1), drop the incorrect mention of ORIG_HEAD. HEAD is
- the only root ref that gets a reflog by default. Also restructure the
- sentence to make it easier to parse.
+ the only root ref that gets a reflog by default. In the description of
+ core.logAllRefUpdates, correct the claim that "always" only applies to
+ refs under "refs/". It applies to root refs too.
- In the description of core.logAllRefUpdates, correct the claim that
- "always" only applies to refs under "refs/". It applies to root refs
- too.
+ Distinguish root refs and pseudorefs in gitdatamodel(7). Lowercase the
+ "other references" list entry there to match the others.
@@ Documentation/git-worktree.adoc: but others are specific to an individual worktr
-however: refs inside refs/bisect, refs/worktree and refs/rewritten are -not shared.
+In general, all root refs and pseudorefs are per-worktree and all refs
-+starting with refs/ are shared. There are exceptions, however: refs -+inside refs/bisect, refs/worktree and refs/rewritten are not -+shared.
++starting with refs/ are shared, except for refs with the following prefixes:
++
++ - refs/bisect/
++
++ - refs/rewritten/
++
++ - refs/worktree/
Refs that are per-worktree can still be accessed from another worktree via two special paths, main-worktree and worktrees. The former gives
+ ## Documentation/gitdatamodel.adoc ##
+@@ Documentation/gitdatamodel.adoc: remote-tracking branches: refs/remotes/<remote>/<branch>::
+ default branch. This is the branch that git clone checks out by default.
+
+ [[other-refs]]
+-Other references::
++other references::
+ Git tools may create references anywhere under refs/.
+ For example, linkgit:git-stash[1], linkgit:git-bisect[1],
+ and linkgit:git-notes[1] all create their own references
+ in refs/stash, refs/bisect, etc.
+ Third-party Git tools may also create their own references.
+-+
+-Git may also create references other than HEAD at the base of the
+-hierarchy, like ORIG_HEAD.
++
++[[root-refs]]
++root refs::
++ Git may also create references other than HEAD at the root of the
++ hierarchy, for example ORIG_HEAD or REBASE_HEAD.
++
++[[pseudorefs]]
++pseudorefs::
++ linkgit:git-fetch[1] and linkgit:git-merge[1] create the so-called
++ pseudorefs FETCH_HEAD and MERGE_HEAD. They are not references as
++ such, as they are not stored in the same way, but they can nevertheless
++ be used to refer to objects in commands such as linkgit:git-log[1] and
++ linkgit:git-diff[1].
+
+ NOTE: Git may delete objects that aren't "reachable" from any reference
+ or <<reflogs,reflog>>.
+
## Documentation/rev-list-options.adoc ##
@@ Documentation/rev-list-options.adoc: Under --pretty=reference, this information will not be shown at all.
4: 8bb6d5435c ! 4: eb3d64fa96 refs: stop calling root refs pseudorefs
@@ Commit message
Some messages and comments in the code still use "pseudoref" in its old sense of any ref outside of "refs/", whereas the glossary now calls
- those root refs and restricts pseudorefs to FETCH_HEAD and MERGE_HEAD.
+ those root refs and restricts pseudorefs to FETCH_HEAD and MERGE_HEAD,
+ so update them.
- Replace "pseudoref" with "root ref" in the help text for
- "git for-each-ref --include-root-refs", in comments in refs.h, and in
- comments in the bash completion script, including the one for
- __git_pseudoref_exists(), which is also used for root refs. The function
- itself is not renamed. There is no obvious term covering both root refs
- and pseudorefs, and the old name might need to be kept for third-party
- completion scripts.
-
- Update the description of pseudorefs in refs.h to match the glossary.
+ Bash completion function __git_pseudoref_exists() is not renamed, as
+ there is no obvious term covering both root refs and pseudorefs, and
+ third-party completion scripts might depend on the name.
5: c681a032ba = 5: 31022553a6 t: stop calling root refs pseudorefs
Signature · 1 line
2.56.0
Quoted 191 lines · Andy Koppe
Changes in v2:
- Tweak pseudoref definition.
- Add prefix lists for per-worktree refs.
- Wrap lists in '--'.
- Add root refs and pseudorefs to ref types in gitdatamodel(7).
- Trim messages of commits 3 and 4.Andy Koppe (5):
doc: glossary: add root ref and clarify pseudorefs
doc: glossary: update per-worktree refs
doc: stop calling root refs pseudorefs
refs: stop calling root refs pseudorefs
t: stop calling root refs pseudorefsDocumentation/config/core.adoc | 2 +- Documentation/for-each-ref-options.adoc | 2 +- Documentation/git-ls-remote.adoc | 4 +- Documentation/git-update-ref.adoc | 13 ++- Documentation/git-worktree.adoc | 13 ++- Documentation/gitdatamodel.adoc | 18 +++- Documentation/glossary-content.adoc | 98 ++++++++++++------- Documentation/rev-list-options.adoc | 4 +- builtin/for-each-ref.c | 2 +- contrib/completion/git-completion.bash | 7 +- refs.h | 13 ++- revision.c | 2 +- t/show-ref-exists-tests.sh | 4 +- t/t0600-reffiles-backend.sh | 2 +- t/t0610-reftable-basics.sh | 2 +- t/t1400-update-ref.sh | 66 ++++++------- t/t1403-show-ref.sh | 2 +- t/t1460-refs-migrate.sh | 4 +- t/t4013-diff-various.sh | 6 +- ...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +- t/t6302-for-each-ref-filter.sh | 4 +- t/t9902-completion.sh | 4 +- 22 files changed, 158 insertions(+), 116 deletions(-) rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE =>diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)
Range-diff against v1:
1:9979ad1589! 1:4734fa2f2edoc: glossary: add root ref and clarify pseudorefs
@@Documentation/glossary-content.adoc: exclude;;
- A ref that has different semantics than normal refs. These refs
can be
- read via normal Git commands, but cannot be written to by
commands like
- linkgit:git-update-ref[1].
-+ A name that can be used like a <<def_ref,ref>> to refer to
-+ <<def_object,objects>>, but that is not stored in the same way
as refs.
-+ For example, pseudorefs cannot be written by
linkgit:git-update-ref[1]
-+ or listed by linkgit:git-for-each-ref[1].
++ A name that can be used like a <<def_ref,ref>> to refer to an
++ <<def_object,object>>, but that is not stored in the same way as
refs.
++ For example, pseudorefs can be passed to linkgit:git-log[1] or
++ linkgit:git-diff[1], but they cannot be written by
++ linkgit:git-update-ref[1] or listed by
linkgit:git-for-each-ref[1].
+
The following pseudorefs are known to Git:
-
-@@Documentation/glossary-content.adoc: The following pseudorefs
are known to Git:+- +++ ++-- + - `FETCH_HEAD` is written by linkgit:git-fetch[1] orlinkgit:git-pull[1]. It
+ may refer to multiple object IDs. Each object ID is annotated
with metadata
+ indicating where it was fetched from and its fetch status.-
MERGE_HEADis written by linkgit:git-merge[1] when resolving merge conflicts. It contains all commit IDs which are being merged.
++--
++
+When a pseudoref contains more than one object ID, using it to refer to an +object yields the first one.
2: 8932691331 ! 2:62f4ae009cdoc: glossary: update per-worktree refs
@@Documentation/glossary-content.adoc: exclude;;
- that start withrefs/bisect/, but might later include other
- unusual refs.
+ A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>,
-+ rather than shared between all worktrees. All
-+ <<def_root_ref,root refs>>, such as <<def_HEAD,HEAD>>, are
-+ per-worktree, as are refs that start withrefs/bisect/,
-+refs/worktree/orrefs/rewritten/.
++ rather than shared between all worktrees. All <<def_root_ref,root refs>>,
++ for example <<def_HEAD,HEAD>> andORIG_HEAD, are per-worktree, as are
++ refs with the following prefixes:
+++
++--
++ -refs/bisect/
++
++ -refs/rewritten/
++
++ -refs/worktree/
++--
++
+<<def_pseudoref,Pseudorefs>> are also specific to each worktree. ++
@@Documentation/glossary-content.adoc: exclude;;
+per-worktree refs of other worktrees.[[def_pseudoref]]pseudoref::
- A name that can be used like a <<def_ref,ref>> to refer to
+ A name that can be used like a <<def_ref,ref>> to refer to an
@@Documentation/glossary-content.adoc: and pseudorefs.
"working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree
- (e.g. the index, HEAD and pseudorefs likeMERGE_HEAD,
- per-worktree refs and per-worktree configuration file).
-+ (e.g. the index, per-worktree refs such as HEAD, pseudorefs
-+ such asMERGE_HEAD, and the per-worktree configuration file).
++ (e.g. the index, <<def_per_worktree_ref,per-worktree refs>>, and the
++ per-worktree configuration file).
3:8cdd299c28! 3:73dcb3d715doc: stop calling root refs pseudorefs
@@ Commit message
there, correct "symbolics" to "symbolic refs".In git-update-ref(1), drop the incorrect mention of
ORIG_HEAD. HEAD is
- the only root ref that gets a reflog by default. Also restructure the
- sentence to make it easier to parse.
+ the only root ref that gets a reflog by default. In the description of
+ core.logAllRefUpdates, correct the claim that "always" only applies to
+ refs under "refs/". It applies to root refs too.- In the description of core.logAllRefUpdates, correct the claim that
- "always" only applies to refs under "refs/". It applies to root refs
- too.
+ Distinguish root refs and pseudorefs in gitdatamodel(7). Lowercase the
+ "other references" list entry there to match the others.Signed-off-by Andy Koppe <[email protected]>@@
Documentation/git-worktree.adoc: but others are specific to an
individual worktr
-however: refs insiderefs/bisect,refs/worktreeandrefs/rewrittenare
-not shared.
+In general, all root refs and pseudorefs are per-worktree and all
refs
-+starting withrefs/are shared. There are exceptions, however:
refs
-+insiderefs/bisect,refs/worktreeandrefs/rewrittenare not -+shared.
++starting withrefs/are shared, except for refs with the
following prefixes:++ ++ - `refs/bisect/` ++ ++ - `refs/rewritten/` ++ ++ - `refs/worktree/` Refs that are per-worktree can still be accessed from another worktree via two special paths, `main-worktree` and `worktrees`. The former gives + ## Documentation/gitdatamodel.adoc ## +@@ Documentation/gitdatamodel.adoc: remote-tracking branches:
refs/remotes/<remote>/<branch>::
+ default branch. This is the branch thatgit clonechecks out by
default.
+
+ [[other-refs]]
+-Other references::
++other references::
+ Git tools may create references anywhere underrefs/.
+ For example, linkgit:git-stash[1], linkgit:git-bisect[1],
+ and linkgit:git-notes[1] all create their own references
+ inrefs/stash,refs/bisect, etc.
+ Third-party Git tools may also create their own references.
+-+
+-Git may also create references other thanHEADat the base of
the+-hierarchy, like `ORIG_HEAD`. ++ ++[[root-refs]] ++root refs:: ++ Git may also create references other than `HEAD` at the root of the ++ hierarchy, for example `ORIG_HEAD` or `REBASE_HEAD`. ++ ++[[pseudorefs]] ++pseudorefs:: ++ linkgit:git-fetch[1] and linkgit:git-merge[1] create the
Quoted 5 lines
so-called
++ pseudorefsFETCH_HEADandMERGE_HEAD. They are not
references as
++ such, as they are not stored in the same way, but they can
nevertheless
When I look at my .git directory during a merge conflict, I see these files:
$ ls .git | grep HEAD FETCH_HEAD HEAD MERGE_HEAD ORIG_HEAD
From the above, it sounds like ORIG_HEAD is a "root ref" and MERGE_HEAD is a "pseudoref", but naively it does look like they're stored in the same way. What's the difference?
Quoted 26 lines · Julia Evans
Quoted 9 lines · Andy Koppe
++[[root-refs]] ++root refs:: ++ Git may also create references other than `HEAD` at the root of the ++ hierarchy, for example `ORIG_HEAD` or `REBASE_HEAD`. ++ ++[[pseudorefs]] ++pseudorefs:: ++ linkgit:git-fetch[1] and linkgit:git-merge[1] create theQuoted 5 lines
so-called
++ pseudorefsFETCH_HEADandMERGE_HEAD. They are not
references as
++ such, as they are not stored in the same way, but they can
neverthelessWhen I look at my .git directory during a merge conflict, I see these files:
$ ls .git | grep HEAD FETCH_HEAD HEAD MERGE_HEAD ORIG_HEAD
Quoted 3 lines
From the above, it sounds like
ORIG_HEADis a "root ref" andMERGE_HEADis a "pseudoref", but naively it does look like they're stored in the same way. What's the difference?
Good question. The differences certainly aren't obvious, and they barely matter to users.
Root refs:
- Can be stored in reftables instead of files in .git.
- Contain either a single hash or a single symbolic ref such as 'ref:
refs/heads/main'.
- Can be modified with 'git update-ref' (generally a bad idea for built-in root refs) and listed with 'git for-each-ref' and similar commands.
Pseudorefs:
- Are always stored as files in .git.
- May contain multiple hashes, and in the case of FETCH_HEAD, carry additional information about where each hash came from.
- Are only modified by the commands they serve (i.e. fetch, merge and pull) and can't be listed.
The big thing they have in common, apart from the *_HEAD names, is that you can pass both types to commands such as 'git log', 'git diff' or 'git checkout' to refer to a commit or tree, just like any ref under refs/.
Quoted 49 lines · Andy Koppe
Quoted 26 lines · Julia Evans
Quoted 9 lines · Andy Koppe
++[[root-refs]] ++root refs:: ++ Git may also create references other than `HEAD` at the root of the ++ hierarchy, for example `ORIG_HEAD` or `REBASE_HEAD`. ++ ++[[pseudorefs]] ++pseudorefs:: ++ linkgit:git-fetch[1] and linkgit:git-merge[1] create theQuoted 5 lines
so-called
++ pseudorefsFETCH_HEADandMERGE_HEAD. They are not
references as
++ such, as they are not stored in the same way, but they can
neverthelessWhen I look at my .git directory during a merge conflict, I see these files:
$ ls .git | grep HEAD FETCH_HEAD HEAD MERGE_HEAD ORIG_HEADQuoted 3 lines
From the above, it sounds like
ORIG_HEADis a "root ref" andMERGE_HEADis a "pseudoref", but naively it does look like they're stored in the same way. What's the difference?Good question. The differences certainly aren't obvious, and they barely matter to users.
Root refs:
- Can be stored in reftables instead of files in .git.
- Contain either a single hash or a single symbolic ref such as 'ref:
refs/heads/main'.
- Can be modified with 'git update-ref' (generally a bad idea for built-in root refs) and listed with 'git for-each-ref' and similar commands.Pseudorefs:
- Are always stored as files in .git.
- May contain multiple hashes, and in the case ofFETCH_HEAD, carry additional information about where each hash came from.
- Are only modified by the commands they serve (i.e. fetch, merge and pull) and can't be listed.
Quoted 4 lines
The big thing they have in common, apart from the
*_HEADnames, is that you can pass both types to commands such as 'git log', 'git diff' or 'git checkout' to refer to a commit or tree, just like any ref under refs/.
That’s very helpful. I think it would make sense to include “may contain multiple hashes” at least, that on its own makes it very clear what the difference is.
My impression is that FETCH_HEAD specifically is a relatively popular pseudoref and folks would be interested to know that it can contain multiple hashes.
If a pseudoref contains multiple hashes and you pass it to a command, will the command use the first hash?
Also are FETCH_HEAD and MERGE_HEAD the only
pseudorefs?
Quoted 29 lines · Julia Evans
Quoted 15 lines · Andy Koppe
Root refs:
- Can be stored in reftables instead of files in .git.
- Contain either a single hash or a single symbolic ref such as 'ref:
refs/heads/main'.
- Can be modified with 'git update-ref' (generally a bad idea for built-in root refs) and listed with 'git for-each-ref' and similar commands.Pseudorefs:
- Are always stored as files in .git.
- May contain multiple hashes, and in the case ofFETCH_HEAD, carry additional information about where each hash came from.
- Are only modified by the commands they serve (i.e. fetch, merge and pull) and can't be listed.Quoted 4 lines
The big thing they have in common, apart from the
*_HEADnames, is that you can pass both types to commands such as 'git log', 'git diff' or 'git checkout' to refer to a commit or tree, just like any ref under refs/.That’s very helpful. I think it would make sense to include “may contain multiple hashes” at least, that on its own makes it very clear what the difference is.
My impression is that
FETCH_HEADspecifically is a relatively popular pseudoref and folks would be interested to know that it can contain multiple hashes.
Quoted 5 lines
If a pseudoref contains multiple hashes and you pass it to a command, will the command use the first hash?
Also are
FETCH_HEADandMERGE_HEADthe only
pseudorefs?
I think the pseudoref glossary entry covers these questions. As it appears in 'man' after v2:
pseudoref
A name that can be used like a ref to refer to an object, but that is not stored in the same way as refs. For example, pseudorefs can be passed to git-log(1) or git-diff(1), but they cannot be written by git-update-ref(1) or listed by git-for-each-ref(1).
The following pseudorefs are known to Git:
• FETCH_HEAD is written by git-fetch(1) or git-pull(1). It may
refer to multiple object IDs. Each object ID is annotated with metadata indicating where it was fetched from and its fetch status.
• MERGE_HEAD is written by git-merge(1) when resolving merge
conflicts. It contains all commit IDs which are being merged.
When a pseudoref contains more than one object ID, using it to refer to an object yields the first one.
Quoted 7 lines
pseudoref
A name that can be used like a ref to refer to an object, but that is not stored in the same way as refs. For example, pseudorefs can be passed to git-log(1) or git-diff(1), but they cannot be written by git-update-ref(1) or listed by git-for-each-ref(1).
Quoted 6 lines
The following pseudorefs are known to Git:
•
FETCH_HEADis written by git-fetch(1) or git-pull(1). It may
refer to multiple object IDs. Each object ID is annotated with metadata indicating where it was fetched from and its fetch status.
I found "Each object ID is annotated with metadata indicating where it was fetched from and its fetch status." to be very hard to parse, and I had to go look at .git/FETCH_HEAD myself to understand what it was talking about.
It might help to instead describe FETCH_HEAD with an example, especially since we already aren't giving a lot of details. Maybe something like this:
Git has 2 special pseudorefs: MERGE_HEAD and FETCH_HEAD. Unlike references (which can only contain an object ID or the name of another reference), these have their own format:
- FETCH_HEAD has a list of entries like this:
d4c5f27105ee2e44366d718dbc5db95bbe99c714 not-for-merge branch 'example' of https://example.com/x/y
with details about what was fetched by linkgit:git-fetch[1].
- MERGE_HEAD has a list of commit IDs
These are stored as files in the .git directory. You can pass a pseudoref to git show, git log, etc, and it will use the first ID in the list. Pseudorefs can't be written by git-update-ref(1) or listed by git-for-each-ref(1).
Quoted 30 lines · Julia Evans
Quoted 6 lines
pseudoref
A name that can be used like a ref to refer to an object, but that is not stored in the same way as refs. For example, pseudorefs can be passed to git-log(1) or git-diff(1), but they cannot be written by git-update-ref(1) or listed by git-for-each-ref(1).Quoted 6 lines
The following pseudorefs are known to Git:
•
FETCH_HEADis written by git-fetch(1) or git-pull(1). It may
refer to multiple object IDs. Each object ID is annotated with metadata indicating where it was fetched from and its fetch status.I found "Each object ID is annotated with metadata indicating where it was fetched from and its fetch status." to be very hard to parse, and I had to go look at .git/FETCH_HEAD myself to understand what it was talking about.
It might help to instead describe
FETCH_HEADwith an example, especially since we already aren't giving a lot of details. Maybe something like this:Git has 2 special pseudorefs:
MERGE_HEADandFETCH_HEAD. Unlike references (which can only contain an object ID or the name of another reference), these have their own format:-
FETCH_HEADhas a list of entries like this:
d4c5f27105ee2e44366d718dbc5db95bbe99c714 not-for-merge branch 'example' of https://example.com/x/y
with details about what was fetched by linkgit:git-fetch[1].
-MERGE_HEADhas a list of commit IDs
Quoted 4 lines
These are stored as files in the
.gitdirectory. You can pass a pseudoref togit show,git log, etc, and it will use the first ID in the list. Pseudorefs can't be written by git-update-ref(1) or listed by git-for-each-ref(1).
I agree that the FETCH_HEAD and MERGE_HEAD descriptions are difficult to parse, but I don't think the rather cryptic FETCH_HEAD example belongs in the glossary.
I've taken Patrick's and Junio's suggestions, moved up the point about reading the first object ID, and rewrote the FETCH_HEAD and MERGE_HEAD descriptions, ending up with this:
pseudoref
A name that can be used like a ref to refer to an object, but that has additional semantics: it can record more than one object ID and may carry extra metadata. In contrast to root refs, pseudorefs are therefore not stored or handled by the ref backend.
Pseudorefs can be passed to commands such as git-log(1) or git- diff(1), but cannot be written by git-update-ref(1) or listed by git-for-each-ref(1). When a pseudoref contains more than one object ID, using it to refer to an object yields the first one.
The following pseudorefs are known to Git:
• FETCH_HEAD is written by git-fetch(1) or git-pull(1) to record
the objects that have been fetched. Each object is annotated with the ref and repository it was fetched from and whether it is to be merged when pulling.
• MERGE_HEAD is written by git-merge(1) or git-pull(1) to record
the commits being merged while a merge is in progress.
"Julia Evans" <[email protected]> writes:
... 200 lines of quoted material omitted ...
Quoted 18 lines
Quoted 8 lines
++[[pseudorefs]] ++pseudorefs:: ++ linkgit:git-fetch[1] and linkgit:git-merge[1] create theso-called
++ pseudorefsFETCH_HEADandMERGE_HEAD. They are not
references as
++ such, as they are not stored in the same way, but they can
neverthelessWhen I look at my .git directory during a merge conflict, I see these files:
$ ls .git | grep HEAD FETCH_HEAD HEAD MERGE_HEAD ORIG_HEAD
Quoted 3 lines
From the above, it sounds like
ORIG_HEADis a "root ref" andMERGE_HEADis a "pseudoref", but naively it does look like they're stored in the same way. What's the difference?
A pseudoref cannot be treated as a true ref because it can describe multiple objects. If you force it to be interpreted as an object, you will still get one of the objects, but that is not the primary way it is designed to be used. FETCH_HEAD even describes the nature of each object, e.g.,
a018953...4 branch 'maint' of gitolite.kernel.org:/pub/scm/git/git
8d1b215...8 not-for-merge branch 'master' of gitolite.kernel.org:/pub/scm/git/git
882cbad...5 not-for-merge branch 'next' of gitolite.kernel.org:/pub/scm/git/git
4231a2f...4 not-for-merge branch 'jch' of gitolite.kernel.org:/pub/scm/git/git
2fa90fe...8 not-for-merge branch 'seen' of gitolite.kernel.org:/pub/scm/git/git
The other kind, just like a normal ref, describes one and only one object. The only special trait it has is that it is outside the refs/ hierarchy, so it may be a slight misnomer to call them "root" refs. We do accept $GIT_DIR/ORIG_HEAD as if it were a real ref, but if we did:
$ mkdir -p .git/foo/bar
$ git rev-parse HEAD~24 >.git/foo/bar/baz
$ git show -s foo/bar/bazwe would end up treating "foo/bar/baz" as if it were a real ref, too, with exactly the same mechanism used to treat ORIG_HEAD.
The only difference between .git/ORIG_HEAD and .git/foo/bar/baz in the above example is that we _do_ create "root" refs ourselves, while we do not create such funky things like foo/bar/baz (hence they do not deserve a name, and such "use" may suddenly break without notice).
By the way, *please* trim your quote. Having to scroll past 200 lines of material that are totally irrelevant to understanding your comment is a real pain.
Thanks.
PATCH v2 1/5 doc: glossary: add root ref and clarify pseudorefs
In reply to Andy KoppeThe glossary describes refs in the root of the ref hierarchy, but does not actually name them "root refs", even though the term is used elsewhere, for example by "git for-each-ref --include-root-refs". It also defines pseudorefs as refs, yet is_root_ref() deliberately excludes them, as they are not stored or handled by the ref backends.
Add a "root ref" entry, moving the naming rules and the list of irregular root refs there from the "ref" entry. State that pseudorefs are not root refs, and refer to gitrevisions(7) for descriptions of commonly used root refs and pseudorefs.
Reword the "pseudoref" entry so that it no longer calls them refs, add git-for-each-ref(1) as another example of how they are not proper refs, and explain that using a pseudoref containing multiple object IDs yields the first one.
--- Documentation/glossary-content.adoc | 73 ++++++++++++++++++----------- 1 file changed, 45 insertions(+), 28 deletions(-)
Documentation/glossary-content.adoc +45 -28
@@ -500,18 +500,25 @@ exclude;; unusual refs. [[def_pseudoref]]pseudoref:: - A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to an + <<def_object,object>>, but that is not stored in the same way as refs. + For example, pseudorefs can be passed to linkgit:git-log[1] or + linkgit:git-diff[1], but they cannot be written by + linkgit:git-update-ref[1] or listed by linkgit:git-for-each-ref[1]. + The following pseudorefs are known to Git: - ++ +-- - `FETCH_HEAD` is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It may refer to multiple object IDs. Each object ID is annotated with metadata indicating where it was fetched from and its fetch status. - `MERGE_HEAD` is written by linkgit:git-merge[1] when resolving merge conflicts. It contains all commit IDs which are being merged. +-- ++ +When a pseudoref contains more than one object ID, using it to refer to an +object yields the first one. [[def_pull]]pull:: Pulling a <<def_branch,branch>> means to <<def_fetch,fetch>> it and
@@ -562,33 +569,12 @@ The following pseudorefs are known to Git: + The ref namespace is hierarchical. Ref names must either start with `refs/` or be located in the root of -the hierarchy. For the latter, their name must follow these rules: -+ --- - - The name consists of only upper-case characters or underscores. - - - The name ends with "`_HEAD`" or is equal to "`HEAD`". --- -+ -There are some irregular refs in the root of the hierarchy that do not -match these rules. The following list is exhaustive and shall not be -extended in the future: -+ --- - - `AUTO_MERGE` - - - `BISECT_EXPECTED_REV` - - - `NOTES_MERGE_PARTIAL` - - - `NOTES_MERGE_REF` - - - `MERGE_AUTOSTASH` --- +the hierarchy, in which case they must follow the naming rules for +<<def_root_ref,root refs>>. + Different subhierarchies are used for different purposes. For example, the `refs/heads/` hierarchy is used to represent local branches whereas -the `refs/tags/` hierarchy is used to represent local tags.. +the `refs/tags/` hierarchy is used to represent local tags. + See also "REFERENCES" in linkgit:gitdatamodel[7].
@@ -640,6 +626,37 @@ format. See linkgit:git-reflog[1] for details. To throw away part of the development, i.e. to assign the <<def_head,head>> to an earlier <<def_revision,revision>>. +[[def_root_ref]]root ref:: + A <<def_ref,ref>> located in the root of the ref hierarchy, outside + `refs/`. Root ref names must follow these rules: ++ +-- + - The name consists of only upper-case characters or underscores. + + - The name ends with "`_HEAD`" or is equal to "`HEAD`". +-- ++ +The following irregular root refs are exceptions to these rules. This +list is exhaustive and shall not be extended in future: ++ +-- + - `AUTO_MERGE` + + - `BISECT_EXPECTED_REV` + + - `NOTES_MERGE_PARTIAL` + + - `NOTES_MERGE_REF` + + - `MERGE_AUTOSTASH` +-- ++ +<<def_pseudoref,Pseudorefs>> are not considered root refs, even though +they follow the naming rules. ++ +See linkgit:gitrevisions[7] for descriptions of commonly used root refs +and pseudorefs. + [[def_SCM]]SCM:: Source code management (tool).
Signature · 1 line
2.56.0
Re: [PATCH v2 1/5] doc: glossary: add root ref and clarify pseudorefs
Quoted 6 lines · Andy Koppe
Documentation/glossary-content.adoc +0
-0@@ -500,18 +500,25 @@ exclude;; unusual refs.
Documentation/glossary-content.adoc exclude;; · line 507
Quoted 10 lines
Documentation/glossary-content.adoc +5
-3[[def_pseudoref]]pseudoref:: - A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to an + <<def_object,object>>, but that is not stored in the same way as refs. + For example, pseudorefs can be passed to linkgit:git-log[1] or + linkgit:git-diff[1], but they cannot be written by + linkgit:git-update-ref[1] or listed by linkgit:git-for-each-ref[1].
I'm still not entirely convinced by this change, as it only focusses on the difference in storage. How about this instead:
[[def_pseudoref]]pseudoref::
A name that can be used like a <<def_ref,ref>> to refer to an <<def_object,object>>, but that has different semantics: it can record more than one object ID and may carry additional metadata. In contrast to root refs, pseudorefs are therefore not stored or handled by the ref backend. They can be passed to commands like linkgit:git-log[1] or linkgit:git-diff[1], but cannot be written by linkgit:git-update-ref[1] or listed by linkgit:git-for-each-ref[1].
Patrick
Re: [PATCH v2 1/5] doc: glossary: add root ref and clarify pseudorefs
Quoted 12 lines · Patrick Steinhardt
I'm still not entirely convinced by this change, as it only focusses on the difference in storage. How about this instead:
[[def_pseudoref]]pseudoref::
A name that can be used like a <<def_ref,ref>> to refer to an <<def_object,object>>, but that has different semantics: it can record more than one object ID and may carry additional metadata. In contrast to root refs, pseudorefs are therefore not stored or handled by the ref backend. They can be passed to commands like linkgit:git-log[1] or linkgit:git-diff[1], but cannot be written by linkgit:git-update-ref[1] or listed by linkgit:git-for-each-ref[1].
Between the two I would prefer yours. I would replace "different" with "additional", because a pseudoref can be used as the name of the first object it contains in a fully compatible way as any other refs, I want to avoid "different" that implies "there are additional things it can do but there are things it cannot do" Venn diagram.
Then replace "carry additional" with "carry extra", just to avoid repetitions of "additional" due to the earlier change.
PATCH v2 2/5 doc: glossary: update per-worktree refs
In reply to Andy KoppeThe "per-worktree ref" entry says that these are only HEAD and refs under "refs/bisect/", but that has been out of date since a9be29c981 (sequencer: make refs generated by the label command worktree-local, 2018-04-25). All root refs are per-worktree, as are refs under "refs/worktree/" and "refs/rewritten/". Pseudorefs are specific to each worktree too.
Bring the list up to date, and refer to git-worktree(1) for how to access per-worktree refs of other worktrees. In the "worktree" entry, describe HEAD as a per-worktree ref and MERGE_HEAD as a pseudoref, rather than listing them separately from per-worktree refs.
--- Documentation/glossary-content.adoc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
Documentation/glossary-content.adoc +19 -6
@@ -494,10 +494,23 @@ exclude;; interface than the <<def_plumbing,plumbing>>. [[def_per_worktree_ref]]per-worktree ref:: - Refs that are per-<<def_worktree,worktree>>, rather than - global. This is presently only <<def_HEAD,HEAD>> and any refs - that start with `refs/bisect/`, but might later include other - unusual refs. + A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>, + rather than shared between all worktrees. All <<def_root_ref,root refs>>, + for example <<def_HEAD,HEAD>> and `ORIG_HEAD`, are per-worktree, as are + refs with the following prefixes: ++ +-- + - `refs/bisect/` + + - `refs/rewritten/` + + - `refs/worktree/` +-- ++ +<<def_pseudoref,Pseudorefs>> are also specific to each worktree. ++ +See "REFS" in linkgit:git-worktree[1] for how to access the +per-worktree refs of other worktrees. [[def_pseudoref]]pseudoref:: A name that can be used like a <<def_ref,ref>> to refer to an
@@ -791,5 +804,5 @@ and pseudorefs. "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree - (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, - per-worktree refs and per-worktree configuration file). + (e.g. the index, <<def_per_worktree_ref,per-worktree refs>>, and the + per-worktree configuration file).
Signature · 1 line
2.56.0
Re: [PATCH v2 2/5] doc: glossary: update per-worktree refs
On Sun, Nov 01, 2026 at 11:03:20PM +0000, Andy Koppe wrote:
[snip]
Quoted 4 lines
Bring the list up to date, and refer to git-worktree(1) for how to access per-worktree refs of other worktrees. In the "worktree" entry, describe HEAD as a per-worktree ref and
MERGE_HEADas a pseudoref, rather than listing them separately from per-worktree refs.
This doesn't match what you're doing anymore, as you don't mention MERGE_HEAD at all anymore.
Documentation/glossary-content.adoc and pseudorefs. · line 808
Quoted 12 lines
Documentation/glossary-content.adoc +2
-2@@ -791,5 +804,5 @@ and pseudorefs. "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree - (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, - per-worktree refs and per-worktree configuration file). + (e.g. the index, <<def_per_worktree_ref,per-worktree refs>>, and the + per-worktree configuration file).
Patrick
PATCH v2 3/5 doc: stop calling root refs pseudorefs
In reply to Andy KoppeSeveral manual pages still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls a root ref. Pseudorefs have since been restricted to FETCH_HEAD and MERGE_HEAD, which are not considered root refs.
Replace "pseudoref" with "root ref" in those pages, giving HEAD and ORIG_HEAD as examples. In git-worktree(1), say that both root refs and pseudorefs are per-worktree, and drop the description of them as being directly under $GIT_DIR, because that does not apply to the reftable backend.
In git-ls-remote(1), describe --refs as omitting refs outside "refs/", since that is what it actually checks. In the example, refer to HEAD, which is the only root ref that git-upload-pack(1) advertises. While there, correct "symbolics" to "symbolic refs".
In git-update-ref(1), drop the incorrect mention of ORIG_HEAD. HEAD is the only root ref that gets a reflog by default. In the description of core.logAllRefUpdates, correct the claim that "always" only applies to refs under "refs/". It applies to root refs too.
Distinguish root refs and pseudorefs in gitdatamodel(7). Lowercase the "other references" list entry there to match the others.
--- Documentation/config/core.adoc | 2 +- Documentation/for-each-ref-options.adoc | 2 +- Documentation/git-ls-remote.adoc | 4 ++-- Documentation/git-update-ref.adoc | 13 ++++++------- Documentation/git-worktree.adoc | 13 ++++++++----- Documentation/gitdatamodel.adoc | 18 ++++++++++++++---- Documentation/rev-list-options.adoc | 4 ++-- 7 files changed, 34 insertions(+), 22 deletions(-)
Documentation/config/core.adoc +1 -1
@@ -376,7 +376,7 @@ core.logAllRefUpdates:: `refs/heads/`), remote refs (i.e. under `refs/remotes/`), note refs (i.e. under `refs/notes/`), and the symbolic ref `HEAD`. If it is set to `always`, then a missing reflog is automatically - created for any ref under `refs/`. + created for any ref, including root refs such as `ORIG_HEAD`. + This information can be used to determine what commit was the tip of a branch "2 days ago".
Documentation/for-each-ref-options.adoc +1 -1
@@ -73,7 +73,7 @@ TAB %(refname)`. using the same rules as _<pattern>_ above. `--include-root-refs`:: - List root refs (`HEAD` and pseudorefs) apart from regular refs. + Also list root refs, such as `HEAD` or `ORIG_HEAD`. `--start-after=<marker>`:: Allows paginating the output by skipping references up to and including the
Documentation/git-ls-remote.adoc +2 -2
@@ -35,7 +35,7 @@ OPTIONS with other git subcommands. --refs:: - Do not show peeled tags or pseudorefs like `HEAD` in the output. + Do not show peeled tags or refs outside `refs/`. -q:: --quiet::
@@ -118,7 +118,7 @@ line shows the name of the object the tag points at. EXAMPLES -------- -* List all references (including symbolics and pseudorefs), peeling +* List all references (including `HEAD` and symbolic refs), peeling tags: + ----
Documentation/git-update-ref.adoc +6 -7
@@ -163,13 +163,12 @@ still see a subset of the modifications. LOGGING UPDATES --------------- -If config parameter "core.logAllRefUpdates" is true and the ref is one -under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref -like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then -`git update-ref` will append a line to the log file -"$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating -the log name) describing the change in ref value. Log lines are -formatted as: +If config parameter "core.logAllRefUpdates" is true and the ref is +HEAD or one under "refs/heads/", "refs/remotes/" or "refs/notes/", or +if the file "$GIT_DIR/logs/<ref>" exists, then `git update-ref` will +append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all +symbolic refs before creating the log name) describing the change in +ref value. Log lines are formatted as: oldsha1 SP newsha1 SP committer LF
Documentation/git-worktree.adoc +8 -5
@@ -303,11 +303,14 @@ but others are specific to an individual worktree. One example is `HEAD`, which is different for each worktree. This section is about the sharing rules and how to access refs of one worktree from another. -In general, all pseudo refs are per-worktree and all refs starting with -`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly -under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions, -however: refs inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are -not shared. +In general, all root refs and pseudorefs are per-worktree and all refs +starting with `refs/` are shared, except for refs with the following prefixes: + + - `refs/bisect/` + + - `refs/rewritten/` + + - `refs/worktree/` Refs that are per-worktree can still be accessed from another worktree via two special paths, `main-worktree` and `worktrees`. The former gives
Documentation/gitdatamodel.adoc +14 -4
@@ -211,15 +211,25 @@ remote-tracking branches: `refs/remotes/<remote>/<branch>`:: default branch. This is the branch that `git clone` checks out by default. [[other-refs]] -Other references:: +other references:: Git tools may create references anywhere under `refs/`. For example, linkgit:git-stash[1], linkgit:git-bisect[1], and linkgit:git-notes[1] all create their own references in `refs/stash`, `refs/bisect`, etc. Third-party Git tools may also create their own references. -+ -Git may also create references other than `HEAD` at the base of the -hierarchy, like `ORIG_HEAD`. + +[[root-refs]] +root refs:: + Git may also create references other than `HEAD` at the root of the + hierarchy, for example `ORIG_HEAD` or `REBASE_HEAD`. + +[[pseudorefs]] +pseudorefs:: + linkgit:git-fetch[1] and linkgit:git-merge[1] create the so-called + pseudorefs `FETCH_HEAD` and `MERGE_HEAD`. They are not references as + such, as they are not stored in the same way, but they can nevertheless + be used to refer to objects in commands such as linkgit:git-log[1] and + linkgit:git-diff[1]. NOTE: Git may delete objects that aren't "reachable" from any reference or <<reflogs,reflog>>.
Documentation/rev-list-options.adoc +2 -2
@@ -350,8 +350,8 @@ Under `--pretty=reference`, this information will not be shown at all. `--merge`:: Show commits touching conflicted paths in the range `HEAD...<other>`, - where `<other>` is the first existing pseudoref in `MERGE_HEAD`, - `CHERRY_PICK_HEAD`, `REVERT_HEAD` or `REBASE_HEAD`. Only works + where `<other>` is the first of `MERGE_HEAD`, `CHERRY_PICK_HEAD`, + `REVERT_HEAD` or `REBASE_HEAD` that exists. Only works when the index has unmerged entries. This option can be used to show relevant commits when resolving conflicts from a 3-way merge.
Signature · 1 line
2.56.0
Re: [PATCH v2 3/5] doc: stop calling root refs pseudorefs
Quoted 12 lines · Andy Koppe
Documentation/gitdatamodel.adoc +1
-1@@ -211,15 +211,25 @@ remote-tracking branches: `refs/remotes/<remote>/<branch>`:: default branch. This is the branch that `git clone` checks out by default. [[other-refs]] -Other references:: +other references:: Git tools may create references anywhere under `refs/`. For example, linkgit:git-stash[1], linkgit:git-bisect[1],
Documentation/gitdatamodel.adoc remote-tracking branches: `refs/remotes/<remote>/<branch>`:: · line 223
Quoted 10 lines
Documentation/gitdatamodel.adoc +4
-3and linkgit:git-notes[1] all create their own references in `refs/stash`, `refs/bisect`, etc. Third-party Git tools may also create their own references. -+ -Git may also create references other than `HEAD` at the base of the -hierarchy, like `ORIG_HEAD`. + +[[root-refs]] +root refs:: + Git may also create references other than `HEAD` at the root of the
Nit: I'd drop the "also" here. It made sense before, but it doesn't anymore now that this is its own list entry.
Documentation/gitdatamodel.adoc remote-tracking branches: `refs/remotes/<remote>/<branch>`:: · line 232
Quoted 9 lines
Documentation/gitdatamodel.adoc +9
-0+ hierarchy, for example `ORIG_HEAD` or `REBASE_HEAD`. + +[[pseudorefs]] +pseudorefs:: + linkgit:git-fetch[1] and linkgit:git-merge[1] create the so-called + pseudorefs `FETCH_HEAD` and `MERGE_HEAD`. They are not references as + such, as they are not stored in the same way, but they can nevertheless + be used to refer to objects in commands such as linkgit:git-log[1] and + linkgit:git-diff[1].
Do we maybe want to provide pointers to the glossary for those two entries?
Patrick
PATCH v2 4/5 refs: stop calling root refs pseudorefs
In reply to Andy KoppeSome messages and comments in the code still use "pseudoref" in its old sense of any ref outside of "refs/", whereas the glossary now calls those root refs and restricts pseudorefs to FETCH_HEAD and MERGE_HEAD, so update them.
Bash completion function __git_pseudoref_exists() is not renamed, as there is no obvious term covering both root refs and pseudorefs, and third-party completion scripts might depend on the name.
--- builtin/for-each-ref.c | 2 +- contrib/completion/git-completion.bash | 7 ++++--- refs.h | 13 ++++++------- revision.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
builtin/for-each-ref.c +1 -1
@@ -48,7 +48,7 @@ int for_each_ref_core(int argc, const char **argv, const char *prefix, struct reOPT_NO_CONTAINS (&filter.no_commit,N_ ("print only refs which don't contain the commit" )),OPT_BOOL (0 ,"ignore-case" , &icase,N_ ("sorting and filtering are case insensitive" )),OPT_BOOL (0 ,"stdin" , &from_stdin,N_ ("read reference patterns from stdin" )), -OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include HEAD ref and pseudorefs" )), +OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include root refs" )), OPT_END(), };
contrib/completion/git-completion.bash +4 -3
@@ -147,8 +147,9 @@ __git_eread () test -r "$1" && IFS=$'\r\n' read -r "$2" <"$1" } -# Runs git in $__git_repo_path to determine whether a pseudoref exists. -# 1: The pseudo-ref to search +# Runs git in $__git_repo_path to determine whether a root ref or +# pseudoref exists. +# 1: The ref to check __git_pseudoref_exists () { local ref=$1
@@ -954,7 +955,7 @@ __git_refs () esac } -# Completes refs, short and long, local and remote, symbolic and pseudo. +# Completes refs, short and long, local and remote, symbolic, root and pseudo. # # Usage: __git_complete_refs [<option>]... # --remote=<remote>: The remote to list refs from, can be the name of a
refs.h +6 -7
@@ -85,7 +85,7 @@ enum ref_transaction_error {* Even with RESOLVE_REF_ALLOW_BAD_NAME, names that escape the refs/ * directory and do not consist of all caps and underscores cannot be * resolved. The function returns NULL for such ref names. -* Caps and underscores refers to the pseudorefs, such as HEAD, +* Caps and underscores refers to root refs and pseudorefs, such as HEAD, * FETCH_HEAD and friends, that all live outside of the refs/ directory. */ #define RESOLVE_REF_READING 0x01
@@ -448,8 +448,8 @@ enum refs_for_each_flag {REFS_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 <<2 ),/* -* Include root refs i.e. HEAD and pseudorefs along with the regular -* refs. +* Include root refs, such as HEAD and ORIG_HEAD, along with the +* regular refs. */ REFS_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3), };
@@ -1306,10 +1306,9 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref);int is_root_ref (const char *refname);/* -* Pseudorefs are refs that have different semantics compared to -* "normal" refs. These refs can thus not be stored in the ref backend, -* but must always be accessed via the filesystem. The following refs -* are pseudorefs: +* Pseudorefs are names that can be used like refs, but have different +* semantics. They cannot be stored in the ref backend, but must always +* be accessed via the filesystem. The following are pseudorefs: * * - FETCH_HEAD may contain multiple object IDs, and each one of them * carries additional metadata like where it came from.
revision.c +1 -1
@@ -2000,7 +2000,7 @@ static const char *lookup_other_head(struct object_id *oid)return other_head[i]; } -die (_ ("--merge requires one of the pseudorefs MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" )); +die (_ ("--merge requires one of MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" )); }static void prepare_show_merge (struct rev_info *revs)
Signature · 1 line
2.56.0
PATCH v2 5/5 t: stop calling root refs pseudorefs
In reply to Andy KoppeSeveral test titles and comments still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls root refs.
Replace "pseudoref" with "root ref" there. In t1400 and t4013, rename the root refs that the tests create from PSEUDOREF to ROOT_REF_HEAD and from REVERSE to REVERSE_HEAD, so that they follow the naming rules for root refs. This includes renaming the expected output file in t4013.
Some tests also still refer to FETCH_HEAD and MERGE_HEAD as "special refs", which was the previous term for "pseudorefs". Correct them.
---
t/show-ref-exists-tests.sh | 4 +-
t/t0600-reffiles-backend.sh | 2 +-
t/t0610-reftable-basics.sh | 2 +-
t/t1400-update-ref.sh | 66 +++++++++----------
t/t1403-show-ref.sh | 2 +-
t/t1460-refs-migrate.sh | 4 +-
t/t4013-diff-various.sh | 6 +-
...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +-
t/t6302-for-each-ref-filter.sh | 4 +-
t/t9902-completion.sh | 4 +-
10 files changed, 48 insertions(+), 48 deletions(-)
rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)t/show-ref-exists-tests.sh +2 -2
@@ -64,11 +64,11 @@ test_expect_success '--exists with directory fails with generic error' ' test_cmp expect err ' -test_expect_success '--exists with non-existent special ref' ' +test_expect_success '--exists with non-existent pseudoref' ' test_expect_code 2 ${git_show_ref_exists} FETCH_HEAD ' -test_expect_success '--exists with existing special ref' ' +test_expect_success '--exists with existing pseudoref' ' test_when_finished "rm .git/FETCH_HEAD" && git rev-parse HEAD >.git/FETCH_HEAD && ${git_show_ref_exists} FETCH_HEAD
t/t0600-reffiles-backend.sh +1 -1
@@ -267,7 +267,7 @@ test_expect_success 'setup worktree' ' ) ' -# Some refs (refs/bisect/*, pseudorefs) are kept per worktree, so they should +# Some refs (refs/bisect/*, root refs) are kept per worktree, so they should # only appear in the for-each-reflog output if it is called from the correct # worktree, which is exercised in this test. This test is poorly written for # multiple reasons: 1) it creates invalidly formatted log entries. 2) it uses
t/t0610-reftable-basics.sh +1 -1
@@ -1156,7 +1156,7 @@ test_expect_success 'worktree: adds worktree with detached HEAD' ' test_cmp expect actual ' -test_expect_success 'fetch: accessing FETCH_HEAD special ref works' ' +test_expect_success 'fetch: accessing FETCH_HEAD pseudoref works' ' test_when_finished "rm -rf repo sub" && git init sub &&
t/t1400-update-ref.sh +33 -33
94 lines not on this page · raw message
t/t1403-show-ref.sh +1 -1
@@ -181,7 +181,7 @@ test_expect_success 'show-ref --verify HEAD' ' test_must_be_empty actual ' -test_expect_success 'show-ref --verify pseudorefs' ' +test_expect_success 'show-ref --verify root refs' ' git update-ref CHERRY_PICK_HEAD HEAD $ZERO_OID && test_when_finished "git update-ref -d CHERRY_PICK_HEAD" && git show-ref -s --verify HEAD >actual &&
t/t1460-refs-migrate.sh +2 -2
@@ -170,7 +170,7 @@ do test_cmp expect actual ' - test_expect_success "$from_format -> $to_format: pseudo-refs" ' + test_expect_success "$from_format -> $to_format: root refs" ' test_when_finished "rm -rf repo" && git init --ref-storage-format=$from_format repo && test_commit -C repo initial &&
@@ -178,7 +178,7 @@ do test_migration repo "$to_format" ' - test_expect_success "$from_format -> $to_format: special refs are left alone" ' + test_expect_success "$from_format -> $to_format: pseudorefs are left alone" ' test_when_finished "rm -rf repo" && git init --ref-storage-format=$from_format repo && test_commit -C repo initial &&
t/t4013-diff-various.sh +3 -3
@@ -115,10 +115,10 @@ test_expect_success setup ' git checkout -f main && # Same merge as main, but with parents reversed. Hide it in a - # pseudo-ref to avoid impacting tests with --all. + # root ref to avoid impacting tests with --all. commit=$(echo reverse | git commit-tree -p main^2 -p main^1 main^{tree}) && - git update-ref REVERSE $commit && + git update-ref REVERSE_HEAD $commit && git config diff.renames false &&
@@ -328,7 +328,7 @@ diff-tree --cc --stat --summary main diff-tree -c --stat --summary side diff-tree --cc --stat --summary side diff-tree --cc --shortstat main -diff-tree --cc --summary REVERSE +diff-tree --cc --summary REVERSE_HEAD # improved by Timo's patch diff-tree --cc --patch-with-stat main # improved by Timo's patch
t/t4013/diff.diff-tree_--cc_--summary_REVERSE_HEAD renamed from t/t4013/diff.diff-tree_--cc_--summary_REVERSE +1 -1
@@ -1,4 +1,4 @@ -$ git diff-tree --cc --summary REVERSE +$ git diff-tree --cc --summary REVERSE_HEAD 2562325a7ee916efb2481da93073b82cec801cbc create mode 100644 file1 delete mode 100644 file2
t/t6302-for-each-ref-filter.sh +2 -2
@@ -31,7 +31,7 @@ test_expect_success 'setup some history and refs' ' git update-ref refs/odd/spot main ' -test_expect_success '--include-root-refs pattern prints pseudorefs' ' +test_expect_success '--include-root-refs pattern prints root refs' ' cat >expect <<-\EOF && HEAD ORIG_HEAD
@@ -52,7 +52,7 @@ test_expect_success '--include-root-refs pattern prints pseudorefs' ' test_cmp expect actual ' -test_expect_success '--include-root-refs pattern does not print special refs' ' +test_expect_success '--include-root-refs pattern does not print pseudorefs' ' test_when_finished "rm -rf repo" && git init repo && (
t/t9902-completion.sh +2 -2
@@ -2693,13 +2693,13 @@ test_expect_success 'checkout matches case insensitively with GIT_COMPLETION_IGN ) ' -test_expect_success 'checkout completes pseudo refs' ' +test_expect_success 'checkout completes root refs' ' test_completion "git checkout H" <<-\EOF HEAD Z EOF ' -test_expect_success 'checkout completes pseudo refs case insensitively with GIT_COMPLETION_IGNORE_CASE' ' +test_expect_success 'checkout completes root refs case insensitively with GIT_COMPLETION_IGNORE_CASE' ' ( GIT_COMPLETION_IGNORE_CASE=1 && test_completion "git checkout h" <<-\EOF
Signature · 1 line
2.56.0
v3 cover root refs vs pseudorefs
In reply to Andy KoppeChanges in v3:
- Explain the additional semantics of pseudorefs in the glossary.
- Clarify the FETCH_HEAD and MERGE_HEAD descriptions.
- Point gitdatamodel(7) to the glossary for root refs and pseudorefs.
- Reword messages of commits 1 and 2.
Andy Koppe (5):
doc: glossary: add root ref and clarify pseudorefs
doc: glossary: update per-worktree refs
doc: stop calling root refs pseudorefs
refs: stop calling root refs pseudorefs
t: stop calling root refs pseudorefs
Documentation/config/core.adoc | 2 +-
Documentation/for-each-ref-options.adoc | 2 +-
Documentation/git-ls-remote.adoc | 4 +-
Documentation/git-update-ref.adoc | 13 +--
Documentation/git-worktree.adoc | 13 ++-
Documentation/gitdatamodel.adoc | 21 +++-
Documentation/glossary-content.adoc | 109 +++++++++++-------
Documentation/rev-list-options.adoc | 4 +-
builtin/for-each-ref.c | 2 +-
contrib/completion/git-completion.bash | 7 +-
refs.h | 13 +--
revision.c | 2 +-
t/show-ref-exists-tests.sh | 4 +-
t/t0600-reffiles-backend.sh | 2 +-
t/t0610-reftable-basics.sh | 2 +-
t/t1400-update-ref.sh | 66 +++++------
t/t1403-show-ref.sh | 2 +-
t/t1460-refs-migrate.sh | 4 +-
t/t4013-diff-various.sh | 6 +-
...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +-
t/t6302-for-each-ref-filter.sh | 4 +-
t/t9902-completion.sh | 4 +-
22 files changed, 167 insertions(+), 121 deletions(-)
rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)Range-diff against v2:
1: c52fbbd369 ! 1: 5630c671db doc: glossary: add root ref and clarify pseudorefs
@@ Commit message
not actually name them "root refs", even though the term is used elsewhere, for example by "git for-each-ref --include-root-refs". It also defines pseudorefs as refs, yet is_root_ref() deliberately excludes
- them, as they are not stored or handled by the ref backends.
+ them, as they are not stored or handled by the ref backend.
Add a "root ref" entry, moving the naming rules and the list of irregular root refs there from the "ref" entry. State that pseudorefs are not root refs, and refer to gitrevisions(7) for descriptions of commonly used root refs and pseudorefs.
- Reword the "pseudoref" entry so that it no longer calls them refs, add
- git-for-each-ref(1) as another example of how they are not proper refs,
- and explain that using a pseudoref containing multiple object IDs yields
- the first one.
+ Reword the "pseudoref" entry so that it no longer calls them refs, and
+ explain how their additional semantics set them apart. Clarify what
+ FETCH_HEAD records and what its "fetch status" annotation means, and
+ that MERGE_HEAD is also written by git-pull(1) and not only for merge
+ conflicts.
@@ Documentation/glossary-content.adoc: exclude;;
- read via normal Git commands, but cannot be written to by commands like
- linkgit:git-update-ref[1].
+ A name that can be used like a <<def_ref,ref>> to refer to an
-+ <<def_object,object>>, but that is not stored in the same way as refs.
-+ For example, pseudorefs can be passed to linkgit:git-log[1] or
-+ linkgit:git-diff[1], but they cannot be written by
-+ linkgit:git-update-ref[1] or listed by linkgit:git-for-each-ref[1].
++ <<def_object,object>>, but that has additional semantics: it can
++ record more than one object ID and may carry extra metadata. In
++ contrast to <<def_root_ref,root refs>>, pseudorefs are therefore
++ not stored or handled by the ref backend.
+++
++Pseudorefs can be passed to commands such as linkgit:git-log[1] or ++linkgit:git-diff[1], but cannot be written by linkgit:git-update-ref[1] ++or listed by linkgit:git-for-each-ref[1]. When a pseudoref contains more ++than one object ID, using it to refer to an object yields the first one.
+
The following pseudorefs are known to Git:
--
++
-+--
- - FETCH_HEAD is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It
- may refer to multiple object IDs. Each object ID is annotated with metadata
- indicating where it was fetched from and its fetch status.
++ - FETCH_HEAD is written by linkgit:git-fetch[1] or linkgit:git-pull[1]
++ to record the objects that have been fetched. Each object is annotated
++ with the ref and repository it was fetched from and whether it is to be
++ merged when pulling.
- - MERGE_HEAD is written by linkgit:git-merge[1] when resolving merge
- conflicts. It contains all commit IDs which are being merged.
-+--
-++
-+When a pseudoref contains more than one object ID, using it to refer to an -+object yields the first one.
+- - FETCH_HEAD is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It
+- may refer to multiple object IDs. Each object ID is annotated with metadata
+- indicating where it was fetched from and its fetch status.
+-
+- - MERGE_HEAD is written by linkgit:git-merge[1] when resolving merge
+- conflicts. It contains all commit IDs which are being merged.
++ - MERGE_HEAD is written by linkgit:git-merge[1] or linkgit:git-pull[1]
++ to record the commits being merged while a merge is in progress.
[[def_pull]]pull::
Pulling a <<def_branch,branch>> means to <<def_fetch,fetch>> it and
2: 9e1ddc997c ! 2: 0bc902f13d doc: glossary: update per-worktree refs
@@ Metadata
## Commit message ##
doc: glossary: update per-worktree refs
- The "per-worktree ref" entry says that these are only HEAD and refs
- under "refs/bisect/", but that has been out of date since a9be29c981
- (sequencer: make refs generated by the label command worktree-local,
- 2018-04-25). All root refs are per-worktree, as are refs under
- "refs/worktree/" and "refs/rewritten/". Pseudorefs are specific to each
- worktree too.
+ The "per-worktree ref" entry says that only HEAD and refs under
+ "refs/bisect/" are per-worktree, but that has been out of date since
+ a9be29c981 (sequencer: make refs generated by the label command
+ worktree-local, 2018-04-25). All root refs are per-worktree, as are refs
+ under "refs/worktree/" and "refs/rewritten/". Pseudorefs are specific to
+ each worktree too.
Bring the list up to date, and refer to git-worktree(1) for how to access per-worktree refs of other worktrees. In the "worktree" entry,
- describe HEAD as a per-worktree ref and MERGE_HEAD as a pseudoref,
- rather than listing them separately from per-worktree refs.
+ link to "per-worktree ref" instead of listing HEAD and MERGE_HEAD.
3: 6711bf027d ! 3: ac3ed53867 doc: stop calling root refs pseudorefs
@@ Documentation/gitdatamodel.adoc: remote-tracking branches: `refs/remotes/<remote
+
+[[root-refs]]
+root refs::
-+ Git may also create references other than HEAD at the root of the
-+ hierarchy, for example ORIG_HEAD or REBASE_HEAD.
++ Git may create references other than HEAD at the root of the hierarchy,
++ for example ORIG_HEAD or REBASE_HEAD.
+
+[[pseudorefs]]
+pseudorefs::
-+ linkgit:git-fetch[1] and linkgit:git-merge[1] create the so-called
-+ pseudorefs FETCH_HEAD and MERGE_HEAD. They are not references as
-+ such, as they are not stored in the same way, but they can nevertheless
-+ be used to refer to objects in commands such as linkgit:git-log[1] and
-+ linkgit:git-diff[1].
++ linkgit:git-fetch[1], linkgit:git-merge[1] and linkgit:git-pull[1]
++ create the so-called pseudorefs FETCH_HEAD and MERGE_HEAD.
++ They are not references as such, because they are not stored by the
++ ref backend, but they can nevertheless be used to refer to objects in
++ commands such as linkgit:git-log[1] and linkgit:git-diff[1].
++
++See linkgit:gitglossary[7] for further details on root refs and ++pseudorefs.
NOTE: Git may delete objects that aren't "reachable" from any reference or <<reflogs,reflog>>.
4: ea7baa1269 = 4: 2c3f3ab195 refs: stop calling root refs pseudorefs 5: d11ab774ec = 5: d8a825d8cc t: stop calling root refs pseudorefs
Signature · 1 line
2.56.0
PATCH v3 1/5 doc: glossary: add root ref and clarify pseudorefs
The glossary describes refs in the root of the ref hierarchy, but does not actually name them "root refs", even though the term is used elsewhere, for example by "git for-each-ref --include-root-refs". It also defines pseudorefs as refs, yet is_root_ref() deliberately excludes them, as they are not stored or handled by the ref backend.
Add a "root ref" entry, moving the naming rules and the list of irregular root refs there from the "ref" entry. State that pseudorefs are not root refs, and refer to gitrevisions(7) for descriptions of commonly used root refs and pseudorefs.
Reword the "pseudoref" entry so that it no longer calls them refs, and explain how their additional semantics set them apart. Clarify what FETCH_HEAD records and what its "fetch status" annotation means, and that MERGE_HEAD is also written by git-pull(1) and not only for merge conflicts.
--- Documentation/glossary-content.adoc | 84 +++++++++++++++++------------ 1 file changed, 51 insertions(+), 33 deletions(-)
Documentation/glossary-content.adoc +51 -33
@@ -500,18 +500,26 @@ exclude;; unusual refs. [[def_pseudoref]]pseudoref:: - A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to an + <<def_object,object>>, but that has additional semantics: it can + record more than one object ID and may carry extra metadata. In + contrast to <<def_root_ref,root refs>>, pseudorefs are therefore + not stored or handled by the ref backend. ++ +Pseudorefs can be passed to commands such as linkgit:git-log[1] or +linkgit:git-diff[1], but cannot be written by linkgit:git-update-ref[1] +or listed by linkgit:git-for-each-ref[1]. When a pseudoref contains more +than one object ID, using it to refer to an object yields the first one. + The following pseudorefs are known to Git: ++ + - `FETCH_HEAD` is written by linkgit:git-fetch[1] or linkgit:git-pull[1] + to record the objects that have been fetched. Each object is annotated + with the ref and repository it was fetched from and whether it is to be + merged when pulling. - - `FETCH_HEAD` is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It - may refer to multiple object IDs. Each object ID is annotated with metadata - indicating where it was fetched from and its fetch status. - - - `MERGE_HEAD` is written by linkgit:git-merge[1] when resolving merge - conflicts. It contains all commit IDs which are being merged. + - `MERGE_HEAD` is written by linkgit:git-merge[1] or linkgit:git-pull[1] + to record the commits being merged while a merge is in progress. [[def_pull]]pull:: Pulling a <<def_branch,branch>> means to <<def_fetch,fetch>> it and
@@ -562,33 +570,12 @@ The following pseudorefs are known to Git: + The ref namespace is hierarchical. Ref names must either start with `refs/` or be located in the root of -the hierarchy. For the latter, their name must follow these rules: -+ --- - - The name consists of only upper-case characters or underscores. - - - The name ends with "`_HEAD`" or is equal to "`HEAD`". --- -+ -There are some irregular refs in the root of the hierarchy that do not -match these rules. The following list is exhaustive and shall not be -extended in the future: -+ --- - - `AUTO_MERGE` - - - `BISECT_EXPECTED_REV` - - - `NOTES_MERGE_PARTIAL` - - - `NOTES_MERGE_REF` - - - `MERGE_AUTOSTASH` --- +the hierarchy, in which case they must follow the naming rules for +<<def_root_ref,root refs>>. + Different subhierarchies are used for different purposes. For example, the `refs/heads/` hierarchy is used to represent local branches whereas -the `refs/tags/` hierarchy is used to represent local tags.. +the `refs/tags/` hierarchy is used to represent local tags. + See also "REFERENCES" in linkgit:gitdatamodel[7].
@@ -640,6 +627,37 @@ format. See linkgit:git-reflog[1] for details. To throw away part of the development, i.e. to assign the <<def_head,head>> to an earlier <<def_revision,revision>>. +[[def_root_ref]]root ref:: + A <<def_ref,ref>> located in the root of the ref hierarchy, outside + `refs/`. Root ref names must follow these rules: ++ +-- + - The name consists of only upper-case characters or underscores. + + - The name ends with "`_HEAD`" or is equal to "`HEAD`". +-- ++ +The following irregular root refs are exceptions to these rules. This +list is exhaustive and shall not be extended in future: ++ +-- + - `AUTO_MERGE` + + - `BISECT_EXPECTED_REV` + + - `NOTES_MERGE_PARTIAL` + + - `NOTES_MERGE_REF` + + - `MERGE_AUTOSTASH` +-- ++ +<<def_pseudoref,Pseudorefs>> are not considered root refs, even though +they follow the naming rules. ++ +See linkgit:gitrevisions[7] for descriptions of commonly used root refs +and pseudorefs. + [[def_SCM]]SCM:: Source code management (tool).
Signature · 1 line
2.56.0
Re: [PATCH v3 1/5] doc: glossary: add root ref and clarify pseudorefs
Quoted 1 line · Andy Koppe
Reword the "pseudoref" entry so that it no longer calls them refs,
Very very good. They are "pseudo" and are *not* "refs".
Documentation/glossary-content.adoc exclude;;
Quoted 7 lines
[[def_pseudoref]]pseudoref::
Documentation/glossary-content.adoc +3
-3- A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to an + <<def_object,object>>, but that has additional semantics: it can + record more than one object ID and may carry extra metadata.
Good.
Documentation/glossary-content.adoc exclude;; · line 507
Quoted 3 lines
Documentation/glossary-content.adoc +3
-0+ ... In + contrast to <<def_root_ref,root refs>>, pseudorefs are therefore + not stored or handled by the ref backend.
I am not sure if we need to contrast this with root refs, though. Normal refs are also handled by the ref backend after all, but we do not contrast pseudorefs with them, either.
Can we get rid of "In contrast to ..., " and start the sentence with "Therefore, pseudorefs are not..."?
Documentation/glossary-content.adoc The following pseudorefs are known to Git: · line 580
Quoted 9 lines
Documentation/glossary-content.adoc +3
-1+the hierarchy, in which case they must follow the naming rules for +<<def_root_ref,root refs>>. + Different subhierarchies are used for different purposes. For example, the `refs/heads/` hierarchy is used to represent local branches whereas -the `refs/tags/` hierarchy is used to represent local tags.. +the `refs/tags/` hierarchy is used to represent local tags. + See also "REFERENCES" in linkgit:gitdatamodel[7].
Do we want to mention remotes and notes hierarchies, I wonder. If we do not mention remotes, calling things in refs/heads specifically "local" branches is not very useful.
Quoted 14 lines
+[[def_root_ref]]root ref::
Documentation/glossary-content.adoc +13
-0+ A <<def_ref,ref>> located in the root of the ref hierarchy, outside + `refs/`. Root ref names must follow these rules: ++ +-- + - The name consists of only upper-case characters or underscores. + + - The name ends with "`_HEAD`" or is equal to "`HEAD`". +-- ++ +The following irregular root refs are exceptions to these rules. This +list is exhaustive and shall not be extended in future: ++ +--
Documentation/glossary-content.adoc format. See linkgit:git-reflog[1] for details. · line 653
Quoted 10 lines
Documentation/glossary-content.adoc +10
-0+ - `AUTO_MERGE` + + - `BISECT_EXPECTED_REV` + + - `NOTES_MERGE_PARTIAL` + + - `NOTES_MERGE_REF` + + - `MERGE_AUTOSTASH` +--
Good.
Quoted 2 lines
+<<def_pseudoref,Pseudorefs>> are not considered root refs, even though +they follow the naming rules.
Again, I am not sure what the value of saying this is. It somehow feels like elephants are not rhinos even though they are both gray. Why should a confused reader expect it to be considered root refs? We already said that pseudorefs are not even refs upfront.
Other than these "do not contrast pseudorefs with refs or root refs" suggestions on two places, the patch looks ready to me.
Thanks.
This is a tangent but is very deeply related to how "root refs" are handled by the code, so I'll mention it. Random things outside refs/ are usable as if they are refs in the same code path that handles the root refs. E.g.,
$ git update-ref out/mister refs/heads/master
$ git for-each-ref ;# not shown just like root refs
29f5d436870d37a2e36388e96e9175e0a5bf53e9 commit refs/heads/master
$ ls -l .git/out/mister
-rw------- 1 gitster gitster 41 Nov 6 14:01 .git/refo/heads/mister
$ git show --oneline -s out/mister
eddc71c initialWe probably should tighten the system to forbid them, not just from creation side by tightening update-ref but from blind application of the first element of rev_parse_rules[].
In other words, things "outside refs/" that are not at the root level should not be treated by the code as if they were.
As solving this (or leaving it unsolved) has no impact on the status of this patch we are discussing, I'll just leave #leftoverbits mark here.
Re: [PATCH v3 1/5] doc: glossary: add root ref and clarify pseudorefs
Quoted 10 lines · Junio C Hamano
Documentation/glossary-content.adoc exclude;; · line 507
Quoted 3 lines · Andy Koppe
Documentation/glossary-content.adoc +3
-0+ ... In + contrast to <<def_root_ref,root refs>>, pseudorefs are therefore + not stored or handled by the ref backend.I am not sure if we need to contrast this with root refs, though. Normal refs are also handled by the ref backend after all, but we do not contrast pseudorefs with them, either.
…
Quoted 7 lines
Quoted 2 lines
+<<def_pseudoref,Pseudorefs>> are not considered root refs, even though +they follow the naming rules.
Again, I am not sure what the value of saying this is. It somehow feels like elephants are not rhinos even though they are both gray. Why should a confused reader expect it to be considered root refs? We already said that pseudorefs are not even refs upfront.
Fair. Dropped in both places.
Quoted 10 lines
Documentation/glossary-content.adoc The following pseudorefs are known to Git: · line 580
Quoted 6 lines
Different subhierarchies are used for different purposes. For example, the
refs/heads/hierarchy is used to represent local branches whereasDocumentation/glossary-content.adoc +1
-1-the `refs/tags/` hierarchy is used to represent local tags.. +the `refs/tags/` hierarchy is used to represent local tags. + See also "REFERENCES" in linkgit:gitdatamodel[7].Do we want to mention remotes and notes hierarchies, I wonder. If we do not mention remotes, calling things in refs/heads specifically "local" branches is not very useful.
v4 mentions remote-tracking branches alongside local branches and tags. I left out notes, as they seemed less essential examples than the other three, and of course there are more.
Quoted 4 lines
This is a tangent but is very deeply related to how "root refs" are handled by the code, so I'll mention it. Random things outside refs/ are usable as if they are refs in the same code path that handles the root refs.
Yeah, the rules are incompletely enforced. I assumed that was due to backward compat concerns. 3.0 is of course a good opportunity to tighten things, but as you say, separate topic.
PATCH v3 2/5 doc: glossary: update per-worktree refs
In reply to Andy KoppeThe "per-worktree ref" entry says that only HEAD and refs under "refs/bisect/" are per-worktree, but that has been out of date since a9be29c981 (sequencer: make refs generated by the label command worktree-local, 2018-04-25). All root refs are per-worktree, as are refs under "refs/worktree/" and "refs/rewritten/". Pseudorefs are specific to each worktree too.
Bring the list up to date, and refer to git-worktree(1) for how to access per-worktree refs of other worktrees. In the "worktree" entry, link to "per-worktree ref" instead of listing HEAD and MERGE_HEAD.
--- Documentation/glossary-content.adoc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
Documentation/glossary-content.adoc +19 -6
@@ -494,10 +494,23 @@ exclude;; interface than the <<def_plumbing,plumbing>>. [[def_per_worktree_ref]]per-worktree ref:: - Refs that are per-<<def_worktree,worktree>>, rather than - global. This is presently only <<def_HEAD,HEAD>> and any refs - that start with `refs/bisect/`, but might later include other - unusual refs. + A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>, + rather than shared between all worktrees. All <<def_root_ref,root refs>>, + for example <<def_HEAD,HEAD>> and `ORIG_HEAD`, are per-worktree, as are + refs with the following prefixes: ++ +-- + - `refs/bisect/` + + - `refs/rewritten/` + + - `refs/worktree/` +-- ++ +<<def_pseudoref,Pseudorefs>> are also specific to each worktree. ++ +See "REFS" in linkgit:git-worktree[1] for how to access the +per-worktree refs of other worktrees. [[def_pseudoref]]pseudoref:: A name that can be used like a <<def_ref,ref>> to refer to an
@@ -792,5 +805,5 @@ and pseudorefs. "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree - (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, - per-worktree refs and per-worktree configuration file). + (e.g. the index, <<def_per_worktree_ref,per-worktree refs>>, and the + per-worktree configuration file).
Signature · 1 line
2.56.0
Re: [PATCH v3 2/5] doc: glossary: update per-worktree refs
Quoted 14 lines · Andy Koppe
Documentation/glossary-content.adoc +2
-4@@ -494,10 +494,23 @@ exclude;; interface than the <<def_plumbing,plumbing>>. [[def_per_worktree_ref]]per-worktree ref:: - Refs that are per-<<def_worktree,worktree>>, rather than - global. This is presently only <<def_HEAD,HEAD>> and any refs - that start with `refs/bisect/`, but might later include other - unusual refs. + A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>, + rather than shared between all worktrees. All <<def_root_ref,root refs>>,
Documentation/glossary-content.adoc exclude;; · line 508
Quoted 10 lines
Documentation/glossary-content.adoc +10
-0+ for example <<def_HEAD,HEAD>> and `ORIG_HEAD`, are per-worktree, as are + refs with the following prefixes: ++ +-- + - `refs/bisect/` + + - `refs/rewritten/` + + - `refs/worktree/` +--
Very nice. Do we want to mention, like the root refs whose names do not end with HEAD, that we have no plan to add any new ones (in other words, new ones are meant to be created under refs/worktree/)?
Documentation/glossary-content.adoc exclude;; · line 510
Quoted 1 line
Documentation/glossary-content.adoc +1
-0+<<def_pseudoref,Pseudorefs>> are also specific to each worktree.
Prefix the last sentence with "Even though they are not refs, ", perhaps?
PATCH v3 3/5 doc: stop calling root refs pseudorefs
In reply to Andy KoppeSeveral manual pages still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls a root ref. Pseudorefs have since been restricted to FETCH_HEAD and MERGE_HEAD, which are not considered root refs.
Replace "pseudoref" with "root ref" in those pages, giving HEAD and ORIG_HEAD as examples. In git-worktree(1), say that both root refs and pseudorefs are per-worktree, and drop the description of them as being directly under $GIT_DIR, because that does not apply to the reftable backend.
In git-ls-remote(1), describe --refs as omitting refs outside "refs/", since that is what it actually checks. In the example, refer to HEAD, which is the only root ref that git-upload-pack(1) advertises. While there, correct "symbolics" to "symbolic refs".
In git-update-ref(1), drop the incorrect mention of ORIG_HEAD. HEAD is the only root ref that gets a reflog by default. In the description of core.logAllRefUpdates, correct the claim that "always" only applies to refs under "refs/". It applies to root refs too.
Distinguish root refs and pseudorefs in gitdatamodel(7). Lowercase the "other references" list entry there to match the others.
--- Documentation/config/core.adoc | 2 +- Documentation/for-each-ref-options.adoc | 2 +- Documentation/git-ls-remote.adoc | 4 ++-- Documentation/git-update-ref.adoc | 13 ++++++------- Documentation/git-worktree.adoc | 13 ++++++++----- Documentation/gitdatamodel.adoc | 21 +++++++++++++++++---- Documentation/rev-list-options.adoc | 4 ++-- 7 files changed, 37 insertions(+), 22 deletions(-)
Documentation/config/core.adoc +1 -1
@@ -376,7 +376,7 @@ core.logAllRefUpdates:: `refs/heads/`), remote refs (i.e. under `refs/remotes/`), note refs (i.e. under `refs/notes/`), and the symbolic ref `HEAD`. If it is set to `always`, then a missing reflog is automatically - created for any ref under `refs/`. + created for any ref, including root refs such as `ORIG_HEAD`. + This information can be used to determine what commit was the tip of a branch "2 days ago".
Documentation/for-each-ref-options.adoc +1 -1
@@ -73,7 +73,7 @@ TAB %(refname)`. using the same rules as _<pattern>_ above. `--include-root-refs`:: - List root refs (`HEAD` and pseudorefs) apart from regular refs. + Also list root refs, such as `HEAD` or `ORIG_HEAD`. `--start-after=<marker>`:: Allows paginating the output by skipping references up to and including the
Documentation/git-ls-remote.adoc +2 -2
@@ -35,7 +35,7 @@ OPTIONS with other git subcommands. --refs:: - Do not show peeled tags or pseudorefs like `HEAD` in the output. + Do not show peeled tags or refs outside `refs/`. -q:: --quiet::
@@ -118,7 +118,7 @@ line shows the name of the object the tag points at. EXAMPLES -------- -* List all references (including symbolics and pseudorefs), peeling +* List all references (including `HEAD` and symbolic refs), peeling tags: + ----
Documentation/git-update-ref.adoc +6 -7
@@ -163,13 +163,12 @@ still see a subset of the modifications. LOGGING UPDATES --------------- -If config parameter "core.logAllRefUpdates" is true and the ref is one -under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref -like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then -`git update-ref` will append a line to the log file -"$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating -the log name) describing the change in ref value. Log lines are -formatted as: +If config parameter "core.logAllRefUpdates" is true and the ref is +HEAD or one under "refs/heads/", "refs/remotes/" or "refs/notes/", or +if the file "$GIT_DIR/logs/<ref>" exists, then `git update-ref` will +append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all +symbolic refs before creating the log name) describing the change in +ref value. Log lines are formatted as: oldsha1 SP newsha1 SP committer LF
Documentation/git-worktree.adoc +8 -5
@@ -303,11 +303,14 @@ but others are specific to an individual worktree. One example is `HEAD`, which is different for each worktree. This section is about the sharing rules and how to access refs of one worktree from another. -In general, all pseudo refs are per-worktree and all refs starting with -`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly -under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions, -however: refs inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are -not shared. +In general, all root refs and pseudorefs are per-worktree and all refs +starting with `refs/` are shared, except for refs with the following prefixes: + + - `refs/bisect/` + + - `refs/rewritten/` + + - `refs/worktree/` Refs that are per-worktree can still be accessed from another worktree via two special paths, `main-worktree` and `worktrees`. The former gives
Documentation/gitdatamodel.adoc +17 -4
@@ -211,15 +211,28 @@ remote-tracking branches: `refs/remotes/<remote>/<branch>`:: default branch. This is the branch that `git clone` checks out by default. [[other-refs]] -Other references:: +other references:: Git tools may create references anywhere under `refs/`. For example, linkgit:git-stash[1], linkgit:git-bisect[1], and linkgit:git-notes[1] all create their own references in `refs/stash`, `refs/bisect`, etc. Third-party Git tools may also create their own references. -+ -Git may also create references other than `HEAD` at the base of the -hierarchy, like `ORIG_HEAD`. + +[[root-refs]] +root refs:: + Git may create references other than `HEAD` at the root of the hierarchy, + for example `ORIG_HEAD` or `REBASE_HEAD`. + +[[pseudorefs]] +pseudorefs:: + linkgit:git-fetch[1], linkgit:git-merge[1] and linkgit:git-pull[1] + create the so-called pseudorefs `FETCH_HEAD` and `MERGE_HEAD`. + They are not references as such, because they are not stored by the + ref backend, but they can nevertheless be used to refer to objects in + commands such as linkgit:git-log[1] and linkgit:git-diff[1]. + +See linkgit:gitglossary[7] for further details on root refs and +pseudorefs. NOTE: Git may delete objects that aren't "reachable" from any reference or <<reflogs,reflog>>.
Documentation/rev-list-options.adoc +2 -2
@@ -350,8 +350,8 @@ Under `--pretty=reference`, this information will not be shown at all. `--merge`:: Show commits touching conflicted paths in the range `HEAD...<other>`, - where `<other>` is the first existing pseudoref in `MERGE_HEAD`, - `CHERRY_PICK_HEAD`, `REVERT_HEAD` or `REBASE_HEAD`. Only works + where `<other>` is the first of `MERGE_HEAD`, `CHERRY_PICK_HEAD`, + `REVERT_HEAD` or `REBASE_HEAD` that exists. Only works when the index has unmerged entries. This option can be used to show relevant commits when resolving conflicts from a 3-way merge.
Signature · 1 line
2.56.0
Re: [PATCH v3 3/5] doc: stop calling root refs pseudorefs
Quoted 10 lines · Andy Koppe
Several manual pages still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls a root ref. Pseudorefs have since been restricted to
FETCH_HEADandMERGE_HEAD, which are not considered root refs.Replace "pseudoref" with "root ref" in those pages, giving HEAD and
ORIG_HEADas examples. In git-worktree(1), say that both root refs and pseudorefs are per-worktree, and drop the description of them as being directly under $GIT_DIR, because that does not apply to the reftable backend.
Thanks. Clarification of this kind is very very much appreciated.
Documentation/config/core.adoc core.logAllRefUpdates:: · line 379
Quoted 10 lines
Documentation/config/core.adoc +1
-1@@ -376,7 +376,7 @@ core.logAllRefUpdates:: `refs/heads/`), remote refs (i.e. under `refs/remotes/`), note refs (i.e. under `refs/notes/`), and the symbolic ref `HEAD`. If it is set to `always`, then a missing reflog is automatically - created for any ref under `refs/`. + created for any ref, including root refs such as `ORIG_HEAD`.
We are witnessing a grave mistake getting corrected here. Nice.
Documentation/config/core.adoc core.logAllRefUpdates:: · line 381
Quoted 3 lines
Documentation/config/core.adoc +1
-1`--include-root-refs`:: - List root refs (`HEAD` and pseudorefs) apart from regular refs. + Also list root refs, such as `HEAD` or `ORIG_HEAD`.
Good.
Documentation/git-ls-remote.adoc OPTIONS · line 38
Quoted 10 lines
Documentation/git-ls-remote.adoc +1
-1@@ -35,7 +35,7 @@ OPTIONS with other git subcommands. --refs:: - Do not show peeled tags or pseudorefs like `HEAD` in the output. + Do not show peeled tags or refs outside `refs/`.
Hmph, is there a reason for saying "refs outside refs/" (as opposed to "root refs") here?
I _think_ (correct me if I am not remembering right) by default ls-remote shows everything under refs/ (with peeled tags) and HEAD. It is not even "normal refs including root refs", i.e. ORIG_HEAD is not shown. With "--refs", of course ORIG_HEAD is still not shown, but it stops HEAD from getting shown. So "do not show root refs" or "do not show refs outside refs/" are equally slightly broader than needed (meaning: with or without this option restricting further, any root ref other than HEAD, like ORIG_HEAD, are not shown anyway).
Do we even say what are normally shown in this manual page? Perhaps we would want to update the description to say something like
DESCRIPTION
-----------
Displays references available in a remote repository along with the associated commit IDs. By default, all normal refs under refs/ and HEAD are shown. For each tag object, the tag itself and the object it tags (colloquially called peeled) are shown.
upfront, before going to the OPTIONS section to tell the users how to tweak that default?
Documentation/git-ls-remote.adoc line shows the name of the object the tag points at. · line 122
Quoted 7 lines
Documentation/git-ls-remote.adoc +1
-1@@ -118,7 +118,7 @@ line shows the name of the object the tag points at. EXAMPLES -------- -* List all references (including symbolics and pseudorefs), peeling +* List all references (including `HEAD` and symbolic refs), peeling tags:
Here, mentioning symbolic refs as if they are anything special is misleading, no? Symbolic or non-symbolic, refs are refs.
On the other hand, "all references" should logically include (normal) refs under refs/ hierarchy plus "root refs", so "List all references" is technically incorrect. Perhaps give it a bit more correction, e.g.,
List all refs under refs/ and HEAD, peeling tags.
which would make it in line with the updated DESCRIPTION suggested above.
Quoted 11 lines
Documentation/git-update-ref.adoc +0
-3@@ -163,13 +163,12 @@ still see a subset of the modifications. LOGGING UPDATES --------------- -If config parameter "core.logAllRefUpdates" is true and the ref is one -under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref -like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then
Documentation/git-update-ref.adoc still see a subset of the modifications. · line 171
Quoted 10 lines
Documentation/git-update-ref.adoc +6
-4-`git update-ref` will append a line to the log file -"$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating -the log name) describing the change in ref value. Log lines are -formatted as: +If config parameter "core.logAllRefUpdates" is true and the ref is +HEAD or one under "refs/heads/", "refs/remotes/" or "refs/notes/", or +if the file "$GIT_DIR/logs/<ref>" exists, then `git update-ref` will +append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all +symbolic refs before creating the log name) describing the change in +ref value. Log lines are formatted as:
This mention of files and lines may be obsolete in the world with reftable, but I am perfectly fine to leave the correction on that front to another series, and concentrate only on "what is a ref? what is a root ref? and what is a pseudoref?" clarification and nothing else. And for that purpose, the updated text is a perfect fit.
Documentation/git-worktree.adoc but others are specific to an individual worktree. One example is `HEAD`, · line 313
Quoted 10 lines
Documentation/git-worktree.adoc +8
-0+In general, all root refs and pseudorefs are per-worktree and all refs +starting with `refs/` are shared, except for refs with the following prefixes: + + - `refs/bisect/` + + - `refs/rewritten/` + + - `refs/worktree/`
Good; the same comment on "are these frozen?" applies.
Documentation/gitdatamodel.adoc remote-tracking branches: `refs/remotes/<remote>/<branch>`:: · line 214
Quoted 10 lines
Documentation/gitdatamodel.adoc +1
-1@@ -211,15 +211,28 @@ remote-tracking branches: `refs/remotes/<remote>/<branch>`:: default branch. This is the branch that `git clone` checks out by default. [[other-refs]] -Other references:: +other references::
Nice attention to the detail.
Documentation/gitdatamodel.adoc remote-tracking branches: `refs/remotes/<remote>/<branch>`:: · line 222
Quoted 8 lines
Documentation/gitdatamodel.adoc +0
-3Git tools may create references anywhere under `refs/`. For example, linkgit:git-stash[1], linkgit:git-bisect[1], and linkgit:git-notes[1] all create their own references in `refs/stash`, `refs/bisect`, etc. Third-party Git tools may also create their own references. -+ -Git may also create references other than `HEAD` at the base of the -hierarchy, like `ORIG_HEAD`.
Good to get rid of this and adding a separate entry for root refs.
Documentation/gitdatamodel.adoc remote-tracking branches: `refs/remotes/<remote>/<branch>`:: · line 224
Quoted 5 lines
Documentation/gitdatamodel.adoc +5
-0+ +[[root-refs]] +root refs:: + Git may create references other than `HEAD` at the root of the hierarchy, + for example `ORIG_HEAD` or `REBASE_HEAD`.
Is this a good place to talk about their naming conventions? At least we want to have a reference to where we talk about it, I think, just like you did one for pseudorefs below.
Documentation/gitdatamodel.adoc remote-tracking branches: `refs/remotes/<remote>/<branch>`:: · line 235
Quoted 10 lines
Documentation/gitdatamodel.adoc +10
-0+[[pseudorefs]] +pseudorefs:: + linkgit:git-fetch[1], linkgit:git-merge[1] and linkgit:git-pull[1] + create the so-called pseudorefs `FETCH_HEAD` and `MERGE_HEAD`. + They are not references as such, because they are not stored by the + ref backend, but they can nevertheless be used to refer to objects in + commands such as linkgit:git-log[1] and linkgit:git-diff[1]. + +See linkgit:gitglossary[7] for further details on root refs and +pseudorefs.
Great. I do not see a need for so-called here. As technical term, pseudorefs, references, and root refs, all are officially sanctioned words, and there is nothing so-called about them.
Documentation/rev-list-options.adoc Under `--pretty=reference`, this information will not be shown at all. · line 354
Quoted 12 lines
Documentation/rev-list-options.adoc +2
-2@@ -350,8 +350,8 @@ Under `--pretty=reference`, this information will not be shown at all. `--merge`:: Show commits touching conflicted paths in the range `HEAD...<other>`, - where `<other>` is the first existing pseudoref in `MERGE_HEAD`, - `CHERRY_PICK_HEAD`, `REVERT_HEAD` or `REBASE_HEAD`. Only works + where `<other>` is the first of `MERGE_HEAD`, `CHERRY_PICK_HEAD`, + `REVERT_HEAD` or `REBASE_HEAD` that exists. Only works
Phrasing "existing pseudoref" in the original was wrong, but the updated text feels a bit incomplete. "... where <other> is the first ref among X, Y, ... Z that exist" or something like that?
Overall, very welcome clarificaiton.
Re: [PATCH v3 3/5] doc: stop calling root refs pseudorefs
Quoted 8 lines · Junio C Hamano
Quoted 5 lines · Andy Koppe
Several manual pages still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls a root ref. Pseudorefs have since been restricted to
FETCH_HEADandMERGE_HEAD, which are not considered root refs.
Quoted 7 lines
Quoted 5 lines
Replace "pseudoref" with "root ref" in those pages, giving HEAD and
ORIG_HEADas examples. In git-worktree(1), say that both root refs and pseudorefs are per-worktree, and drop the description of them as being directly under $GIT_DIR, because that does not apply to the reftable backend.Thanks. Clarification of this kind is very very much appreciated.
You're welcome, and thanks for the comprehensive review!
Quoted 6 lines
Documentation/git-ls-remote.adoc OPTIONS · line 38
Quoted 3 lines
--refs::
Documentation/git-ls-remote.adoc +1
-1- Do not show peeled tags or pseudorefs like `HEAD` in the output. + Do not show peeled tags or refs outside `refs/`.Hmph, is there a reason for saying "refs outside
refs/" (as opposed to "root refs") here?
Corrected to "Do not show HEAD or peeled tags in the output."
Quoted 10 lines
Do we even say what are normally shown in this manual page? Perhaps we would want to update the description to say something like
DESCRIPTION
-----------
Displays references available in a remote repository along with the associated commit IDs. By default, all normal refs underrefs/andHEADare shown. For each tag object, the tag itself and the object it tags (colloquially calledpeeled) are shown.
I went with this to introduce what peeling means:
Displays references available in a remote repository along with the associated object IDs. By default, HEAD and all refs under refs/ are shown. Annotated tags are also shown peeled, i.e. recursively resolved to the objects they point at.
Quoted 7 lines
Documentation/git-ls-remote.adoc line shows the name of the object the tag points at. · line 122
Quoted 3 lines
Documentation/git-ls-remote.adoc +1
-1-* List all references (including symbolics and pseudorefs), peeling +* List all references (including `HEAD` and symbolic refs), peeling tags:Here, mentioning symbolic refs as if they are anything special is misleading, no? Symbolic or non-symbolic, refs are refs.
Quoted 6 lines
On the other hand, "all references" should logically include (normal) refs under
refs/hierarchy plus "root refs", so "List all references" is technically incorrect. Perhaps give it a bit more correction, e.g.,List all refs under
refs/andHEAD, peeling tags.
I switched it round to avoid suggesting that there's something under HEAD:
List HEAD and all refs under refs/, peeling tags.
Quoted 8 lines
Documentation/gitdatamodel.adoc remote-tracking branches: `refs/remotes/<remote>/<branch>`:: · line 224
Quoted 4 lines
+[[root-refs]]
Documentation/gitdatamodel.adoc +3
-0+root refs:: + Git may create references other than `HEAD` at the root of the hierarchy, + for example `ORIG_HEAD` or `REBASE_HEAD`.Is this a good place to talk about their naming conventions? At least we want to have a reference to where we talk about it, I think, just like you did one for pseudorefs below.
The gitglossary reference below the pseudorefs entry is outside the whole list, so is meant to apply to both root refs and pseudorefs. I've tweaked the wording:
See linkgit:gitglossary[7] for the root ref naming rules and further details on pseudorefs.
Quoted 6 lines
Quoted 6 lines
+[[pseudorefs]]
Documentation/gitdatamodel.adoc +5
-0+pseudorefs:: + linkgit:git-fetch[1], linkgit:git-merge[1] and linkgit:git-pull[1] + create the so-called pseudorefs `FETCH_HEAD` and `MERGE_HEAD`. + They are not references as such, because they are not stored by the + ref backend, but they can nevertheless be used to refer to objects in
Quoted 8 lines
Documentation/gitdatamodel.adoc remote-tracking branches: `refs/remotes/<remote>/<branch>`:: · line 235
Quoted 4 lines
Documentation/gitdatamodel.adoc +4
-0+ commands such as linkgit:git-log[1] and linkgit:git-diff[1]. + +See linkgit:gitglossary[7] for further details on root refs and +pseudorefs.Great. I do not see a need for so-called here. As technical term, pseudorefs, references, and root refs, all are officially sanctioned words, and there is nothing so-called about them.
True. Dropped.
Quoted 10 lines
Documentation/rev-list-options.adoc Under `--pretty=reference`, this information will not be shown at all. · line 354
Quoted 6 lines
--merge::
Show commits touching conflicted paths in the rangeHEAD...<other>,Documentation/rev-list-options.adoc +2
-2- where `<other>` is the first existing pseudoref in `MERGE_HEAD`, - `CHERRY_PICK_HEAD`, `REVERT_HEAD` or `REBASE_HEAD`. Only works + where `<other>` is the first of `MERGE_HEAD`, `CHERRY_PICK_HEAD`, + `REVERT_HEAD` or `REBASE_HEAD` that exists. Only worksPhrasing "existing pseudoref" in the original was wrong, but the updated text feels a bit incomplete. "... where <other> is the first ref among X, Y, ... Z that exist" or something like that?
I just added "one" to avoid calling MERGE_HEAD a ref:
where <other> is the first one of MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD that exists.
PATCH v3 4/5 refs: stop calling root refs pseudorefs
In reply to Andy KoppeSome messages and comments in the code still use "pseudoref" in its old sense of any ref outside of "refs/", whereas the glossary now calls those root refs and restricts pseudorefs to FETCH_HEAD and MERGE_HEAD, so update them.
Bash completion function __git_pseudoref_exists() is not renamed, as there is no obvious term covering both root refs and pseudorefs, and third-party completion scripts might depend on the name.
--- builtin/for-each-ref.c | 2 +- contrib/completion/git-completion.bash | 7 ++++--- refs.h | 13 ++++++------- revision.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
builtin/for-each-ref.c +1 -1
@@ -48,7 +48,7 @@ int for_each_ref_core(int argc, const char **argv, const char *prefix, struct reOPT_NO_CONTAINS (&filter.no_commit,N_ ("print only refs which don't contain the commit" )),OPT_BOOL (0 ,"ignore-case" , &icase,N_ ("sorting and filtering are case insensitive" )),OPT_BOOL (0 ,"stdin" , &from_stdin,N_ ("read reference patterns from stdin" )), -OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include HEAD ref and pseudorefs" )), +OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include root refs" )), OPT_END(), };
contrib/completion/git-completion.bash +4 -3
@@ -147,8 +147,9 @@ __git_eread () test -r "$1" && IFS=$'\r\n' read -r "$2" <"$1" } -# Runs git in $__git_repo_path to determine whether a pseudoref exists. -# 1: The pseudo-ref to search +# Runs git in $__git_repo_path to determine whether a root ref or +# pseudoref exists. +# 1: The ref to check __git_pseudoref_exists () { local ref=$1
@@ -954,7 +955,7 @@ __git_refs () esac } -# Completes refs, short and long, local and remote, symbolic and pseudo. +# Completes refs, short and long, local and remote, symbolic, root and pseudo. # # Usage: __git_complete_refs [<option>]... # --remote=<remote>: The remote to list refs from, can be the name of a
refs.h +6 -7
@@ -85,7 +85,7 @@ enum ref_transaction_error {* Even with RESOLVE_REF_ALLOW_BAD_NAME, names that escape the refs/ * directory and do not consist of all caps and underscores cannot be * resolved. The function returns NULL for such ref names. -* Caps and underscores refers to the pseudorefs, such as HEAD, +* Caps and underscores refers to root refs and pseudorefs, such as HEAD, * FETCH_HEAD and friends, that all live outside of the refs/ directory. */ #define RESOLVE_REF_READING 0x01
@@ -448,8 +448,8 @@ enum refs_for_each_flag {REFS_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 <<2 ),/* -* Include root refs i.e. HEAD and pseudorefs along with the regular -* refs. +* Include root refs, such as HEAD and ORIG_HEAD, along with the +* regular refs. */ REFS_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3), };
@@ -1306,10 +1306,9 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref);int is_root_ref (const char *refname);/* -* Pseudorefs are refs that have different semantics compared to -* "normal" refs. These refs can thus not be stored in the ref backend, -* but must always be accessed via the filesystem. The following refs -* are pseudorefs: +* Pseudorefs are names that can be used like refs, but have different +* semantics. They cannot be stored in the ref backend, but must always +* be accessed via the filesystem. The following are pseudorefs: * * - FETCH_HEAD may contain multiple object IDs, and each one of them * carries additional metadata like where it came from.
revision.c +1 -1
@@ -2000,7 +2000,7 @@ static const char *lookup_other_head(struct object_id *oid)return other_head[i]; } -die (_ ("--merge requires one of the pseudorefs MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" )); +die (_ ("--merge requires one of MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" )); }static void prepare_show_merge (struct rev_info *revs)
Signature · 1 line
2.56.0
Re: [PATCH v3 4/5] refs: stop calling root refs pseudorefs
builtin/for-each-ref.c int for_each_ref_core(int argc, const char **argv, const char *prefix, struct re · line 52
Quoted 11 lines · Andy Koppe
builtin/for-each-ref.c +1
-1@@ -48,7 +48,7 @@ int for_each_ref_core(int argc, const char **argv, const char *prefix, struct reOPT_NO_CONTAINS (&filter.no_commit,N_ ("print only refs which don't contain the commit" )),OPT_BOOL (0 ,"ignore-case" , &icase,N_ ("sorting and filtering are case insensitive" )),OPT_BOOL (0 ,"stdin" , &from_stdin,N_ ("read reference patterns from stdin" )), -OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include HEAD ref and pseudorefs" )), +OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include root refs" )), OPT_END(),
Correct. Not just HEAD, but all root refs are included, e.g., ORIG_HEAD.
builtin/for-each-ref.c int for_each_ref_core(int argc, const char **argv, const char *prefix, struct re · line 53
Quoted 2 lines
builtin/for-each-ref.c +1
-1-die (_ ("--merge requires one of the pseudorefs MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" )); +die (_ ("--merge requires one of MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" ));
If we do not want to think deeply only on this one, just stop after replacing pseudoref with root ref, but do not drop pseudoref and be content. Otherwise you would end up confusing users this way:
let's see the --merge option I read recently about.
$ git log --merge
fatal: --merge requires one of MERGE_HEAD, ...
oh, do I have to give one of these?
$ git log --merge MERGE_HEAD
fatal: ambiguous argument 'MERGE_HEAD': unknown revision or ...
puzzled. why doesn't it work?
It might work to say "one of root refs to exist (e.g., MERGE_HEAD, ...)", or give it a more operational message, like this:
--merge works only in the middle of a merge, rebase, etc.
THanks.
PATCH v3 5/5 t: stop calling root refs pseudorefs
In reply to Andy KoppeSeveral test titles and comments still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls root refs.
Replace "pseudoref" with "root ref" there. In t1400 and t4013, rename the root refs that the tests create from PSEUDOREF to ROOT_REF_HEAD and from REVERSE to REVERSE_HEAD, so that they follow the naming rules for root refs. This includes renaming the expected output file in t4013.
Some tests also still refer to FETCH_HEAD and MERGE_HEAD as "special refs", which was the previous term for "pseudorefs". Correct them.
---
t/show-ref-exists-tests.sh | 4 +-
t/t0600-reffiles-backend.sh | 2 +-
t/t0610-reftable-basics.sh | 2 +-
t/t1400-update-ref.sh | 66 +++++++++----------
t/t1403-show-ref.sh | 2 +-
t/t1460-refs-migrate.sh | 4 +-
t/t4013-diff-various.sh | 6 +-
...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +-
t/t6302-for-each-ref-filter.sh | 4 +-
t/t9902-completion.sh | 4 +-
10 files changed, 48 insertions(+), 48 deletions(-)
rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)t/show-ref-exists-tests.sh +2 -2
@@ -64,11 +64,11 @@ test_expect_success '--exists with directory fails with generic error' ' test_cmp expect err ' -test_expect_success '--exists with non-existent special ref' ' +test_expect_success '--exists with non-existent pseudoref' ' test_expect_code 2 ${git_show_ref_exists} FETCH_HEAD ' -test_expect_success '--exists with existing special ref' ' +test_expect_success '--exists with existing pseudoref' ' test_when_finished "rm .git/FETCH_HEAD" && git rev-parse HEAD >.git/FETCH_HEAD && ${git_show_ref_exists} FETCH_HEAD
t/t0600-reffiles-backend.sh +1 -1
@@ -267,7 +267,7 @@ test_expect_success 'setup worktree' ' ) ' -# Some refs (refs/bisect/*, pseudorefs) are kept per worktree, so they should +# Some refs (refs/bisect/*, root refs) are kept per worktree, so they should # only appear in the for-each-reflog output if it is called from the correct # worktree, which is exercised in this test. This test is poorly written for # multiple reasons: 1) it creates invalidly formatted log entries. 2) it uses
t/t0610-reftable-basics.sh +1 -1
@@ -1156,7 +1156,7 @@ test_expect_success 'worktree: adds worktree with detached HEAD' ' test_cmp expect actual ' -test_expect_success 'fetch: accessing FETCH_HEAD special ref works' ' +test_expect_success 'fetch: accessing FETCH_HEAD pseudoref works' ' test_when_finished "rm -rf repo sub" && git init sub &&
t/t1400-update-ref.sh +33 -33
94 lines not on this page · raw message
t/t1403-show-ref.sh +1 -1
@@ -181,7 +181,7 @@ test_expect_success 'show-ref --verify HEAD' ' test_must_be_empty actual ' -test_expect_success 'show-ref --verify pseudorefs' ' +test_expect_success 'show-ref --verify root refs' ' git update-ref CHERRY_PICK_HEAD HEAD $ZERO_OID && test_when_finished "git update-ref -d CHERRY_PICK_HEAD" && git show-ref -s --verify HEAD >actual &&
t/t1460-refs-migrate.sh +2 -2
@@ -170,7 +170,7 @@ do test_cmp expect actual ' - test_expect_success "$from_format -> $to_format: pseudo-refs" ' + test_expect_success "$from_format -> $to_format: root refs" ' test_when_finished "rm -rf repo" && git init --ref-storage-format=$from_format repo && test_commit -C repo initial &&
@@ -178,7 +178,7 @@ do test_migration repo "$to_format" ' - test_expect_success "$from_format -> $to_format: special refs are left alone" ' + test_expect_success "$from_format -> $to_format: pseudorefs are left alone" ' test_when_finished "rm -rf repo" && git init --ref-storage-format=$from_format repo && test_commit -C repo initial &&
t/t4013-diff-various.sh +3 -3
@@ -115,10 +115,10 @@ test_expect_success setup ' git checkout -f main && # Same merge as main, but with parents reversed. Hide it in a - # pseudo-ref to avoid impacting tests with --all. + # root ref to avoid impacting tests with --all. commit=$(echo reverse | git commit-tree -p main^2 -p main^1 main^{tree}) && - git update-ref REVERSE $commit && + git update-ref REVERSE_HEAD $commit && git config diff.renames false &&
@@ -328,7 +328,7 @@ diff-tree --cc --stat --summary main diff-tree -c --stat --summary side diff-tree --cc --stat --summary side diff-tree --cc --shortstat main -diff-tree --cc --summary REVERSE +diff-tree --cc --summary REVERSE_HEAD # improved by Timo's patch diff-tree --cc --patch-with-stat main # improved by Timo's patch
t/t4013/diff.diff-tree_--cc_--summary_REVERSE_HEAD renamed from t/t4013/diff.diff-tree_--cc_--summary_REVERSE +1 -1
@@ -1,4 +1,4 @@ -$ git diff-tree --cc --summary REVERSE +$ git diff-tree --cc --summary REVERSE_HEAD 2562325a7ee916efb2481da93073b82cec801cbc create mode 100644 file1 delete mode 100644 file2
t/t6302-for-each-ref-filter.sh +2 -2
@@ -31,7 +31,7 @@ test_expect_success 'setup some history and refs' ' git update-ref refs/odd/spot main ' -test_expect_success '--include-root-refs pattern prints pseudorefs' ' +test_expect_success '--include-root-refs pattern prints root refs' ' cat >expect <<-\EOF && HEAD ORIG_HEAD
@@ -52,7 +52,7 @@ test_expect_success '--include-root-refs pattern prints pseudorefs' ' test_cmp expect actual ' -test_expect_success '--include-root-refs pattern does not print special refs' ' +test_expect_success '--include-root-refs pattern does not print pseudorefs' ' test_when_finished "rm -rf repo" && git init repo && (
t/t9902-completion.sh +2 -2
@@ -2693,13 +2693,13 @@ test_expect_success 'checkout matches case insensitively with GIT_COMPLETION_IGN ) ' -test_expect_success 'checkout completes pseudo refs' ' +test_expect_success 'checkout completes root refs' ' test_completion "git checkout H" <<-\EOF HEAD Z EOF ' -test_expect_success 'checkout completes pseudo refs case insensitively with GIT_COMPLETION_IGNORE_CASE' ' +test_expect_success 'checkout completes root refs case insensitively with GIT_COMPLETION_IGNORE_CASE' ' ( GIT_COMPLETION_IGNORE_CASE=1 && test_completion "git checkout h" <<-\EOF
Signature · 1 line
2.56.0
v4 cover root refs vs pseudorefs
In reply to Andy KoppeChanges in v4:
- Glossary: stop contrasting pseudorefs with root refs, mention remote-tracking branches in the "ref" entry, and state that the list of per-worktree ref prefixes will not be extended.
- git-ls-remote(1): describe what is shown by default, including peeling, and describe --refs and the example in those terms.
- gitdatamodel(7): mention the root ref naming rules, and drop "so-called".
- Reword the description and error message of rev-list --merge.
Andy Koppe (5):
doc: glossary: add root ref and clarify pseudorefs
doc: glossary: update per-worktree refs
doc: stop calling root refs pseudorefs
refs: stop calling root refs pseudorefs
t: stop calling root refs pseudorefs
Documentation/config/core.adoc | 2 +-
Documentation/for-each-ref-options.adoc | 2 +-
Documentation/git-ls-remote.adoc | 9 +-
Documentation/git-update-ref.adoc | 13 +--
Documentation/git-worktree.adoc | 16 ++-
Documentation/gitdatamodel.adoc | 22 +++-
Documentation/glossary-content.adoc | 110 +++++++++++-------
Documentation/rev-list-options.adoc | 4 +-
builtin/for-each-ref.c | 2 +-
contrib/completion/git-completion.bash | 7 +-
refs.h | 13 +--
revision.c | 2 +-
t/show-ref-exists-tests.sh | 4 +-
t/t0600-reffiles-backend.sh | 2 +-
t/t0610-reftable-basics.sh | 2 +-
t/t1400-update-ref.sh | 66 +++++------
t/t1403-show-ref.sh | 2 +-
t/t1460-refs-migrate.sh | 4 +-
t/t4013-diff-various.sh | 6 +-
...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +-
t/t6302-for-each-ref-filter.sh | 4 +-
t/t9902-completion.sh | 4 +-
22 files changed, 174 insertions(+), 124 deletions(-)
rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)Range-diff against v3:
1: 5630c671db ! 1: e3f2ee816f doc: glossary: add root ref and clarify pseudorefs
@@ Commit message
them, as they are not stored or handled by the ref backend.
Add a "root ref" entry, moving the naming rules and the list of
- irregular root refs there from the "ref" entry. State that pseudorefs
- are not root refs, and refer to gitrevisions(7) for descriptions of
- commonly used root refs and pseudorefs.
+ irregular root refs there from the "ref" entry, and refer to
+ gitrevisions(7) for descriptions of commonly used root refs. In the
+ "ref" entry, mention remote-tracking branches alongside local branches
+ and tags.
Reword the "pseudoref" entry so that it no longer calls them refs, and explain how their additional semantics set them apart. Clarify what
@@ Documentation/glossary-content.adoc: exclude;;
- linkgit:git-update-ref[1].
+ A name that can be used like a <<def_ref,ref>> to refer to an
+ <<def_object,object>>, but that has additional semantics: it can
-+ record more than one object ID and may carry extra metadata. In
-+ contrast to <<def_root_ref,root refs>>, pseudorefs are therefore
-+ not stored or handled by the ref backend.
++ record more than one object ID and may carry extra metadata.
++ Therefore, pseudorefs are not stored or handled by the ref backend.
++
+Pseudorefs can be passed to commands such as linkgit:git-log[1] or +linkgit:git-diff[1], but cannot be written by linkgit:git-update-ref[1]
@@ Documentation/glossary-content.adoc: The following pseudorefs are known to Git:
+<<def_root_ref,root refs>>.
+
Different subhierarchies are used for different purposes. For example,
- the refs/heads/ hierarchy is used to represent local branches whereas +-the refs/heads/ hierarchy is used to represent local branches whereas -the refs/tags/ hierarchy is used to represent local tags..
-+the refs/tags/ hierarchy is used to represent local tags. ++local branches are stored under refs/heads/, remote-tracking branches ++under refs/remotes/, and tags under refs/tags/.
+
See also "REFERENCES" in linkgit:gitdatamodel[7].
@@ Documentation/glossary-content.adoc: format. See linkgit:git-reflog[1] for detai
+ - MERGE_AUTOSTASH
+--
++
-+<<def_pseudoref,Pseudorefs>> are not considered root refs, even though -+they follow the naming rules.
-++
-+See linkgit:gitrevisions[7] for descriptions of commonly used root refs -+and pseudorefs.
++See linkgit:gitrevisions[7] for descriptions of commonly used root refs.
+
[[def_SCM]]SCM::
Source code management (tool).
2: 0bc902f13d ! 2: ccc3554410 doc: glossary: update per-worktree refs
@@ Commit message
under "refs/worktree/" and "refs/rewritten/". Pseudorefs are specific to each worktree too.
- Bring the list up to date, and refer to git-worktree(1) for how to
- access per-worktree refs of other worktrees. In the "worktree" entry,
- link to "per-worktree ref" instead of listing HEAD and MERGE_HEAD.
+ Bring the list up to date, and state that it will not be extended, as
+ new per-worktree refs are meant to go under "refs/worktree/" since
+ 8aff1a9ca5 (Add a place for (not) sharing stuff between worktrees,
+ 2018-09-29).
@@ Documentation/glossary-content.adoc: exclude;;
+ - refs/worktree/
+--
++
-+<<def_pseudoref,Pseudorefs>> are also specific to each worktree. ++This list will not be extended in future. Any new per-worktree refs shall be ++created under refs/worktree/.
+++
++Even though they are not refs, <<def_pseudoref,pseudorefs>> are also ++specific to each worktree.
++
+See "REFS" in linkgit:git-worktree[1] for how to access the +per-worktree refs of other worktrees.
[[def_pseudoref]]pseudoref::
A name that can be used like a <<def_ref,ref>> to refer to an
-@@ Documentation/glossary-content.adoc: and pseudorefs.
+@@ Documentation/glossary-content.adoc: See linkgit:gitrevisions[7] for descriptions of commonly used root refs.
"working tree" and repository metadata, most of which are
shared among other worktrees of a single repository, and
some of which are maintained separately per worktree
3: ac3ed53867 ! 3: bc29d66748 doc: stop calling root refs pseudorefs
@@ Commit message
ORIG_HEAD as examples. In git-worktree(1), say that both root refs and
pseudorefs are per-worktree, and drop the description of them as being
directly under $GIT_DIR, because that does not apply to the reftable
- backend.
+ backend. As in the glossary, state that the list of per-worktree
+ prefixes will not be extended.
- In git-ls-remote(1), describe --refs as omitting refs outside "refs/",
- since that is what it actually checks. In the example, refer to HEAD,
- which is the only root ref that git-upload-pack(1) advertises. While
- there, correct "symbolics" to "symbolic refs".
+ In git-ls-remote(1), state that HEAD and refs under "refs/" are shown
+ by default, and describe --refs and the example in those terms rather
+ than in terms of pseudorefs. Say "object IDs" instead of "commit IDs",
+ as tag objects are shown too.
In git-update-ref(1), drop the incorrect mention of ORIG_HEAD. HEAD is the only root ref that gets a reflog by default. In the description of
@@ Documentation/for-each-ref-options.adoc: TAB %(refname)`.
Allows paginating the output by skipping references up to and including the
## Documentation/git-ls-remote.adoc ##
+@@ Documentation/git-ls-remote.adoc: SYNOPSIS
+ DESCRIPTION
+ -----------
+ Displays references available in a remote repository along with the associated +-commit IDs.
++object IDs. By default, HEAD and all refs under refs/ are shown. ++Annotated tags are also shown peeled, i.e. recursively resolved to the objects ++they point at.
+
+
+ OPTIONS
@@ Documentation/git-ls-remote.adoc: OPTIONS
with other git subcommands.
--refs::
- Do not show peeled tags or pseudorefs like HEAD in the output.
-+ Do not show peeled tags or refs outside refs/.
++ Do not show HEAD or peeled tags in the output.
-q::
--quiet::
@@ Documentation/git-ls-remote.adoc: line shows the name of the object the tag poin
--------
-* List all references (including symbolics and pseudorefs), peeling
-+* List all references (including HEAD and symbolic refs), peeling
- tags:
+- tags:
++* List HEAD and all refs under refs/, peeling tags:
+
----
+ $ git ls-remote
## Documentation/git-update-ref.adoc ##
@@ Documentation/git-update-ref.adoc: still see a subset of the modifications.
@@ Documentation/git-worktree.adoc: but others are specific to an individual worktr
+ - refs/rewritten/
+
+ - refs/worktree/
++
++This list will not be extended in future. Any new per-worktree refs shall be ++created under refs/worktree/.
Refs that are per-worktree can still be accessed from another worktree via two special paths, main-worktree and worktrees. The former gives
@@ Documentation/gitdatamodel.adoc: remote-tracking branches: `refs/remotes/<remote
+[[root-refs]]
+root refs::
+ Git may create references other than HEAD at the root of the hierarchy,
-+ for example ORIG_HEAD or REBASE_HEAD.
++ for example ORIG_HEAD or REBASE_HEAD. Their names must follow
++ special rules.
+
+[[pseudorefs]]
+pseudorefs::
+ linkgit:git-fetch[1], linkgit:git-merge[1] and linkgit:git-pull[1]
-+ create the so-called pseudorefs FETCH_HEAD and MERGE_HEAD.
++ create the pseudorefs FETCH_HEAD and MERGE_HEAD.
+ They are not references as such, because they are not stored by the
+ ref backend, but they can nevertheless be used to refer to objects in
+ commands such as linkgit:git-log[1] and linkgit:git-diff[1].
+
-+See linkgit:gitglossary[7] for further details on root refs and -+pseudorefs.
++See linkgit:gitglossary[7] for the root ref naming rules and further details ++on pseudorefs.
NOTE: Git may delete objects that aren't "reachable" from any reference or <<reflogs,reflog>>.
@@ Documentation/rev-list-options.adoc: Under --pretty=reference, this informatio
Show commits touching conflicted paths in the range HEAD...<other>,
- where <other> is the first existing pseudoref in MERGE_HEAD,
- CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD. Only works
-+ where <other> is the first of MERGE_HEAD, CHERRY_PICK_HEAD,
++ where <other> is the first one of MERGE_HEAD, CHERRY_PICK_HEAD,
+ REVERT_HEAD or REBASE_HEAD that exists. Only works
when the index has unmerged entries. This option can be used to show relevant commits when resolving conflicts from a 3-way merge.
4: 2c3f3ab195 ! 4: 610138169d refs: stop calling root refs pseudorefs
@@ Commit message
those root refs and restricts pseudorefs to FETCH_HEAD and MERGE_HEAD, so update them.
+ The "--merge" error message called MERGE_HEAD, CHERRY_PICK_HEAD,
+ REVERT_HEAD and REBASE_HEAD pseudorefs, but MERGE_HEAD is the only
+ actual pseudoref among them, and merely listing their names suggests
+ that one of them should be given as an argument. Instead, say that an
+ ongoing merge, cherry-pick, revert or rebase is required.
+
Bash completion function __git_pseudoref_exists() is not renamed, as there is no obvious term covering both root refs and pseudorefs, and third-party completion scripts might depend on the name.
@@ contrib/completion/git-completion.bash: __git_eread ()
-# 1: The pseudo-ref to search
+# Runs git in $__git_repo_path to determine whether a root ref or +# pseudoref exists.
-+# 1: The ref to check
++# 1: The name to check
__git_pseudoref_exists ()
{
local ref=$1
@@ refs.h: void update_ref_namespace(enum ref_namespace namespace, char *ref);
- * "normal" refs. These refs can thus not be stored in the ref backend,
- * but must always be accessed via the filesystem. The following refs
- * are pseudorefs:
-+ * Pseudorefs are names that can be used like refs, but have different ++ * Pseudorefs are names that can be used like refs, but have additional
+ * semantics. They cannot be stored in the ref backend, but must always
+ * be accessed via the filesystem. The following are pseudorefs:
*
@@ revision.c: static const char *lookup_other_head(struct object_id *oid)
}
- die(_("--merge requires one of the pseudorefs MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD"));
-+ die(_("--merge requires one of MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD"));
++ die(_("--merge requires an ongoing merge, cherry-pick, revert or rebase"));
}
static void prepare_show_merge(struct rev_info *revs)
5: d8a825d8cc = 5: 368ea8b6bc t: stop calling root refs pseudorefs
Signature · 1 line
2.56.0
PATCH v4 1/5 doc: glossary: add root ref and clarify pseudorefs
The glossary describes refs in the root of the ref hierarchy, but does not actually name them "root refs", even though the term is used elsewhere, for example by "git for-each-ref --include-root-refs". It also defines pseudorefs as refs, yet is_root_ref() deliberately excludes them, as they are not stored or handled by the ref backend.
Add a "root ref" entry, moving the naming rules and the list of irregular root refs there from the "ref" entry, and refer to gitrevisions(7) for descriptions of commonly used root refs. In the "ref" entry, mention remote-tracking branches alongside local branches and tags.
Reword the "pseudoref" entry so that it no longer calls them refs, and explain how their additional semantics set them apart. Clarify what FETCH_HEAD records and what its "fetch status" annotation means, and that MERGE_HEAD is also written by git-pull(1) and not only for merge conflicts.
--- Documentation/glossary-content.adoc | 81 +++++++++++++++++------------ 1 file changed, 47 insertions(+), 34 deletions(-)
Documentation/glossary-content.adoc +47 -34
@@ -500,18 +500,25 @@ exclude;; unusual refs. [[def_pseudoref]]pseudoref:: - A ref that has different semantics than normal refs. These refs can be - read via normal Git commands, but cannot be written to by commands like - linkgit:git-update-ref[1]. + A name that can be used like a <<def_ref,ref>> to refer to an + <<def_object,object>>, but that has additional semantics: it can + record more than one object ID and may carry extra metadata. + Therefore, pseudorefs are not stored or handled by the ref backend. ++ +Pseudorefs can be passed to commands such as linkgit:git-log[1] or +linkgit:git-diff[1], but cannot be written by linkgit:git-update-ref[1] +or listed by linkgit:git-for-each-ref[1]. When a pseudoref contains more +than one object ID, using it to refer to an object yields the first one. + The following pseudorefs are known to Git: ++ + - `FETCH_HEAD` is written by linkgit:git-fetch[1] or linkgit:git-pull[1] + to record the objects that have been fetched. Each object is annotated + with the ref and repository it was fetched from and whether it is to be + merged when pulling. - - `FETCH_HEAD` is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It - may refer to multiple object IDs. Each object ID is annotated with metadata - indicating where it was fetched from and its fetch status. - - - `MERGE_HEAD` is written by linkgit:git-merge[1] when resolving merge - conflicts. It contains all commit IDs which are being merged. + - `MERGE_HEAD` is written by linkgit:git-merge[1] or linkgit:git-pull[1] + to record the commits being merged while a merge is in progress. [[def_pull]]pull:: Pulling a <<def_branch,branch>> means to <<def_fetch,fetch>> it and
@@ -562,33 +569,12 @@ The following pseudorefs are known to Git: + The ref namespace is hierarchical. Ref names must either start with `refs/` or be located in the root of -the hierarchy. For the latter, their name must follow these rules: -+ --- - - The name consists of only upper-case characters or underscores. - - - The name ends with "`_HEAD`" or is equal to "`HEAD`". --- -+ -There are some irregular refs in the root of the hierarchy that do not -match these rules. The following list is exhaustive and shall not be -extended in the future: -+ --- - - `AUTO_MERGE` - - - `BISECT_EXPECTED_REV` - - - `NOTES_MERGE_PARTIAL` - - - `NOTES_MERGE_REF` - - - `MERGE_AUTOSTASH` --- +the hierarchy, in which case they must follow the naming rules for +<<def_root_ref,root refs>>. + Different subhierarchies are used for different purposes. For example, -the `refs/heads/` hierarchy is used to represent local branches whereas -the `refs/tags/` hierarchy is used to represent local tags.. +local branches are stored under `refs/heads/`, remote-tracking branches +under `refs/remotes/`, and tags under `refs/tags/`. + See also "REFERENCES" in linkgit:gitdatamodel[7].
@@ -640,6 +626,33 @@ format. See linkgit:git-reflog[1] for details. To throw away part of the development, i.e. to assign the <<def_head,head>> to an earlier <<def_revision,revision>>. +[[def_root_ref]]root ref:: + A <<def_ref,ref>> located in the root of the ref hierarchy, outside + `refs/`. Root ref names must follow these rules: ++ +-- + - The name consists of only upper-case characters or underscores. + + - The name ends with "`_HEAD`" or is equal to "`HEAD`". +-- ++ +The following irregular root refs are exceptions to these rules. This +list is exhaustive and shall not be extended in future: ++ +-- + - `AUTO_MERGE` + + - `BISECT_EXPECTED_REV` + + - `NOTES_MERGE_PARTIAL` + + - `NOTES_MERGE_REF` + + - `MERGE_AUTOSTASH` +-- ++ +See linkgit:gitrevisions[7] for descriptions of commonly used root refs. + [[def_SCM]]SCM:: Source code management (tool).
Signature · 1 line
2.56.0
PATCH v4 2/5 doc: glossary: update per-worktree refs
In reply to Andy KoppeThe "per-worktree ref" entry says that only HEAD and refs under "refs/bisect/" are per-worktree, but that has been out of date since a9be29c981 (sequencer: make refs generated by the label command worktree-local, 2018-04-25). All root refs are per-worktree, as are refs under "refs/worktree/" and "refs/rewritten/". Pseudorefs are specific to each worktree too.
Bring the list up to date, and state that it will not be extended, as new per-worktree refs are meant to go under "refs/worktree/" since 8aff1a9ca5 (Add a place for (not) sharing stuff between worktrees, 2018-09-29).
--- Documentation/glossary-content.adoc | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
Documentation/glossary-content.adoc +23 -6
@@ -494,10 +494,27 @@ exclude;; interface than the <<def_plumbing,plumbing>>. [[def_per_worktree_ref]]per-worktree ref:: - Refs that are per-<<def_worktree,worktree>>, rather than - global. This is presently only <<def_HEAD,HEAD>> and any refs - that start with `refs/bisect/`, but might later include other - unusual refs. + A <<def_ref,ref>> that is specific to a <<def_worktree,worktree>>, + rather than shared between all worktrees. All <<def_root_ref,root refs>>, + for example <<def_HEAD,HEAD>> and `ORIG_HEAD`, are per-worktree, as are + refs with the following prefixes: ++ +-- + - `refs/bisect/` + + - `refs/rewritten/` + + - `refs/worktree/` +-- ++ +This list will not be extended in future. Any new per-worktree refs shall be +created under `refs/worktree/`. ++ +Even though they are not refs, <<def_pseudoref,pseudorefs>> are also +specific to each worktree. ++ +See "REFS" in linkgit:git-worktree[1] for how to access the +per-worktree refs of other worktrees. [[def_pseudoref]]pseudoref:: A name that can be used like a <<def_ref,ref>> to refer to an
@@ -787,5 +804,5 @@ See linkgit:gitrevisions[7] for descriptions of commonly used root refs. "working tree" and repository metadata, most of which are shared among other worktrees of a single repository, and some of which are maintained separately per worktree - (e.g. the index, HEAD and pseudorefs like MERGE_HEAD, - per-worktree refs and per-worktree configuration file). + (e.g. the index, <<def_per_worktree_ref,per-worktree refs>>, and the + per-worktree configuration file).
Signature · 1 line
2.56.0
PATCH v4 3/5 doc: stop calling root refs pseudorefs
In reply to Andy KoppeSeveral manual pages still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls a root ref. Pseudorefs have since been restricted to FETCH_HEAD and MERGE_HEAD, which are not considered root refs.
Replace "pseudoref" with "root ref" in those pages, giving HEAD and ORIG_HEAD as examples. In git-worktree(1), say that both root refs and pseudorefs are per-worktree, and drop the description of them as being directly under $GIT_DIR, because that does not apply to the reftable backend. As in the glossary, state that the list of per-worktree prefixes will not be extended.
In git-ls-remote(1), state that HEAD and refs under "refs/" are shown by default, and describe --refs and the example in those terms rather than in terms of pseudorefs. Say "object IDs" instead of "commit IDs", as tag objects are shown too.
In git-update-ref(1), drop the incorrect mention of ORIG_HEAD. HEAD is the only root ref that gets a reflog by default. In the description of core.logAllRefUpdates, correct the claim that "always" only applies to refs under "refs/". It applies to root refs too.
Distinguish root refs and pseudorefs in gitdatamodel(7). Lowercase the "other references" list entry there to match the others.
--- Documentation/config/core.adoc | 2 +- Documentation/for-each-ref-options.adoc | 2 +- Documentation/git-ls-remote.adoc | 9 +++++---- Documentation/git-update-ref.adoc | 13 ++++++------- Documentation/git-worktree.adoc | 16 +++++++++++----- Documentation/gitdatamodel.adoc | 22 ++++++++++++++++++---- Documentation/rev-list-options.adoc | 4 ++-- 7 files changed, 44 insertions(+), 24 deletions(-)
Documentation/config/core.adoc +1 -1
@@ -376,7 +376,7 @@ core.logAllRefUpdates:: `refs/heads/`), remote refs (i.e. under `refs/remotes/`), note refs (i.e. under `refs/notes/`), and the symbolic ref `HEAD`. If it is set to `always`, then a missing reflog is automatically - created for any ref under `refs/`. + created for any ref, including root refs such as `ORIG_HEAD`. + This information can be used to determine what commit was the tip of a branch "2 days ago".
Documentation/for-each-ref-options.adoc +1 -1
@@ -73,7 +73,7 @@ TAB %(refname)`. using the same rules as _<pattern>_ above. `--include-root-refs`:: - List root refs (`HEAD` and pseudorefs) apart from regular refs. + Also list root refs, such as `HEAD` or `ORIG_HEAD`. `--start-after=<marker>`:: Allows paginating the output by skipping references up to and including the
Documentation/git-ls-remote.adoc +5 -4
@@ -16,7 +16,9 @@ SYNOPSIS DESCRIPTION ----------- Displays references available in a remote repository along with the associated -commit IDs. +object IDs. By default, `HEAD` and all refs under `refs/` are shown. +Annotated tags are also shown peeled, i.e. recursively resolved to the objects +they point at. OPTIONS
@@ -35,7 +37,7 @@ OPTIONS with other git subcommands. --refs:: - Do not show peeled tags or pseudorefs like `HEAD` in the output. + Do not show `HEAD` or peeled tags in the output. -q:: --quiet::
@@ -118,8 +120,7 @@ line shows the name of the object the tag points at. EXAMPLES -------- -* List all references (including symbolics and pseudorefs), peeling - tags: +* List `HEAD` and all refs under `refs/`, peeling tags: + ---- $ git ls-remote
Documentation/git-update-ref.adoc +6 -7
@@ -163,13 +163,12 @@ still see a subset of the modifications. LOGGING UPDATES --------------- -If config parameter "core.logAllRefUpdates" is true and the ref is one -under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref -like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/<ref>" exists then -`git update-ref` will append a line to the log file -"$GIT_DIR/logs/<ref>" (dereferencing all symbolic refs before creating -the log name) describing the change in ref value. Log lines are -formatted as: +If config parameter "core.logAllRefUpdates" is true and the ref is +HEAD or one under "refs/heads/", "refs/remotes/" or "refs/notes/", or +if the file "$GIT_DIR/logs/<ref>" exists, then `git update-ref` will +append a line to the log file "$GIT_DIR/logs/<ref>" (dereferencing all +symbolic refs before creating the log name) describing the change in +ref value. Log lines are formatted as: oldsha1 SP newsha1 SP committer LF
Documentation/git-worktree.adoc +11 -5
@@ -303,11 +303,17 @@ but others are specific to an individual worktree. One example is `HEAD`, which is different for each worktree. This section is about the sharing rules and how to access refs of one worktree from another. -In general, all pseudo refs are per-worktree and all refs starting with -`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly -under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions, -however: refs inside `refs/bisect`, `refs/worktree` and `refs/rewritten` are -not shared. +In general, all root refs and pseudorefs are per-worktree and all refs +starting with `refs/` are shared, except for refs with the following prefixes: + + - `refs/bisect/` + + - `refs/rewritten/` + + - `refs/worktree/` + +This list will not be extended in future. Any new per-worktree refs shall be +created under `refs/worktree/`. Refs that are per-worktree can still be accessed from another worktree via two special paths, `main-worktree` and `worktrees`. The former gives
Documentation/gitdatamodel.adoc +18 -4
@@ -211,15 +211,29 @@ remote-tracking branches: `refs/remotes/<remote>/<branch>`:: default branch. This is the branch that `git clone` checks out by default. [[other-refs]] -Other references:: +other references:: Git tools may create references anywhere under `refs/`. For example, linkgit:git-stash[1], linkgit:git-bisect[1], and linkgit:git-notes[1] all create their own references in `refs/stash`, `refs/bisect`, etc. Third-party Git tools may also create their own references. -+ -Git may also create references other than `HEAD` at the base of the -hierarchy, like `ORIG_HEAD`. + +[[root-refs]] +root refs:: + Git may create references other than `HEAD` at the root of the hierarchy, + for example `ORIG_HEAD` or `REBASE_HEAD`. Their names must follow + special rules. + +[[pseudorefs]] +pseudorefs:: + linkgit:git-fetch[1], linkgit:git-merge[1] and linkgit:git-pull[1] + create the pseudorefs `FETCH_HEAD` and `MERGE_HEAD`. + They are not references as such, because they are not stored by the + ref backend, but they can nevertheless be used to refer to objects in + commands such as linkgit:git-log[1] and linkgit:git-diff[1]. + +See linkgit:gitglossary[7] for the root ref naming rules and further details +on pseudorefs. NOTE: Git may delete objects that aren't "reachable" from any reference or <<reflogs,reflog>>.
Documentation/rev-list-options.adoc +2 -2
@@ -350,8 +350,8 @@ Under `--pretty=reference`, this information will not be shown at all. `--merge`:: Show commits touching conflicted paths in the range `HEAD...<other>`, - where `<other>` is the first existing pseudoref in `MERGE_HEAD`, - `CHERRY_PICK_HEAD`, `REVERT_HEAD` or `REBASE_HEAD`. Only works + where `<other>` is the first one of `MERGE_HEAD`, `CHERRY_PICK_HEAD`, + `REVERT_HEAD` or `REBASE_HEAD` that exists. Only works when the index has unmerged entries. This option can be used to show relevant commits when resolving conflicts from a 3-way merge.
Signature · 1 line
2.56.0
PATCH v4 4/5 refs: stop calling root refs pseudorefs
In reply to Andy KoppeSome messages and comments in the code still use "pseudoref" in its old sense of any ref outside of "refs/", whereas the glossary now calls those root refs and restricts pseudorefs to FETCH_HEAD and MERGE_HEAD, so update them.
The "--merge" error message called MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD and REBASE_HEAD pseudorefs, but MERGE_HEAD is the only actual pseudoref among them, and merely listing their names suggests that one of them should be given as an argument. Instead, say that an ongoing merge, cherry-pick, revert or rebase is required.
Bash completion function __git_pseudoref_exists() is not renamed, as there is no obvious term covering both root refs and pseudorefs, and third-party completion scripts might depend on the name.
--- builtin/for-each-ref.c | 2 +- contrib/completion/git-completion.bash | 7 ++++--- refs.h | 13 ++++++------- revision.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
builtin/for-each-ref.c +1 -1
@@ -48,7 +48,7 @@ int for_each_ref_core(int argc, const char **argv, const char *prefix, struct reOPT_NO_CONTAINS (&filter.no_commit,N_ ("print only refs which don't contain the commit" )),OPT_BOOL (0 ,"ignore-case" , &icase,N_ ("sorting and filtering are case insensitive" )),OPT_BOOL (0 ,"stdin" , &from_stdin,N_ ("read reference patterns from stdin" )), -OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include HEAD ref and pseudorefs" )), +OPT_BOOL (0 ,"include-root-refs" , &include_root_refs,N_ ("also include root refs" )), OPT_END(), };
contrib/completion/git-completion.bash +4 -3
@@ -147,8 +147,9 @@ __git_eread () test -r "$1" && IFS=$'\r\n' read -r "$2" <"$1" } -# Runs git in $__git_repo_path to determine whether a pseudoref exists. -# 1: The pseudo-ref to search +# Runs git in $__git_repo_path to determine whether a root ref or +# pseudoref exists. +# 1: The name to check __git_pseudoref_exists () { local ref=$1
@@ -954,7 +955,7 @@ __git_refs () esac } -# Completes refs, short and long, local and remote, symbolic and pseudo. +# Completes refs, short and long, local and remote, symbolic, root and pseudo. # # Usage: __git_complete_refs [<option>]... # --remote=<remote>: The remote to list refs from, can be the name of a
refs.h +6 -7
@@ -85,7 +85,7 @@ enum ref_transaction_error {* Even with RESOLVE_REF_ALLOW_BAD_NAME, names that escape the refs/ * directory and do not consist of all caps and underscores cannot be * resolved. The function returns NULL for such ref names. -* Caps and underscores refers to the pseudorefs, such as HEAD, +* Caps and underscores refers to root refs and pseudorefs, such as HEAD, * FETCH_HEAD and friends, that all live outside of the refs/ directory. */ #define RESOLVE_REF_READING 0x01
@@ -448,8 +448,8 @@ enum refs_for_each_flag {REFS_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 <<2 ),/* -* Include root refs i.e. HEAD and pseudorefs along with the regular -* refs. +* Include root refs, such as HEAD and ORIG_HEAD, along with the +* regular refs. */ REFS_FOR_EACH_INCLUDE_ROOT_REFS = (1 << 3), };
@@ -1306,10 +1306,9 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref);int is_root_ref (const char *refname);/* -* Pseudorefs are refs that have different semantics compared to -* "normal" refs. These refs can thus not be stored in the ref backend, -* but must always be accessed via the filesystem. The following refs -* are pseudorefs: +* Pseudorefs are names that can be used like refs, but have additional +* semantics. They cannot be stored in the ref backend, but must always +* be accessed via the filesystem. The following are pseudorefs: * * - FETCH_HEAD may contain multiple object IDs, and each one of them * carries additional metadata like where it came from.
revision.c +1 -1
@@ -2000,7 +2000,7 @@ static const char *lookup_other_head(struct object_id *oid)return other_head[i]; } -die (_ ("--merge requires one of the pseudorefs MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD" )); +die (_ ("--merge requires an ongoing merge, cherry-pick, revert or rebase" )); }static void prepare_show_merge (struct rev_info *revs)
Signature · 1 line
2.56.0
PATCH v4 5/5 t: stop calling root refs pseudorefs
In reply to Andy KoppeSeveral test titles and comments still use "pseudoref" in its old sense of any ref outside of "refs/", which the glossary now calls root refs.
Replace "pseudoref" with "root ref" there. In t1400 and t4013, rename the root refs that the tests create from PSEUDOREF to ROOT_REF_HEAD and from REVERSE to REVERSE_HEAD, so that they follow the naming rules for root refs. This includes renaming the expected output file in t4013.
Some tests also still refer to FETCH_HEAD and MERGE_HEAD as "special refs", which was the previous term for "pseudorefs". Correct them.
---
t/show-ref-exists-tests.sh | 4 +-
t/t0600-reffiles-backend.sh | 2 +-
t/t0610-reftable-basics.sh | 2 +-
t/t1400-update-ref.sh | 66 +++++++++----------
t/t1403-show-ref.sh | 2 +-
t/t1460-refs-migrate.sh | 4 +-
t/t4013-diff-various.sh | 6 +-
...iff.diff-tree_--cc_--summary_REVERSE_HEAD} | 2 +-
t/t6302-for-each-ref-filter.sh | 4 +-
t/t9902-completion.sh | 4 +-
10 files changed, 48 insertions(+), 48 deletions(-)
rename t/t4013/{diff.diff-tree_--cc_--summary_REVERSE => diff.diff-tree_--cc_--summary_REVERSE_HEAD} (73%)t/show-ref-exists-tests.sh +2 -2
@@ -64,11 +64,11 @@ test_expect_success '--exists with directory fails with generic error' ' test_cmp expect err ' -test_expect_success '--exists with non-existent special ref' ' +test_expect_success '--exists with non-existent pseudoref' ' test_expect_code 2 ${git_show_ref_exists} FETCH_HEAD ' -test_expect_success '--exists with existing special ref' ' +test_expect_success '--exists with existing pseudoref' ' test_when_finished "rm .git/FETCH_HEAD" && git rev-parse HEAD >.git/FETCH_HEAD && ${git_show_ref_exists} FETCH_HEAD
t/t0600-reffiles-backend.sh +1 -1
@@ -267,7 +267,7 @@ test_expect_success 'setup worktree' ' ) ' -# Some refs (refs/bisect/*, pseudorefs) are kept per worktree, so they should +# Some refs (refs/bisect/*, root refs) are kept per worktree, so they should # only appear in the for-each-reflog output if it is called from the correct # worktree, which is exercised in this test. This test is poorly written for # multiple reasons: 1) it creates invalidly formatted log entries. 2) it uses
t/t0610-reftable-basics.sh +1 -1
@@ -1156,7 +1156,7 @@ test_expect_success 'worktree: adds worktree with detached HEAD' ' test_cmp expect actual ' -test_expect_success 'fetch: accessing FETCH_HEAD special ref works' ' +test_expect_success 'fetch: accessing FETCH_HEAD pseudoref works' ' test_when_finished "rm -rf repo sub" && git init sub &&
t/t1400-update-ref.sh +33 -33
94 lines not on this page · raw message
t/t1403-show-ref.sh +1 -1
@@ -181,7 +181,7 @@ test_expect_success 'show-ref --verify HEAD' ' test_must_be_empty actual ' -test_expect_success 'show-ref --verify pseudorefs' ' +test_expect_success 'show-ref --verify root refs' ' git update-ref CHERRY_PICK_HEAD HEAD $ZERO_OID && test_when_finished "git update-ref -d CHERRY_PICK_HEAD" && git show-ref -s --verify HEAD >actual &&
t/t1460-refs-migrate.sh +2 -2
@@ -170,7 +170,7 @@ do test_cmp expect actual ' - test_expect_success "$from_format -> $to_format: pseudo-refs" ' + test_expect_success "$from_format -> $to_format: root refs" ' test_when_finished "rm -rf repo" && git init --ref-storage-format=$from_format repo && test_commit -C repo initial &&
@@ -178,7 +178,7 @@ do test_migration repo "$to_format" ' - test_expect_success "$from_format -> $to_format: special refs are left alone" ' + test_expect_success "$from_format -> $to_format: pseudorefs are left alone" ' test_when_finished "rm -rf repo" && git init --ref-storage-format=$from_format repo && test_commit -C repo initial &&
t/t4013-diff-various.sh +3 -3
@@ -115,10 +115,10 @@ test_expect_success setup ' git checkout -f main && # Same merge as main, but with parents reversed. Hide it in a - # pseudo-ref to avoid impacting tests with --all. + # root ref to avoid impacting tests with --all. commit=$(echo reverse | git commit-tree -p main^2 -p main^1 main^{tree}) && - git update-ref REVERSE $commit && + git update-ref REVERSE_HEAD $commit && git config diff.renames false &&
@@ -328,7 +328,7 @@ diff-tree --cc --stat --summary main diff-tree -c --stat --summary side diff-tree --cc --stat --summary side diff-tree --cc --shortstat main -diff-tree --cc --summary REVERSE +diff-tree --cc --summary REVERSE_HEAD # improved by Timo's patch diff-tree --cc --patch-with-stat main # improved by Timo's patch
t/t4013/diff.diff-tree_--cc_--summary_REVERSE_HEAD renamed from t/t4013/diff.diff-tree_--cc_--summary_REVERSE +1 -1
@@ -1,4 +1,4 @@ -$ git diff-tree --cc --summary REVERSE +$ git diff-tree --cc --summary REVERSE_HEAD 2562325a7ee916efb2481da93073b82cec801cbc create mode 100644 file1 delete mode 100644 file2
t/t6302-for-each-ref-filter.sh +2 -2
@@ -31,7 +31,7 @@ test_expect_success 'setup some history and refs' ' git update-ref refs/odd/spot main ' -test_expect_success '--include-root-refs pattern prints pseudorefs' ' +test_expect_success '--include-root-refs pattern prints root refs' ' cat >expect <<-\EOF && HEAD ORIG_HEAD
@@ -52,7 +52,7 @@ test_expect_success '--include-root-refs pattern prints pseudorefs' ' test_cmp expect actual ' -test_expect_success '--include-root-refs pattern does not print special refs' ' +test_expect_success '--include-root-refs pattern does not print pseudorefs' ' test_when_finished "rm -rf repo" && git init repo && (
t/t9902-completion.sh +2 -2
@@ -2693,13 +2693,13 @@ test_expect_success 'checkout matches case insensitively with GIT_COMPLETION_IGN ) ' -test_expect_success 'checkout completes pseudo refs' ' +test_expect_success 'checkout completes root refs' ' test_completion "git checkout H" <<-\EOF HEAD Z EOF ' -test_expect_success 'checkout completes pseudo refs case insensitively with GIT_COMPLETION_IGNORE_CASE' ' +test_expect_success 'checkout completes root refs case insensitively with GIT_COMPLETION_IGNORE_CASE' ' ( GIT_COMPLETION_IGNORE_CASE=1 && test_completion "git checkout h" <<-\EOF
Signature · 1 line
2.56.0
Quoted 9 lines · Andy Koppe
Changes in v4:
- Glossary: stop contrasting pseudorefs with root refs, mention remote-tracking branches in the "ref" entry, and state that the list of per-worktree ref prefixes will not be extended.
- git-ls-remote(1): describe what is shown by default, including peeling, and describe --refs and the example in those terms.
- gitdatamodel(7): mention the root ref naming rules, and drop "so-called".
- Reword the description and error message of rev-list --merge.
What I saw in "git co ak/root-refs-vs-pseudorefs && git diff @{1}" looked all sensible.
Quoted 12 lines · Junio C Hamano
Quoted 9 lines · Andy Koppe
Changes in v4:
- Glossary: stop contrasting pseudorefs with root refs, mention remote-tracking branches in the "ref" entry, and state that the list of per-worktree ref prefixes will not be extended.
- git-ls-remote(1): describe what is shown by default, including peeling, and describe --refs and the example in those terms.
- gitdatamodel(7): mention the root ref naming rules, and drop "so-called".
- Reword the description and error message of rev-list --merge.
Quoted 2 lines
What I saw in "git co ak/root-refs-vs-pseudorefs && git diff @{1}" looked all sensible.
Yeah, agreed, I think we're hitting the point of diminishing returns by now. So from my point of view this should be ready. Thanks!
Patrick