summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2011-12-12 05:38:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-12-12 17:08:52 (GMT)
commit19b68b1e632ba989dc62d0956b7fd06978347370 (patch)
treebcbaddc808e32e42880bda854ec302308639e3c5 /refs.c
parent7c59511ed54aec999c7df3bd8e79b1eb33b92fa6 (diff)
downloadgit-19b68b1e632ba989dc62d0956b7fd06978347370.zip
git-19b68b1e632ba989dc62d0956b7fd06978347370.tar.gz
git-19b68b1e632ba989dc62d0956b7fd06978347370.tar.bz2
is_refname_available(): remove the "quiet" argument
quiet was always set to 0, so get rid of it. Add a function docstring for good measure. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/refs.c b/refs.c
index 7be91d1..d7d422f 100644
--- a/refs.c
+++ b/refs.c
@@ -1057,8 +1057,15 @@ static int remove_empty_directories(const char *file)
return result;
}
+/*
+ * Return true iff a reference named refname could be created without
+ * conflicting with the name of an existing reference. If oldrefname
+ * is non-NULL, ignore potential conflicts with oldrefname (e.g.,
+ * because oldrefname is scheduled for deletion in the same
+ * operation).
+ */
static int is_refname_available(const char *refname, const char *oldrefname,
- struct ref_array *array, int quiet)
+ struct ref_array *array)
{
int i, namlen = strlen(refname); /* e.g. 'foo/bar' */
for (i = 0; i < array->nr; i++ ) {
@@ -1070,9 +1077,8 @@ static int is_refname_available(const char *refname, const char *oldrefname,
const char *lead = (namlen < len) ? entry->name : refname;
if (!strncmp(refname, entry->name, cmplen) &&
lead[cmplen] == '/') {
- if (!quiet)
- error("'%s' exists; cannot create '%s'",
- entry->name, refname);
+ error("'%s' exists; cannot create '%s'",
+ entry->name, refname);
return 0;
}
}
@@ -1213,7 +1219,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
* name is a proper prefix of our refname.
*/
if (missing &&
- !is_refname_available(refname, NULL, get_packed_refs(NULL), 0)) {
+ !is_refname_available(refname, NULL, get_packed_refs(NULL))) {
last_errno = ENOTDIR;
goto error_return;
}
@@ -1367,10 +1373,10 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
if (!symref)
return error("refname %s not found", oldrefname);
- if (!is_refname_available(newrefname, oldrefname, get_packed_refs(NULL), 0))
+ if (!is_refname_available(newrefname, oldrefname, get_packed_refs(NULL)))
return 1;
- if (!is_refname_available(newrefname, oldrefname, get_loose_refs(NULL), 0))
+ if (!is_refname_available(newrefname, oldrefname, get_loose_refs(NULL)))
return 1;
if (log && rename(git_path("logs/%s", oldrefname), git_path(TMP_RENAMED_LOG)))