summaryrefslogtreecommitdiff
path: root/builtin-update-ref.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-01-29 08:57:07 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-01-29 08:57:07 (GMT)
commita2f9fe92ebfdf9b5c458642fa0bf32b17433c6c1 (patch)
treed1484466557729e27ba4dda475dd8c6a2e918f2c /builtin-update-ref.c
parentdf391b192d285646fe80ca4d3cfe3c0a3beb5989 (diff)
downloadgit-a2f9fe92ebfdf9b5c458642fa0bf32b17433c6c1.zip
git-a2f9fe92ebfdf9b5c458642fa0bf32b17433c6c1.tar.gz
git-a2f9fe92ebfdf9b5c458642fa0bf32b17433c6c1.tar.bz2
lock_any_ref_for_update(): do not accept malformatted refs.
We used to use lock_any_ref_for_update() because the command needs to also update HEAD (which is not under refs/, so lock_ref_sha1() cannot be used). The function however did not check for refs with illegal characters in them. Use check_ref_format() to catch malformed refs. For this check, we specifically do not want to say having less than two levels in the name is illegal to allow HEAD (and perhaps other special refs in the future). Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-update-ref.c')
-rw-r--r--builtin-update-ref.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index 1461937..5ee960b 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -61,10 +61,8 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL);
if (!lock)
- return 1;
+ die("%s: cannot lock the ref", refname);
if (write_ref_sha1(lock, sha1, msg) < 0)
- return 1;
-
- /* write_ref_sha1 always unlocks the ref, no need to do it explicitly */
+ die("%s: cannot update the ref", refname);
return 0;
}