]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-check-ref-format.txt
strbuf_check_branch_ref(): a helper to check a refname for a branch
[thirdparty/git.git] / Documentation / git-check-ref-format.txt
CommitLineData
622ef9df
JH
1git-check-ref-format(1)
2=======================
3
4NAME
5----
7bd7f280 6git-check-ref-format - Make sure ref name is well formed
622ef9df
JH
7
8SYNOPSIS
9--------
a31dca03 10[verse]
b1889c36 11'git check-ref-format' <refname>
a31dca03 12'git check-ref-format' [--branch] <branchname-shorthand>
622ef9df
JH
13
14DESCRIPTION
15-----------
16Checks if a given 'refname' is acceptable, and exits non-zero if
17it is not.
18
19A reference is used in git to specify branches and tags. A
20branch head is stored under `$GIT_DIR/refs/heads` directory, and
21a tag is stored under `$GIT_DIR/refs/tags` directory. git
22imposes the following rules on how refs are named:
23
37425065
FD
24. It can include slash `/` for hierarchical (directory)
25 grouping, but no slash-separated component can begin with a
26 dot `.`;
622ef9df
JH
27
28. It cannot have two consecutive dots `..` anywhere;
29
30. It cannot have ASCII control character (i.e. bytes whose
31 values are lower than \040, or \177 `DEL`), space, tilde `~`,
68283999
JH
32 caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`,
33 or open bracket `[` anywhere;
622ef9df
JH
34
35. It cannot end with a slash `/`.
36
37These rules makes it easy for shell script based tools to parse
68283999
JH
38refnames, pathname expansion by the shell when a refname is used
39unquoted (by mistake), and also avoids ambiguities in certain
5162e697 40refname expressions (see linkgit:git-rev-parse[1]). Namely:
622ef9df
JH
41
42. double-dot `..` are often used as in `ref1..ref2`, and in some
43 context this notation means `{caret}ref1 ref2` (i.e. not in
44 ref1 and in ref2).
45
46. tilde `~` and caret `{caret}` are used to introduce postfix
47 'nth parent' and 'peel onion' operation.
48
49. colon `:` is used as in `srcref:dstref` to mean "use srcref\'s
50 value and store it in dstref" in fetch and push operations.
87a56cd3 51 It may also be used to select a specific object such as with
ba020ef5 52 'git-cat-file': "git cat-file blob v1.3.3:refs.c".
622ef9df 53
a31dca03
JH
54With the `--branch` option, it expands a branch name shorthand and
55prints the name of the branch the shorthand refers to.
56
57EXAMPLE
58-------
59
60git check-ref-format --branch @{-1}::
61
62Print the name of the previous branch.
63
622ef9df
JH
64
65GIT
66---
9e1f0a85 67Part of the linkgit:git[1] suite