Skip to content

Commit 89dd32a

Browse files
committed
check-ref-format doc: --branch validates and expands <branch>
"git check-ref-format --branch $name" feature was originally introduced (and was advertised) as a way for scripts to take any end-user supplied string (like "master", "@{-1}" etc.) and see if it is usable when Git expects to see a branch name, and also obtain the concrete branch name that the at-mark magic expands to. Emphasize that "see if it is usable" role in the description and clarify that the @{...} expansion only occurs when run from within a repository. [jn: split out from a larger patch] Helped-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ccc94f commit 89dd32a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Documentation/git-check-ref-format.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ reference name expressions (see linkgit:gitrevisions[7]):
7777

7878
. at-open-brace `@{` is used as a notation to access a reflog entry.
7979

80-
With the `--branch` option, it expands the ``previous branch syntax''
80+
With the `--branch` option, the command takes a name and checks if
81+
it can be used as a valid branch name (e.g. when creating a new
82+
branch). The rule `git check-ref-format --branch $name` implements
83+
may be stricter than what `git check-ref-format refs/heads/$name`
84+
says (e.g. a dash may appear at the beginning of a ref component,
85+
but it is explicitly forbidden at the beginning of a branch name).
86+
When run with `--branch` option in a repository, the input is first
87+
expanded for the ``previous branch syntax''
8188
`@{-n}`. For example, `@{-1}` is a way to refer the last branch you
8289
were on. This option should be used by porcelains to accept this
8390
syntax anywhere a branch name is expected, so they can act as if you

0 commit comments

Comments
 (0)