diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2009-03-24 16:31:01 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-03-24 17:02:20 -0700 |
commit | 3e262b95c50991de12cc5e180b72256561606a19 (patch) | |
tree | affb5e2c4e3fd692d75a999875fe7627a1b84feb /refs.c | |
parent | cbdffe4093be77bbb1408e54eead7865dd3bc33f (diff) | |
download | git-3e262b95c50991de12cc5e180b72256561606a19.tar.gz |
Don't permit ref/branch names to end with ".lock"
We already skip over loose refs under $GIT_DIR/refs if the name
ends with ".lock", so creating a branch named "foo.lock" will not
appear in the output of "git branch", "git for-each-ref", nor will
its commit be considered reachable by "git rev-list --all".
In the latter case this is especially evil, as it may cause
repository corruption when objects reachable only through such a
ref are deleted by "git prune".
It should be reasonably safe to deny use of ".lock" as a ref suffix.
In prior versions of Git such branches would be "phantom branches";
you can create it, but you can't see it in "git branch" output.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -676,6 +676,7 @@ int for_each_rawref(each_ref_fn fn, void *cb_data) * - it has double dots "..", or * - it has ASCII control character, "~", "^", ":" or SP, anywhere, or * - it ends with a "/". + * - it ends with ".lock" */ static inline int bad_ref_char(int ch) @@ -737,6 +738,8 @@ int check_ref_format(const char *ref) return CHECK_REF_FORMAT_ERROR; if (level < 2) return CHECK_REF_FORMAT_ONELEVEL; + if (has_extension(ref, ".lock")) + return CHECK_REF_FORMAT_ERROR; return ret; } } |