Skip to content

Commit e14c92e

Browse files
jacob-kellergitster
authored andcommitted
notes: correct documentation of DWIMery for notes references
expand_notes_ref is used by --ref from git-notes(1) and --notes from the git log to find the full refname of a notes reference. Previously the documentation of these options was not clear about what sorts of expansions would be performed. Fix the documentation to clearly and accurately describe the behavior of the expansions. Add a test for this expansion when using git notes get-ref in order to prevent future patches from changing this behavior. Signed-off-by: Jacob Keller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ee6ad5f commit e14c92e

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

Documentation/git-notes.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ OPTIONS
162162
--ref <ref>::
163163
Manipulate the notes tree in <ref>. This overrides
164164
'GIT_NOTES_REF' and the "core.notesRef" configuration. The ref
165-
is taken to be in `refs/notes/` if it is not qualified.
165+
specifies the full refname when it begins with `refs/notes/`; when it
166+
begins with `notes/`, `refs/` and otherwise `refs/notes/` is prefixed
167+
to form a full name of the ref.
166168

167169
--ignore-missing::
168170
Do not consider it an error to request removing notes from an

Documentation/pretty-options.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ By default, the notes shown are from the notes refs listed in the
5555
environment overrides). See linkgit:git-config[1] for more details.
5656
+
5757
With an optional '<ref>' argument, show this notes ref instead of the
58-
default notes ref(s). The ref is taken to be in `refs/notes/` if it
59-
is not qualified.
58+
default notes ref(s). The ref specifies the full refname when it begins
59+
with `refs/notes/`; when it begins with `notes/`, `refs/` and otherwise
60+
`refs/notes/` is prefixed to form a full name of the ref.
6061
+
6162
Multiple --notes options can be combined to control which notes are
6263
being displayed. Examples: "--notes=foo" will show only notes from

t/t3301-notes.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,12 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' '
11221122
test_must_fail git notes copy one two three
11231123
'
11241124

1125+
test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' '
1126+
test_unconfig core.notesRef &&
1127+
sane_unset GIT_NOTES_REF &&
1128+
test "$(git notes --ref=refs/heads/master get-ref)" = "refs/notes/refs/heads/master"
1129+
'
1130+
11251131
test_expect_success 'git notes get-ref (no overrides)' '
11261132
test_unconfig core.notesRef &&
11271133
sane_unset GIT_NOTES_REF &&

0 commit comments

Comments
 (0)