[PATCH 3/8] refs: move is_pseudoref_syntax() definition earlier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We have a static local function is_pseudoref_syntax(), used by
is_pseudoref(). The difference being that the former checks only syntax,
whereas the latter actually looks at the on-disk refs.

There are a few other places in the file where we care about the
pseudoref syntax and could make use of this function. Let's move it
earlier in the file, so it can be used more extensively without having
to forward declare it.

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
 refs.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/refs.c b/refs.c
index 55d2e0b2cb..d3d21ecd43 100644
--- a/refs.c
+++ b/refs.c
@@ -164,6 +164,22 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref)
 	info->ref_updated = 1;
 }
 
+static int is_pseudoref_syntax(const char *refname)
+{
+	const char *c;
+
+	for (c = refname; *c; c++) {
+		if (!isupper(*c) && *c != '-' && *c != '_')
+			return 0;
+	}
+
+	/*
+	 * HEAD is not a pseudoref, but it certainly uses the
+	 * pseudoref syntax.
+	 */
+	return 1;
+}
+
 /*
  * Try to read one refname component from the front of refname.
  * Return the length of the component found, or -1 if the component is
@@ -844,22 +860,6 @@ int is_per_worktree_ref(const char *refname)
 	       starts_with(refname, "refs/rewritten/");
 }
 
-static int is_pseudoref_syntax(const char *refname)
-{
-	const char *c;
-
-	for (c = refname; *c; c++) {
-		if (!isupper(*c) && *c != '-' && *c != '_')
-			return 0;
-	}
-
-	/*
-	 * HEAD is not a pseudoref, but it certainly uses the
-	 * pseudoref syntax.
-	 */
-	return 1;
-}
-
 int is_pseudoref(struct ref_store *refs, const char *refname)
 {
 	static const char *const irregular_pseudorefs[] = {
-- 
2.45.0.rc1.416.gbe2a76c799





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux