Skip to content

Commit 6fd8037

Browse files
pks-tgitster
authored andcommitted
Documentation/glossary: redefine pseudorefs as special refs
Nowadays, Git knows about three different kinds of refs. As defined in gitglossary(7): - Regular refs that start with "refs/", like "refs/heads/main". - Pseudorefs, which live in the root directory. These must have all-caps names and must be a file that start with an object hash. Consequently, symbolic refs are not pseudorefs because they do not start with an object hash. - Special refs, of which we only have "FETCH_HEAD" and "MERGE_HEAD". This state is extremely confusing, and I would claim that most folks don't fully understand what is what here. The current definitions also have several problems: - Where does "HEAD" fit in? It's not a pseudoref because it can be a symbolic ref. It's not a regular ref because it does not start with "refs/". And it's not a special ref, either. - There is a strong overlap between pseudorefs and special refs. The pseudoref section for example mentions "MERGE_HEAD", even though it is a special ref. Is it thus both a pseudoref and a special ref? - Why do we even need to distinguish refs that live in the root from other refs when they behave just like a regular ref anyway? In other words, the current state is quite a mess and leads to wild inconsistencies without much of a good reason. The original reason why pseudorefs were introduced is that there are some refs that sometimes behave like a ref, even though they aren't a ref. And we really only have two of these nowadays, namely "MERGE_HEAD" and "FETCH_HEAD". Those files are never written via the ref backends, but are instead written by git-fetch(1), git-pull(1) and git-merge(1). They contain additional metadata that highlights where a ref has been fetched from or the list of commits that have been merged. This original intent in fact matches the definition of special refs that we have recently introduced in 8df4c5d (Documentation: add "special refs" to the glossary, 2024-01-19). Due to the introduction of the new reftable backend we were forced to distinguish those refs more clearly such that we don't ever try to read or write them via the reftable backend. In the same series, we also addressed all the other cases where we used to write those special refs via the filesystem directly, thus circumventing the ref backend, to instead write them via the backends. Consequently, there are no other refs left anymore which are special. Let's address this mess and return the pseudoref terminology back to its original intent: a ref that sometimes behave like a ref, but which isn't really a ref because it gets written to the filesystem directly. Or in other words, let's redefine pseudorefs to match the current definition of special refs. As special refs and pseudorefs are now the same per definition, we can drop the "special refs" term again. It's not exposed to our users and thus they wouldn't ever encounter that term anyway. Refs that live in the root of the ref hierarchy but which are not pseudorefs will be further defined in a subsequent commit. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 786a3e4 commit 6fd8037

File tree

1 file changed

+12
-28
lines changed

1 file changed

+12
-28
lines changed

Documentation/glossary-content.txt

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -497,20 +497,18 @@ exclude;;
497497
unusual refs.
498498

499499
[[def_pseudoref]]pseudoref::
500-
Pseudorefs are a class of files under `$GIT_DIR` which behave
501-
like refs for the purposes of rev-parse, but which are treated
502-
specially by git. Pseudorefs both have names that are all-caps,
503-
and always start with a line consisting of a
504-
<<def_SHA1,SHA-1>> followed by whitespace. So, HEAD is not a
505-
pseudoref, because it is sometimes a symbolic ref. They might
506-
optionally contain some additional data. `MERGE_HEAD` and
507-
`CHERRY_PICK_HEAD` are examples. Unlike
508-
<<def_per_worktree_ref,per-worktree refs>>, these files cannot
509-
be symbolic refs, and never have reflogs. They also cannot be
510-
updated through the normal ref update machinery. Instead,
511-
they are updated by directly writing to the files. However,
512-
they can be read as if they were refs, so `git rev-parse
513-
MERGE_HEAD` will work.
500+
A ref that has different semantics than normal refs. These refs can be
501+
accessed via normal Git commands but may not behave the same as a
502+
normal ref in some cases.
503+
+
504+
The following pseudorefs are known to Git:
505+
506+
- `FETCH_HEAD` is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It
507+
may refer to multiple object IDs. Each object ID is annotated with metadata
508+
indicating where it was fetched from and its fetch status.
509+
510+
- `MERGE_HEAD` is written by linkgit:git-merge[1] when resolving merge
511+
conflicts. It contains all commit IDs which are being merged.
514512

515513
[[def_pull]]pull::
516514
Pulling a <<def_branch,branch>> means to <<def_fetch,fetch>> it and
@@ -638,20 +636,6 @@ The most notable example is `HEAD`.
638636
An <<def_object,object>> used to temporarily store the contents of a
639637
<<def_dirty,dirty>> working directory and the index for future reuse.
640638

641-
[[def_special_ref]]special ref::
642-
A ref that has different semantics than normal refs. These refs can be
643-
accessed via normal Git commands but may not behave the same as a
644-
normal ref in some cases.
645-
+
646-
The following special refs are known to Git:
647-
648-
- "`FETCH_HEAD`" is written by linkgit:git-fetch[1] or linkgit:git-pull[1]. It
649-
may refer to multiple object IDs. Each object ID is annotated with metadata
650-
indicating where it was fetched from and its fetch status.
651-
652-
- "`MERGE_HEAD`" is written by linkgit:git-merge[1] when resolving merge
653-
conflicts. It contains all commit IDs which are being merged.
654-
655639
[[def_submodule]]submodule::
656640
A <<def_repository,repository>> that holds the history of a
657641
separate project inside another repository (the latter of

0 commit comments

Comments
 (0)