Skip to contentSkip to conversation

make room for "special ref"

PATCH In review Junio C Hamano 5 participants 26 messages Dec 15, 2023 – Dec 19, 2023 Documentation

lore
Share & tools
lore
#0 lore raw

cover make room for "special ref"

Patrick's reftable work is progressing nicely and wants to establish "special ref" as a phrase with some defined meaning that is somewhat different from a mere "pseudo ref".

A pseudo ref is merely a normal ref with a funny naming convention, i.e., being outside the refs/ hierarchy and has names with all uppercase letters (or an underscore). But there truly are refs that are more than that. For example, FETCH_HEAD currently stores not just a single object name, but can and is used to store multiple object names, each with annotations to record where they came from. There indeed may be a need to introduce a new term to refer to such "special refs".

Existing documentation, however, uses "special ref" to refer to pseudo refs without any "special" property, like FETCH_HEAD does.

This series merely corrects such existing uses of the word, to make room for Patrick's series to introduce (and formally define in the glossary) "special refs".

Junio C Hamano (5):
git.txt: HEAD is not that special
git-bisect.txt: BISECT_HEAD is not that special
refs.h: HEAD is not that special
docs: AUTO_MERGE is not that special
docs: MERGE_AUTOSTASH is not that special

 Documentation/git-bisect.txt    | 2 +-
 Documentation/git-diff.txt      | 2 +-
 Documentation/git-merge.txt     | 2 +-
 Documentation/git.txt           | 7 ++++---
 Documentation/merge-options.txt | 2 +-
 Documentation/user-manual.txt   | 2 +-
 refs.h                          | 2 +-
 7 files changed, 10 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0-76-g1a87c842ec
#1 lore raw

PATCH 1/5 git.txt: HEAD is not that special

The introductory text in "git help git" that describes HEAD called it "a special ref". It is special compared to the more regular refs like refs/heads/master and refs/tags/v1.0.0, but not that special, unlike truly special ones like FETCH_HEAD.

Rewrite a few sentences to also introduce the distinction between a regular ref that contain the object name and a symbolic ref that contain the name of another ref. Update the description of HEAD that point at the current branch to use the more correct term, a "symbolic ref".

This was found as part of auditing the documentation and in-code comments for uses of "special ref" that refer merely a "pseudo ref".

---
 Documentation/git.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Documentation/git.txt +4 -3
index 2535a30194..880cdc5d7f 100644
@@ -1025,10 +1025,11 @@ When first created, objects are stored in individual files, but for
 efficiency may later be compressed together into "pack files".
 
 Named pointers called refs mark interesting points in history.  A ref
-may contain the SHA-1 name of an object or the name of another ref.  Refs
-with names beginning `ref/head/` contain the SHA-1 name of the most
+may contain the SHA-1 name of an object or the name of another ref (the
+latter is called a "symbolic ref").
+Refs with names beginning `ref/head/` contain the SHA-1 name of the most
 recent commit (or "head") of a branch under development.  SHA-1 names of
-tags of interest are stored under `ref/tags/`.  A special ref named
+tags of interest are stored under `ref/tags/`.  A symbolic ref named
 `HEAD` contains the name of the currently checked-out branch.
 
 The index file is initialized with a list of all paths and, for each
Signature · 1 line
2.43.0-76-g1a87c842ec
#2 lore raw

Re: [PATCH 1/5] git.txt: HEAD is not that special

Quoted 24 lines · Junio C Hamano

The introductory text in "git help git" that describes HEAD called it "a special ref". It is special compared to the more regular refs like refs/heads/master and refs/tags/v1.0.0, but not that special, unlike truly special ones like FETCH_HEAD.

Rewrite a few sentences to also introduce the distinction between a regular ref that contain the object name and a symbolic ref that contain the name of another ref. Update the description of HEAD that point at the current branch to use the more correct term, a "symbolic ref".

This was found as part of auditing the documentation and in-code comments for uses of "special ref" that refer merely a "pseudo ref".

---
 Documentation/git.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Documentation/git.txt +0 -0
index 2535a30194..880cdc5d7f 100644

Documentation/git.txt When first created, objects are stored in individual files, but for · line 1030

Quoted 8 lines
Documentation/git.txt +3 -2
@@ -1025,10 +1025,11 @@ When first created, objects are stored in individual files, but for
 efficiency may later be compressed together into "pack files".
 
 Named pointers called refs mark interesting points in history.  A ref
-may contain the SHA-1 name of an object or the name of another ref.  Refs
-with names beginning `ref/head/` contain the SHA-1 name of the most
+may contain the SHA-1 name of an object or the name of another ref (the
+latter is called a "symbolic ref").
+Refs with names beginning `ref/head/` contain the SHA-1 name of the most

Hmm, s:ref/head:refs/heads: right?

Quoted 6 lines
Documentation/git.txt +1 -1
 recent commit (or "head") of a branch under development.  SHA-1 names of
-tags of interest are stored under `ref/tags/`.  A special ref named
+tags of interest are stored under `ref/tags/`.  A symbolic ref named
 `HEAD` contains the name of the currently checked-out branch.
 
 The index file is initialized with a list of all paths and, for each
#3 lore raw

Re: [PATCH 1/5] git.txt: HEAD is not that special

Quoted 7 lines · Ramsay Jones

Documentation/git.txt When first created, objects are stored in individual files, but for · line 1030

Quoted 5 lines
Documentation/git.txt +3 -2
-may contain the SHA-1 name of an object or the name of another ref.  Refs
-with names beginning `ref/head/` contain the SHA-1 name of the most
+may contain the SHA-1 name of an object or the name of another ref (the
+latter is called a "symbolic ref").
+Refs with names beginning `ref/head/` contain the SHA-1 name of the most

Hmm, s:ref/head:refs/heads: right?

Yeah, right, not a new problem with this change, but is indeed a good thing to catch and correct. Thanks for a careful review.

#4 lore raw

Re: [PATCH 1/5] git.txt: HEAD is not that special

Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Ramsay Jones

Documentation/git.txt When first created, objects are stored in individual files, but for · line 1030

Quoted 5 lines
Documentation/git.txt +3 -2
-may contain the SHA-1 name of an object or the name of another ref.  Refs
-with names beginning `ref/head/` contain the SHA-1 name of the most
+may contain the SHA-1 name of an object or the name of another ref (the
+latter is called a "symbolic ref").
+Refs with names beginning `ref/head/` contain the SHA-1 name of the most

Hmm, s:ref/head:refs/heads: right?

Quoted 2 lines

Yeah, right, not a new problem with this change, but is indeed a good thing to catch and correct. Thanks for a careful review.

And we have ref/tags/ just below, which I also have fixed locally.

#5 lore raw

PATCH 1/1 doc: format.notes specify a ref under refs/notes/ hierarchy

There is no 'ref/notes/' hierarchy. '[format] notes = foo' uses notes that are found in 'refs/notes/foo'.

---
* According to my eyeballing "git grep refs/ Documentation" result, this was the only remaining mention of "ref/" in Documentation/ hierarchy that misspells "refs/".

 Documentation/config/format.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/config/format.txt +1 -1
index c98412b697..7410e930e5 100644
@@ -119,7 +119,7 @@ format.notes::
 	`--notes=<ref>`, where `ref` is the non-boolean value. Defaults
 	to false.
 +
-If one wishes to use the ref `ref/notes/true`, please use that literal
+If one wishes to use the ref `refs/notes/true`, please use that literal
 instead.
 +
 This configuration can be specified multiple times in order to allow
#6 lore raw

Re: [PATCH] doc: format.notes specify a ref under refs/notes/ hierarchy

Quoted 8 lines · Junio C Hamano

There is no 'ref/notes/' hierarchy. '[format] notes = foo' uses notes that are found in 'refs/notes/foo'.

---
* According to my eyeballing "git grep refs/ Documentation" result, this was the only remaining mention of "ref/" in Documentation/ hierarchy that misspells "refs/".

This made me look for additional instances where we were referring to "ref/". Turns out it's only a very limited set, see the below diff. Take the translation changes with a big grain of salt though, and neither am I sure whether we want to fix up past release notes. Also, the test is interesting because it would fail even if we didn't pass an invalid atom to git-for-each-ref(1).

Anyway, the patch you have looks obviously correct to me. I would be happy to turn the below diff into a proper patch, but also wouldn't mind to let you roll them into your patch series. Please let me know your preference.

Patrick

Documentation/RelNotes/2.1.1.txt +1 -1
index 830fc3cc6d..d46e142119 100644
@@ -29,7 +29,7 @@ Git v2.1.1 Release Notes
  * "git add x" where x that used to be a directory has become a
    symbolic link to a directory misbehaved.
 
- * The prompt script checked $GIT_DIR/ref/stash file to see if there
+ * The prompt script checked $GIT_DIR/refs/stash file to see if there
    is a stash, which was a no-no.
 
  * "git checkout -m" did not switch to another branch while carrying
Documentation/RelNotes/2.2.0.txt +1 -1
index e98ecbcff6..806908ddb2 100644
@@ -205,7 +205,7 @@ notes for details).
  * "git add x" where x used to be a directory and is now a
    symbolic link to a directory misbehaved.
 
- * The prompt script checked the $GIT_DIR/ref/stash file to see if there
+ * The prompt script checked the $GIT_DIR/refs/stash file to see if there
    is a stash, which was a no-no.
 
  * Pack-protocol documentation had a minor typo.
po/fr.po +1 -1
index ee2e610ef1..744550b056 100644
@@ -19773,7 +19773,7 @@ msgid ""
 "Neither worked, so we gave up. You must fully qualify the ref."
 msgstr ""
 "La destination que vous avez fournie n'est pas un nom de référence complète\n"
-"(c'est-à-dire commençant par \"ref/\"). Essai d'approximation par :\n"
+"(c'est-à-dire commençant par \"refs/\"). Essai d'approximation par :\n"
 "\n"
 "- Recherche d'une référence qui correspond à '%s' sur le serveur distant.\n"
 "- Vérification si la <source> en cours de poussée ('%s')\n"
po/zh_CN.po +2 -2
index 86402725b2..eb47e8f9b7 100644
@@ -13224,8 +13224,8 @@ msgid ""
 msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
-msgstr[0] "注意:ref/remotes 层级之外的一个分支未被移除。要删除它,使用:"
-msgstr[1] "注意:ref/remotes 层级之外的一些分支未被移除。要删除它们,使用:"
+msgstr[0] "注意:refs/remotes 层级之外的一个分支未被移除。要删除它,使用:"
+msgstr[1] "注意:refs/remotes 层级之外的一些分支未被移除。要删除它们,使用:"
 
 #: builtin/remote.c
 #, c-format
po/zh_TW.po +1 -1
index f777a0596f..b2a79cdd93 100644
@@ -13109,7 +13109,7 @@ msgid ""
 msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
-msgstr[0] "注意:ref/remotes 層級之外的一個分支未被移除。要刪除它,使用:"
+msgstr[0] "注意:refs/remotes 層級之外的一個分支未被移除。要刪除它,使用:"
 
 #: builtin/remote.c
 #, c-format
t/t6300-for-each-ref.sh +1 -1
index 54e2281259..e68f7bec8e 100755
@@ -841,7 +841,7 @@ test_expect_success 'err on bad describe atom arg' '
 		EOF
 		test_must_fail git for-each-ref \
 			--format="%(describe:tags,qux=1,abbrev=14)" \
-			ref/heads/master 2>actual &&
+			refs/heads/master 2>actual &&
 		test_cmp expect actual
 	)
 '
#7 lore raw

Re: [PATCH] doc: format.notes specify a ref under refs/notes/ hierarchy

Quoted 4 lines · Patrick Steinhardt
Quoted 3 lines · Junio C Hamano

There is no 'ref/notes/' hierarchy. '[format] notes = foo' uses notes that are found in 'refs/notes/foo'.

Quoted 8 lines
Quoted 5 lines

---
* According to my eyeballing "git grep refs/ Documentation" result, this was the only remaining mention of "ref/" in Documentation/ hierarchy that misspells "refs/".

This made me look for additional instances where we were referring to "ref/". Turns out it's only a very limited set, see the below diff.

Yup, I did the same grep, but I tend to avoid churning what we published long ago (and kept in Documentation/RelNotes/), my patches only covered documents that are still relevant.

Quoted 1 line

the translation changes with a big grain of salt though,

Hopefully pinging Jiang would be sufficient to ask help from the French, Chinese, and Taiwaneese translation teams.

Quoted 42 lines
po/fr.po +1 -1
index ee2e610ef1..744550b056 100644
@@ -19773,7 +19773,7 @@ msgid ""
 "Neither worked, so we gave up. You must fully qualify the ref."
 msgstr ""
 "La destination que vous avez fournie n'est pas un nom de référence complète\n"
-"(c'est-à-dire commençant par \"ref/\"). Essai d'approximation par :\n"
+"(c'est-à-dire commençant par \"refs/\"). Essai d'approximation par :\n"
 "\n"
 "- Recherche d'une référence qui correspond à '%s' sur le serveur distant.\n"
 "- Vérification si la <source> en cours de poussée ('%s')\n"
po/zh_CN.po +2 -2
index 86402725b2..eb47e8f9b7 100644
@@ -13224,8 +13224,8 @@ msgid ""
 msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
-msgstr[0] "注意:ref/remotes 层级之外的一个分支未被移除。要删除它,使用:"
-msgstr[1] "注意:ref/remotes 层级之外的一些分支未被移除。要删除它们,使用:"
+msgstr[0] "注意:refs/remotes 层级之外的一个分支未被移除。要删除它,使用:"
+msgstr[1] "注意:refs/remotes 层级之外的一些分支未被移除。要删除它们,使用:"
 
 #: builtin/remote.c
 #, c-format
po/zh_TW.po +1 -1
index f777a0596f..b2a79cdd93 100644
@@ -13109,7 +13109,7 @@ msgid ""
 msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
-msgstr[0] "注意:ref/remotes 層級之外的一個分支未被移除。要刪除它,使用:"
+msgstr[0] "注意:refs/remotes 層級之外的一個分支未被移除。要刪除它,使用:"
 
 #: builtin/remote.c
 #, c-format
Quoted 3 lines

Also, the test is
interesting because it would fail even if we didn't pass an invalid atom to git-for-each-ref(1).

It is interesting but not surprising. It is not an error to use ref patterns that do not match any ref. It is a mere pattern to filtering what are in refs/ for the ones to be output.

t/t6300-for-each-ref.sh test_expect_success 'err on bad describe atom arg' ' · line 847

Quoted 13 lines
t/t6300-for-each-ref.sh +1 -1
index 54e2281259..e68f7bec8e 100755
@@ -841,7 +841,7 @@ test_expect_success 'err on bad describe atom arg' '
 		EOF
 		test_must_fail git for-each-ref \
 			--format="%(describe:tags,qux=1,abbrev=14)" \
-			ref/heads/master 2>actual &&
+			refs/heads/master 2>actual &&
 		test_cmp expect actual
 	)
 '

The "for-each-ref" family's "--format" string is first parsed and sanity-checked before it is applied. The bogus ref pattern may not yield any ref to apply the format string, but we do not optimize out the parsing and checking, even though we could, as it would be optimizing for a wrong case. So regardless of the ref pattern at the end of the command line does not make a difference to the outcome of this test.

#8 lore raw

Re: [PATCH] doc: format.notes specify a ref under refs/notes/ hierarchy

Quoted 6 lines · Junio C Hamano
Quoted 1 line · Patrick Steinhardt

the translation changes with a big grain of salt though,

Hopefully pinging Jiang would be sufficient to ask help from the French, Chinese, and Taiwaneese translation teams.

The l10n team has a command line tool called git-po-helper that can check for spelling errors in translations, such as mismatched command names, configuration variables. A new pattern will be added to find mismatched reference prefixes, and the following typos will be fixed during the next localization window.

Quoted 41 lines
Quoted 41 lines
po/fr.po +1 -1
index ee2e610ef1..744550b056 100644
@@ -19773,7 +19773,7 @@ msgid ""
 "Neither worked, so we gave up. You must fully qualify the ref."
 msgstr ""
 "La destination que vous avez fournie n'est pas un nom de référence complète\n"
-"(c'est-à-dire commençant par \"ref/\"). Essai d'approximation par :\n"
+"(c'est-à-dire commençant par \"refs/\"). Essai d'approximation par :\n"
 "\n"
 "- Recherche d'une référence qui correspond à '%s' sur le serveur distant.\n"
 "- Vérification si la <source> en cours de poussée ('%s')\n"
po/zh_CN.po +2 -2
index 86402725b2..eb47e8f9b7 100644
@@ -13224,8 +13224,8 @@ msgid ""
 msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
-msgstr[0] "注意:ref/remotes 层级之外的一个分支未被移除。要删除它,使用:"
-msgstr[1] "注意:ref/remotes 层级之外的一些分支未被移除。要删除它们,使用:"
+msgstr[0] "注意:refs/remotes 层级之外的一个分支未被移除。要删除它,使用:"
+msgstr[1] "注意:refs/remotes 层级之外的一些分支未被移除。要删除它们,使用:"
 
 #: builtin/remote.c
 #, c-format
po/zh_TW.po +1 -1
index f777a0596f..b2a79cdd93 100644
@@ -13109,7 +13109,7 @@ msgid ""
 msgid_plural ""
 "Note: Some branches outside the refs/remotes/ hierarchy were not removed;\n"
 "to delete them, use:"
-msgstr[0] "注意:ref/remotes 層級之外的一個分支未被移除。要刪除它,使用:"
+msgstr[0] "注意:refs/remotes 層級之外的一個分支未被移除。要刪除它,使用:"
 
 #: builtin/remote.c
 #, c-format
#9 lore raw

Re: [PATCH 1/5] git.txt: HEAD is not that special

In reply to Junio C Hamano
Quoted 12 lines · Junio C Hamano
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Ramsay Jones

Documentation/git.txt When first created, objects are stored in individual files, but for · line 1030

Quoted 5 lines
Documentation/git.txt +3 -2
-may contain the SHA-1 name of an object or the name of another ref.  Refs
-with names beginning `ref/head/` contain the SHA-1 name of the most
+may contain the SHA-1 name of an object or the name of another ref (the
+latter is called a "symbolic ref").
+Refs with names beginning `ref/head/` contain the SHA-1 name of the most

Hmm, s:ref/head:refs/heads: right?

Quoted 4 lines
Quoted 2 lines

Yeah, right, not a new problem with this change, but is indeed a good thing to catch and correct. Thanks for a careful review.

And we have ref/tags/ just below, which I also have fixed locally.

Heh, yeah I missed that, along with 'ref/notes'. ;)

ATB,
Ramsay Jones

#10 lore raw

Re: [PATCH 1/5] git.txt: HEAD is not that special

In reply to Junio C Hamano
Quoted 24 lines · Junio C Hamano

The introductory text in "git help git" that describes HEAD called it "a special ref". It is special compared to the more regular refs like refs/heads/master and refs/tags/v1.0.0, but not that special, unlike truly special ones like FETCH_HEAD.

Rewrite a few sentences to also introduce the distinction between a regular ref that contain the object name and a symbolic ref that contain the name of another ref. Update the description of HEAD that point at the current branch to use the more correct term, a "symbolic ref".

This was found as part of auditing the documentation and in-code comments for uses of "special ref" that refer merely a "pseudo ref".

---
 Documentation/git.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Documentation/git.txt +0 -0
index 2535a30194..880cdc5d7f 100644

Documentation/git.txt When first created, objects are stored in individual files, but for · line 1029

Quoted 7 lines
Documentation/git.txt +2 -2
@@ -1025,10 +1025,11 @@ When first created, objects are stored in individual files, but for
 efficiency may later be compressed together into "pack files".
 
 Named pointers called refs mark interesting points in history.  A ref
-may contain the SHA-1 name of an object or the name of another ref.  Refs
-with names beginning `ref/head/` contain the SHA-1 name of the most
+may contain the SHA-1 name of an object or the name of another ref (the
+latter is called a "symbolic ref").

On a tangent: While we have a name for symbolic refs, do we also have a name for non-symbolic refs? I often use the term "direct ref" to clearly distinguish them from symbolic refs, but it's of course not defined in our glossary.

Documentation/git.txt When first created, objects are stored in individual files, but for · line 1033

Quoted 5 lines
Documentation/git.txt +2 -1
+Refs with names beginning `ref/head/` contain the SHA-1 name of the most
 recent commit (or "head") of a branch under development.  SHA-1 names of
-tags of interest are stored under `ref/tags/`.  A special ref named
+tags of interest are stored under `ref/tags/`.  A symbolic ref named
 `HEAD` contains the name of the currently checked-out branch.

I was briefly wondering whether we also want to replace SHA-1 with "object hash" while at it, but it's certainly out of the scope of this patch series.

Patrick

#11 lore raw

Re: [PATCH 1/5] git.txt: HEAD is not that special

Quoted 10 lines · Patrick Steinhardt

Documentation/git.txt When first created, objects are stored in individual files, but for · line 1029

Quoted 5 lines

Named pointers called refs mark interesting points in history. A ref

Documentation/git.txt +2 -2
-may contain the SHA-1 name of an object or the name of another ref.  Refs
-with names beginning `ref/head/` contain the SHA-1 name of the most
+may contain the SHA-1 name of an object or the name of another ref (the
+latter is called a "symbolic ref").

On a tangent: While we have a name for symbolic refs, do we also have a name for non-symbolic refs? I often use the term "direct ref" to clearly distinguish them from symbolic refs, but it's of course not defined in our glossary.

You may find me saying "normal ref", "regular ref", or somesuch when it is not clear from the context if you dig the list archive. "direct" is a nice word, especially it would give us a good pair of terms if we are to change "symbolic" to "indirect", but since we are not going to do so, I am not sure the contrast between "direct" and "symbolic" would make such a good pair.

But quite honestly I rarely felt a need for a specific term, as it is fairly clear from the context, e.g.

* "From a ref, we locate an object using the object name it records and use the object"

A statement written from the point of view of the consumer of object name, it does not matter if the object name is directly found in the ref, or indirection is involved to find such a concrete ref that records an object name by following the original symbolic ref.

* "A ref usually stores an object name, but it can also be a symbolic ref that points at another ref, in which case, asking what object such a symbolic ref points at would yield the object the other ref points at".

So I dunno.

Quoted 9 lines

Documentation/git.txt When first created, objects are stored in individual files, but for · line 1033

Quoted 5 lines
Documentation/git.txt +2 -1
+Refs with names beginning `ref/head/` contain the SHA-1 name of the most
 recent commit (or "head") of a branch under development.  SHA-1 names of
-tags of interest are stored under `ref/tags/`.  A special ref named
+tags of interest are stored under `ref/tags/`.  A symbolic ref named
 `HEAD` contains the name of the currently checked-out branch.

I was briefly wondering whether we also want to replace SHA-1 with "object hash" while at it, but it's certainly out of the scope of this patch series.

Yup, there still are too many reference to SHA-1 (and "sha1", which is even worse), and it is not a focus of this series.

Thanks.

#12 lore raw

PATCH 2/5 git-bisect.txt: BISECT_HEAD is not that special

In reply to Junio C Hamano

The description of "git bisect --no-checkout" called BISECT_HEAD a "special ref", but there is nothing special about it. It merely is yet another pseudoref.

---
 Documentation/git-bisect.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/git-bisect.txt +1 -1
index 191b4a42b6..aa02e46224 100644
@@ -362,7 +362,7 @@ OPTIONS
 --no-checkout::
 +
 Do not checkout the new working tree at each iteration of the bisection
-process. Instead just update a special reference named `BISECT_HEAD` to make
+process. Instead just update the reference named `BISECT_HEAD` to make
 it point to the commit that should be tested.
 +
 This option may be useful when the test you would perform in each step
Signature · 1 line
2.43.0-76-g1a87c842ec
#13 lore raw

PATCH 3/5 refs.h: HEAD is not that special

In reply to Junio C Hamano

In-code comment explains pseudorefs but used a wrong nomenclature "special ref".

---
 refs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
refs.h +1 -1
index 23211a5ea1..ff113bb12a 100644
@@ -56,7 +56,7 @@ struct worktree;
  * 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 special refs, such as HEAD,
+ * Caps and underscores refers to the pseudorefs, such as HEAD,
  * FETCH_HEAD and friends, that all live outside of the refs/ directory.
  */
 #define RESOLVE_REF_READING 0x01
Signature · 1 line
2.43.0-76-g1a87c842ec
#14 lore raw

Re: [PATCH 3/5] refs.h: HEAD is not that special

Quoted 13 lines · Junio C Hamano

In-code comment explains pseudorefs but used a wrong nomenclature "special ref".

---
  refs.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
refs.h +0 -0
index 23211a5ea1..ff113bb12a 100644

refs.h struct worktree; · line 62

Quoted 8 lines
refs.h +1 -1
@@ -56,7 +56,7 @@ struct worktree;
   * 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 special refs, such as HEAD,
+ * Caps and underscores refers to the pseudorefs, such as HEAD,
   * FETCH_HEAD and friends, that all live outside of the refs/ directory.
   */
  #define RESOLVE_REF_READING 0x01

gitglossary thinks that HEAD is not a pseudoref:

"Pseudorefs are a class of files under $GIT_DIR which behave like refs for the purposes of rev-parse, but which are treated specially by git. Pseudorefs both have names that are all-caps, and always start with a line consisting of a SHA‐1 followed by whitespace. So, HEAD is not a pseudoref, because it is sometimes a symbolic ref."

(Also, the "sometimes" there actually is "whenever you're on a branch", which is most of the time for most people.)

Regards,
Andy

#15 lore raw

PATCH 4/5 docs: AUTO_MERGE is not that special

In reply to Junio C Hamano

A handful of manual pages called AUTO_MERGE a "special ref", but there is nothing special about it. It merely is yet another pseudoref.

---
 Documentation/git-diff.txt    | 2 +-
 Documentation/git-merge.txt   | 2 +-
 Documentation/user-manual.txt | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Documentation/git-diff.txt +1 -1
index 08087ffad5..c065f023ec 100644
@@ -103,7 +103,7 @@ Just in case you are doing something exotic, it should be
 noted that all of the <commit> in the above description, except
 in the `--merge-base` case and in the last two forms that use `..`
 notations, can be any <tree>. A tree of interest is the one pointed to
-by the special ref `AUTO_MERGE`, which is written by the 'ort' merge
+by the ref named `AUTO_MERGE`, which is written by the 'ort' merge
 strategy upon hitting merge conflicts (see linkgit:git-merge[1]).
 Comparing the working tree with `AUTO_MERGE` shows changes you've made
 so far to resolve textual conflicts (see the examples below).
Documentation/git-merge.txt +1 -1
index e8ab340319..3e9557a44b 100644
@@ -196,7 +196,7 @@ happens:
    can inspect the stages with `git ls-files -u`).  The working
    tree files contain the result of the merge operation; i.e. 3-way
    merge results with familiar conflict markers `<<<` `===` `>>>`.
-5. A special ref `AUTO_MERGE` is written, pointing to a tree
+5. A ref named `AUTO_MERGE` is written, pointing to a tree
    corresponding to the current content of the working tree (including
    conflict markers for textual conflicts).  Note that this ref is only
    written when the 'ort' merge strategy is used (the default).
Documentation/user-manual.txt +1 -1
index d8dbe6b56d..5d32ff2384 100644
@@ -1344,7 +1344,7 @@ $ git diff --theirs file.txt	# same as the above.
 -------------------------------------------------
 
 When using the 'ort' merge strategy (the default), before updating the working
-tree with the result of the merge, Git writes a special ref named AUTO_MERGE
+tree with the result of the merge, Git writes a ref named AUTO_MERGE
 reflecting the state of the tree it is about to write. Conflicted paths with
 textual conflicts that could not be automatically merged are written to this
 tree with conflict markers, just as in the working tree. AUTO_MERGE can thus be
Signature · 1 line
2.43.0-76-g1a87c842ec
#16 lore raw

PATCH 5/5 docs: MERGE_AUTOSTASH is not that special

In reply to Junio C Hamano

A handful of manual pages called MERGE_AUTOSTASH a "special ref", but there is nothing special about it. It merely is yet another pseudoref.

---
 Documentation/merge-options.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/merge-options.txt +1 -1
index d8f7cd7ca0..3eaefc4e94 100644
@@ -191,7 +191,7 @@ endif::git-pull[]
 --autostash::
 --no-autostash::
 	Automatically create a temporary stash entry before the operation
-	begins, record it in the special ref `MERGE_AUTOSTASH`
+	begins, record it in the ref `MERGE_AUTOSTASH`
 	and apply it after the operation ends.  This means
 	that you can run the operation on a dirty worktree.  However, use
 	with care: the final stash application after a successful
Signature · 1 line
2.43.0-76-g1a87c842ec
#17 lore raw

Re: [PATCH 5/5] docs: MERGE_AUTOSTASH is not that special

Quoted 14 lines · Junio C Hamano

A handful of manual pages called MERGE_AUTOSTASH a "special ref", but there is nothing special about it. It merely is yet another pseudoref.

---
  Documentation/merge-options.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/merge-options.txt +0 -0
index d8f7cd7ca0..3eaefc4e94 100644

Documentation/merge-options.txt endif::git-pull[] · line 197

Quoted 8 lines
Documentation/merge-options.txt +1 -1
@@ -191,7 +191,7 @@ endif::git-pull[]
  --autostash::
  --no-autostash::
  	Automatically create a temporary stash entry before the operation
-	begins, record it in the special ref `MERGE_AUTOSTASH`
+	begins, record it in the ref `MERGE_AUTOSTASH`
  	and apply it after the operation ends.  This means
  	that you can run the operation on a dirty worktree.  However, use
  	with care: the final stash application after a successful

Should that say 'pseudoref' instead of 'ref'?

And since MERGE_AUTOSTASH is documented here, it probably should be in gitrevisions as well.

Regards,
Andy

#18 lore raw
In reply to Junio C Hamano
Quoted 5 lines · Junio C Hamano

... For example, FETCH_HEAD currently stores not
just a single object name, but can and is used to store multiple object names, each with annotations to record where they came from. There indeed may be a need to introduce a new term to refer to such "special refs".

The "may be" here vaguely hints another possibility. If we manage to get rid of the "special refs", we do not even have to mention "special refs", and more importantly, we do not need extra code to deal with them.

For FETCH_HEAD, for example, I wonder if an update along this line is possible:

* Teach "git fetch" to store what it writes to FETCH_HEAD to a different file, under a distinctly different filename (e.g., $GIT_DIR/fetched-tips). Demote FETCH_HEAD to a pseudoref, and store the first object name in that "fetched-tips" file to it.

* Teach "git pull" to learn what it used to learn from FETCH_HEAD (i.e., list of fetched tips, each annotated with what ref at what repository it came from and if it is to be merged) from the new "fetched-tips" file.

The "special" ness of FETCH_HEAD is really an implementation detail of how "git pull" works and how the findings of "git fetch" are communicated to "git pull". The general refs API should not have to worry about it, and the refs backends should not have to worry about storing more than just an object name (or if it is a symbolic ref, the target refname).

An end-user command like "git log ORIG_HEAD..FETCH_HEAD" would not be affected by changes along the above line, because the current FETCH_HEAD, when used as a revision, will work as if it stores the single object name that is listed first in the file.

If somebody is reading FETCH_HEAD and acting on its contents (rather than merely consuming it as a ref of the first object), perhaps feeding it to "git fmt-merge-msg", they will be broken by such a change (indeed, our own "git pull" will be broken by the change to "git fetch", and the second bullet point above is about fixing the exact fallout from it), but I am not sure if that is a use case worth worrying about.

Hmm?

#19 lore raw
Quoted 46 lines · Junio C Hamano
Quoted 5 lines · Junio C Hamano

... For example, FETCH_HEAD currently stores not
just a single object name, but can and is used to store multiple object names, each with annotations to record where they came from. There indeed may be a need to introduce a new term to refer to such "special refs".

The "may be" here vaguely hints another possibility. If we manage to get rid of the "special refs", we do not even have to mention "special refs", and more importantly, we do not need extra code to deal with them.

For FETCH_HEAD, for example, I wonder if an update along this line is possible:

* Teach "git fetch" to store what it writes to FETCH_HEAD to a different file, under a distinctly different filename (e.g., $GIT_DIR/fetched-tips). Demote FETCH_HEAD to a pseudoref, and store the first object name in that "fetched-tips" file to it.

* Teach "git pull" to learn what it used to learn from FETCH_HEAD (i.e., list of fetched tips, each annotated with what ref at what repository it came from and if it is to be merged) from the new "fetched-tips" file.

The "special" ness of FETCH_HEAD is really an implementation detail of how "git pull" works and how the findings of "git fetch" are communicated to "git pull". The general refs API should not have to worry about it, and the refs backends should not have to worry about storing more than just an object name (or if it is a symbolic ref, the target refname).

An end-user command like "git log ORIG_HEAD..FETCH_HEAD" would not be affected by changes along the above line, because the current FETCH_HEAD, when used as a revision, will work as if it stores the single object name that is listed first in the file.

If somebody is reading FETCH_HEAD and acting on its contents (rather than merely consuming it as a ref of the first object), perhaps feeding it to "git fmt-merge-msg", they will be broken by such a change (indeed, our own "git pull" will be broken by the change to "git fetch", and the second bullet point above is about fixing the exact fallout from it), but I am not sure if that is a use case worth worrying about.

Quoted 2 lines

Hmm?

Yes, I was going to suggest exactly this, after Patrick pointed out that there were only two 'special psuedo-refs' (I had a vague feeling there were some more than that) FETCH_HEAD and MERGE_HEAD.

ATB,
Ramsay Jones

#20 lore raw
Quoted 3 lines · Ramsay Jones

Yes, I was going to suggest exactly this, after Patrick pointed out that there were only two 'special psuedo-refs' (I had a vague feeling there were some more than that) FETCH_HEAD and MERGE_HEAD.

Glad to see that I am not alone. We should be able to treat MERGE_HEAD similarly. It is used to communicate the list of "other parents" from "git merge" that stops in the middle (either for merge conflict, or in response to the "--no-commit" command line option) to "git commit" that concludes such an unfinished merge. Many commands merely use the presence of MERGE_HEAD as a sign that a merge is in progress (e.g. "git status"), which would not break if we just started to record the first parent in a pseudoref MERGE_HEAD and wrote the other octopus parents elsewhere, but some commands do need all these parents from MERGE_HEAD (e.g. "git blame" that synthesizes a fake starting commit out of the working tree state).

If we cannot get rid of all "special refs" anyway, however, I think there is little that we can gain from doing such "make FETCH_HEAD and MERGE_HEAD into a single-object pseudoref, and write other info in separate files" exercise. We can treat the current FETCH_HEAD and MERGE_HEAD as "file that is not and is more than a ref", which is what the current code is doing anyway, which means we would declare that they have to stay to be files under $GIT_DIR/ and will be accessed via the filesystem access. At that point, calling them "special ref" might even be more misleading than its worth and we may be better off to admit that they are not even refs but a datafile some commands can use to obtain input from, but the phrase we use to refer to them, be it "special ref" or some random datafile, does not make a fundamental change on anything.

#21 lore raw
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · Ramsay Jones

Yes, I was going to suggest exactly this, after Patrick pointed out that there were only two 'special psuedo-refs' (I had a vague feeling there were some more than that) FETCH_HEAD and MERGE_HEAD.

I don't think there are more special refs than those two. Andy pointed out CHERRY_PICK_HEAD and REVERT_HEAD, but both of them actually get accessed via the ref backend exclusively and thus cannot be special in any way. Also, the test suite of Git passes with only those two refs marked as special refs with the reftable backend, which is another good indicator that I didn't miss anything here because we definitely can't store special information in the reftable backend.

It's of course still possible that our test suite has a blind spot and that I missed any special refs. If so, I would love to hear about them.

Quoted 11 lines

Glad to see that I am not alone. We should be able to treat MERGE_HEAD similarly. It is used to communicate the list of "other parents" from "git merge" that stops in the middle (either for merge conflict, or in response to the "--no-commit" command line option) to "git commit" that concludes such an unfinished merge. Many commands merely use the presence of MERGE_HEAD as a sign that a merge is in progress (e.g. "git status"), which would not break if we just started to record the first parent in a pseudoref MERGE_HEAD and wrote the other octopus parents elsewhere, but some commands do need all these parents from MERGE_HEAD (e.g. "git blame" that synthesizes a fake starting commit out of the working tree state).

I would certainly love to drop the "specialness" of both FETCH_HEAD and MERGE_HEAD, but I am a bit pessimistic about whether we really can. The format of those refs has been around for quite a long time already, and I do expect that there is tooling out there that parses those files.

I would claim that it's especially likely that FETCH_HEAD is getting parsed by external tools. Historically, there has not been a way to really figure out which refs have been updated in git-fetch(1). So any scripts that perform a fetch and want to learn about what was updated would very likely resort to parsing FETCH_HEAD. This has changed a bit with the introduction of the machine-parsable interface of git-fetch(1), but it has only been introduced rather recently with Git v2.42.

Quoted 8 lines

If we cannot get rid of all "special refs" anyway, however, I think there is little that we can gain from doing such "make FETCH_HEAD and MERGE_HEAD into a single-object pseudoref, and write other info in separate files" exercise. We can treat the current FETCH_HEAD and MERGE_HEAD as "file that is not and is more than a ref", which is what the current code is doing anyway, which means we would declare that they have to stay to be files under $GIT_DIR/ and will be accessed via the filesystem access.

I'd like for it to be otherwise, but I think this is the only sensible thing to do. I think it was a mistake to introduce those special refs like this and treat them almost like a real ref, but that's always easy to say in hindsight.

Quoted 5 lines

At that point, calling them "special ref" might even be more misleading than its worth and we may be better off to admit that they are not even refs but a datafile some commands can use to obtain input from, but the phrase we use to refer to them, be it "special ref" or some random datafile, does not make a fundamental change on anything.

Well, the problem is that these do indeed behave like a ref for most of the part: you can ask for them via git-rev-parse(1) and we'll resolve them just fine, even though we only ever return the first object ID. So even though I'm not a huge fan of calling them "special ref", I think we should at least highlight the reflike-nature in whatever we want to call them.

Patrick

#22 lore raw
In reply to Ramsay Jones
Quoted 10 lines · Ramsay Jones
Quoted 7 lines · Junio C Hamano

If somebody is reading FETCH_HEAD and acting on its contents (rather than merely consuming it as a ref of the first object), perhaps feeding it to "git fmt-merge-msg", they will be broken by such a change (indeed, our own "git pull" will be broken by the change to "git fetch", and the second bullet point above is about fixing the exact fallout from it), but I am not sure if that is a use case worth worrying about.

Quoted 3 lines

Yes, I was going to suggest exactly this, after Patrick pointed out that there were only two 'special psuedo-refs' (I had a vague feeling there were some more than that) FETCH_HEAD and MERGE_HEAD.

According to the pseudoref entry of gitglossary, CHERRY_PICK_HEAD also stores additional data (which would imply that REVERT_HEAD does too). Looking at CHERRY_PICK_HEAD during a pick though, I only see a single hash, even when picking multiple commits.

Regards,
Andy

#23 lore raw
Quoted 11 lines · Andy Koppe
Quoted 10 lines · Ramsay Jones
Quoted 7 lines · Junio C Hamano

If somebody is reading FETCH_HEAD and acting on its contents (rather than merely consuming it as a ref of the first object), perhaps feeding it to "git fmt-merge-msg", they will be broken by such a change (indeed, our own "git pull" will be broken by the change to "git fetch", and the second bullet point above is about fixing the exact fallout from it), but I am not sure if that is a use case worth worrying about.

Quoted 8 lines
Quoted 3 lines

Yes, I was going to suggest exactly this, after Patrick pointed out that there were only two 'special psuedo-refs' (I had a vague feeling there were some more than that) FETCH_HEAD and MERGE_HEAD.

According to the pseudoref entry of gitglossary, CHERRY_PICK_HEAD also stores additional data (which would imply that REVERT_HEAD does too). Looking at CHERRY_PICK_HEAD during a pick though, I only see a single hash, even when picking multiple commits.

Both CHERRY_PICK_HEAD and REVERT_HEAD are only ever updated via the refs API, so neither of them ever contains anything other than a normal ref. I guess we should update the glossary accordingly.

Patrick

#24 lore raw
In reply to Junio C Hamano
Quoted 3 lines · Junio C Hamano

A pseudo ref is merely a normal ref with a funny naming convention, i.e., being outside the refs/ hierarchy and has names with all uppercase letters (or an underscore).

I know what you mean, but gitglossary defines pseudorefs as separate from refs, albeit behaving like refs. Their name itself implies the same.

Although the 'ref' entry then goes on to say that "there are a few special-purpose refs that do not begin with 'refs/', the most notable example being HEAD."

That implies that at least some of the pseudorefs are refs after all, while keeping in mind that "HEAD is not a pseudoref, because it is sometimes a symbolic ref" according to the 'pseudoref' entry.

I think a clearer answer on whether pseudorefs are refs is needed, or at least a better-defined fudge, such as "pseudorefs are refs except when ...".

Defining everything under "refs/" as refs, and the stuff outside it including HEAD itself as pseudorefs, would draw clearer lines. The fact HEAD is usually symbolic doesn't seem all that relevant from the perspective of a user trying to get a grasp of refs and pseudorefs.

Regards,
Andy

#25 lore raw
In reply to Junio C Hamano
Quoted 13 lines · Junio C Hamano

Patrick's reftable work is progressing nicely and wants to establish "special ref" as a phrase with some defined meaning that is somewhat different from a mere "pseudo ref".

A pseudo ref is merely a normal ref with a funny naming convention, i.e., being outside the refs/ hierarchy and has names with all uppercase letters (or an underscore). But there truly are refs that are more than that. For example, FETCH_HEAD currently stores not just a single object name, but can and is used to store multiple object names, each with annotations to record where they came from. There indeed may be a need to introduce a new term to refer to such "special refs".

Quoted 6 lines

Existing documentation, however, uses "special ref" to refer to pseudo refs without any "special" property, like FETCH_HEAD does.

This series merely corrects such existing uses of the word, to make room for Patrick's series to introduce (and formally define in the glossary) "special refs".

Thanks for helping out with this effort and kicking off the discussion, I highly appreciate it!

Patrick

Quoted 19 lines

Junio C Hamano (5):
git.txt: HEAD is not that special
git-bisect.txt: BISECT_HEAD is not that special
refs.h: HEAD is not that special
docs: AUTO_MERGE is not that special
docs: MERGE_AUTOSTASH is not that special

 Documentation/git-bisect.txt    | 2 +-
 Documentation/git-diff.txt      | 2 +-
 Documentation/git-merge.txt     | 2 +-
 Documentation/git.txt           | 7 ++++---
 Documentation/merge-options.txt | 2 +-
 Documentation/user-manual.txt   | 2 +-
 refs.h                          | 2 +-
 7 files changed, 10 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0-76-g1a87c842ec