Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | git-check-ref-format(1) |
| 2 | ======================= |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 6 | git-check-ref-format - Ensures that a reference name is well formed |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
Junio C Hamano | 5f9a6f0 | 2009-04-06 08:26:56 | [diff] [blame] | 10 | [verse] |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 11 | 'git check-ref-format' <refname> |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 12 | 'git check-ref-format' --print <refname> |
Junio C Hamano | 3d23a0a | 2009-10-19 08:04:30 | [diff] [blame] | 13 | 'git check-ref-format' --branch <branchname-shorthand> |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 14 | |
| 15 | DESCRIPTION |
| 16 | ----------- |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 17 | Checks if a given 'refname' is acceptable, and exits with a non-zero |
| 18 | status if it is not. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 19 | |
| 20 | A reference is used in git to specify branches and tags. A |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 21 | branch head is stored under the `$GIT_DIR/refs/heads` directory, and |
| 22 | a tag is stored under the `$GIT_DIR/refs/tags` directory. git |
| 23 | imposes the following rules on how references are named: |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 24 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 25 | . They can include slash `/` for hierarchical (directory) |
Junio C Hamano | 33db437 | 2006-06-07 19:51:45 | [diff] [blame] | 26 | grouping, but no slash-separated component can begin with a |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 27 | dot `.`. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 28 | |
Junio C Hamano | 8679a79 | 2009-05-13 20:50:32 | [diff] [blame] | 29 | . They must contain at least one `/`. This enforces the presence of a |
| 30 | category like `heads/`, `tags/` etc. but the actual names are not |
| 31 | restricted. |
| 32 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 33 | . They cannot have two consecutive dots `..` anywhere. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 34 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 35 | . They cannot have ASCII control characters (i.e. bytes whose |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 36 | values are lower than \040, or \177 `DEL`), space, tilde `~`, |
| 37 | caret `{caret}`, colon `:`, question-mark `?`, asterisk `*`, |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 38 | or open bracket `[` anywhere. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 39 | |
Junio C Hamano | 5f9a6f0 | 2009-04-06 08:26:56 | [diff] [blame] | 40 | . They cannot end with a slash `/` nor a dot `.`. |
| 41 | |
| 42 | . They cannot end with the sequence `.lock`. |
| 43 | |
| 44 | . They cannot contain a sequence `@{`. |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 45 | |
Junio C Hamano | 7ae1825 | 2009-05-23 09:53:32 | [diff] [blame] | 46 | - They cannot contain a `\\`. |
| 47 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 48 | These rules make it easy for shell script based tools to parse |
| 49 | reference names, pathname expansion by the shell when a reference name is used |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 50 | unquoted (by mistake), and also avoids ambiguities in certain |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 51 | reference name expressions (see linkgit:git-rev-parse[1]): |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 52 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 53 | . A double-dot `..` is often used as in `ref1..ref2`, and in some |
| 54 | contexts this notation means `{caret}ref1 ref2` (i.e. not in |
| 55 | `ref1` and in `ref2`). |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 56 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 57 | . A tilde `~` and caret `{caret}` are used to introduce the postfix |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 58 | 'nth parent' and 'peel onion' operation. |
| 59 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 60 | . A colon `:` is used as in `srcref:dstref` to mean "use srcref\'s |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 61 | value and store it in dstref" in fetch and push operations. |
Junio C Hamano | b2f5edd | 2006-05-21 10:50:09 | [diff] [blame] | 62 | It may also be used to select a specific object such as with |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 63 | 'git-cat-file': "git cat-file blob v1.3.3:refs.c". |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 64 | |
Junio C Hamano | 5f9a6f0 | 2009-04-06 08:26:56 | [diff] [blame] | 65 | . at-open-brace `@{` is used as a notation to access a reflog entry. |
| 66 | |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 67 | With the `--print` option, if 'refname' is acceptable, it prints the |
| 68 | canonicalized name of a hypothetical reference with that name. That is, |
| 69 | it prints 'refname' with any extra `/` characters removed. |
| 70 | |
Junio C Hamano | 3d23a0a | 2009-10-19 08:04:30 | [diff] [blame] | 71 | With the `--branch` option, it expands the ``previous branch syntax'' |
| 72 | `@{-n}`. For example, `@{-1}` is a way to refer the last branch you |
| 73 | were on. This option should be used by porcelains to accept this |
| 74 | syntax anywhere a branch name is expected, so they can act as if you |
| 75 | typed the branch name. |
Junio C Hamano | 5f9a6f0 | 2009-04-06 08:26:56 | [diff] [blame] | 76 | |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 77 | EXAMPLES |
| 78 | -------- |
Junio C Hamano | 5f9a6f0 | 2009-04-06 08:26:56 | [diff] [blame] | 79 | |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 80 | * Print the name of the previous branch: |
| 81 | + |
| 82 | ------------ |
| 83 | $ git check-ref-format --branch @{-1} |
| 84 | ------------ |
Junio C Hamano | 5f9a6f0 | 2009-04-06 08:26:56 | [diff] [blame] | 85 | |
Junio C Hamano | c21ab05 | 2009-10-31 04:03:55 | [diff] [blame] | 86 | * Determine the reference name to use for a new branch: |
| 87 | + |
| 88 | ------------ |
| 89 | $ ref=$(git check-ref-format --print "refs/heads/$newbranch") || |
| 90 | die "we do not like '$newbranch' as a branch name." |
| 91 | ------------ |
Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 92 | |
| 93 | GIT |
| 94 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 95 | Part of the linkgit:git[1] suite |