summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 321b184)
raw | patch | inline | side by side (parent: 321b184)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 2 Jan 2008 19:14:40 +0000 (11:14 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 2 Jan 2008 19:20:09 +0000 (11:20 -0800) |
This updates send-pack and fast-import to use symbolic constants
for checking the return values from check_ref_format(), and also
futureproof the logic in lock_any_ref_for_update() to explicitly
name the case that is usually considered an error but is Ok for
this particular use.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
for checking the return values from check_ref_format(), and also
futureproof the logic in lock_any_ref_for_update() to explicitly
name the case that is usually considered an error but is Ok for
this particular use.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-send-pack.c | patch | blob | history | |
fast-import.c | patch | blob | history | |
refs.c | patch | blob | history |
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 25ae1fe860601e672575b545bbd2fdfa6ad7966c..8afb1d0bca0635dc22f658455477d9fada231290 100644 (file)
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
remote = remote ? (remote + 1) : heads[i];
switch (check_ref_format(remote)) {
case 0: /* ok */
- case -2: /* ok but a single level -- that is fine for
- * a match pattern.
- */
- case -3: /* ok but ends with a pattern-match character */
+ case CHECK_REF_FORMAT_ONELEVEL:
+ /* ok but a single level -- that is fine for
+ * a match pattern.
+ */
+ case CHECK_REF_FORMAT_WILDCARD:
+ /* ok but ends with a pattern-match character */
continue;
}
die("remote part of refspec is not a valid name in %s",
diff --git a/fast-import.c b/fast-import.c
index 4646c056f32818549635b6ecc6b1088dc08ff469..74597c901c4e7bff7ed5344719c3162b4e096c3a 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
if (b)
die("Invalid attempt to create duplicate branch: %s", name);
switch (check_ref_format(name)) {
- case 0: break; /* its valid */
- case -2: break; /* valid, but too few '/', allow anyway */
+ case 0: break; /* its valid */
+ case CHECK_REF_FORMAT_ONELEVEL:
+ break; /* valid, but too few '/', allow anyway */
default:
die("Branch name doesn't conform to GIT standards: %s", name);
}
index 7484a46d6834b4c85dd81f1f38596bc3be087426..58f6d173970bcd3c1e540b7cff04d1613fce3692 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -822,10 +822,10 @@ struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags)
{
switch (check_ref_format(ref)) {
- case CHECK_REF_FORMAT_ERROR:
- case CHECK_REF_FORMAT_WILDCARD:
- return NULL;
default:
+ return NULL;
+ case 0:
+ case CHECK_REF_FORMAT_ONELEVEL:
return lock_ref_sha1_basic(ref, old_sha1, flags, NULL);
}
}