summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/refs.c b/refs.c
index b2a37e1185..aeef257ee3 100644
--- a/refs.c
+++ b/refs.c
@@ -694,6 +694,7 @@ static inline int bad_ref_char(int ch)
int check_ref_format(const char *ref)
{
int ch, level, bad_type;
+ int ret = CHECK_REF_FORMAT_OK;
const char *cp = ref;
level = 0;
@@ -709,18 +710,18 @@ int check_ref_format(const char *ref)
return CHECK_REF_FORMAT_ERROR;
bad_type = bad_ref_char(ch);
if (bad_type) {
- return (bad_type == 2 && !*cp)
- ? CHECK_REF_FORMAT_WILDCARD
- : CHECK_REF_FORMAT_ERROR;
+ if (bad_type == 2 && (!*cp || *cp == '/') &&
+ ret == CHECK_REF_FORMAT_OK)
+ ret = CHECK_REF_FORMAT_WILDCARD;
+ else
+ return CHECK_REF_FORMAT_ERROR;
}
/* scan the rest of the path component */
while ((ch = *cp++) != 0) {
bad_type = bad_ref_char(ch);
if (bad_type) {
- return (bad_type == 2 && !*cp)
- ? CHECK_REF_FORMAT_WILDCARD
- : CHECK_REF_FORMAT_ERROR;
+ return CHECK_REF_FORMAT_ERROR;
}
if (ch == '/')
break;
@@ -731,7 +732,7 @@ int check_ref_format(const char *ref)
if (!ch) {
if (level < 2)
return CHECK_REF_FORMAT_ONELEVEL;
- return CHECK_REF_FORMAT_OK;
+ return ret;
}
}
}
@@ -995,7 +996,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
err = unlink(git_path("logs/%s", lock->ref_name));
if (err && errno != ENOENT)
- fprintf(stderr, "warning: unlink(%s) failed: %s",
+ warning("unlink(%s) failed: %s",
git_path("logs/%s", lock->ref_name), strerror(errno));
invalidate_cached_refs();
unlock_ref(lock);
@@ -1437,8 +1438,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
if (get_sha1_hex(rec + 41, sha1))
die("Log %s is corrupt.", logfile);
if (hashcmp(logged_sha1, sha1)) {
- fprintf(stderr,
- "warning: Log %s has gap after %s.\n",
+ warning("Log %s has gap after %s.",
logfile, show_date(date, tz, DATE_RFC2822));
}
}
@@ -1450,8 +1450,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *
if (get_sha1_hex(rec + 41, logged_sha1))
die("Log %s is corrupt.", logfile);
if (hashcmp(logged_sha1, sha1)) {
- fprintf(stderr,
- "warning: Log %s unexpectedly ended on %s.\n",
+ warning("Log %s unexpectedly ended on %s.",
logfile, show_date(date, tz, DATE_RFC2822));
}
}