git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 08/43] refs.c: move the hidden refs functions to the common code

From
David Turner <dturner@twopensource.com>
Date
Sep 3, 2015, 01:54 UTC
Message-ID
<1441245313-11907-9-git-send-email-dturner@twopensource.com>
In-Reply-To
<1441245313-11907-1-git-send-email-dturner@twopensource.com>
From: Ronnie Sahlberg <sahlberg@google.com>

Move the hidden refs functions to the refs.c file since these functions do not contain any backend specific code.

Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: David Turner <dturner@twitter.com>
---
 refs-be-files.c | 51 ---------------------------------------------------
 refs.c          | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 51 deletions(-)
diff --git a/refs-be-files.c b/refs-be-files.c
index 085f776..e559d46 100644
--- a/refs-be-files.c
+++ b/refs-be-files.c
@@ -4179,57 +4179,6 @@ char *shorten_unambiguous_ref(const char *refname, int strict)
 	return xstrdup(refname);
 }
 
-static struct string_list *hide_refs;
-
-int parse_hide_refs_config(const char *var, const char *value, const char *section)
-{
-	if (!strcmp("transfer.hiderefs", var) ||
-	    /* NEEDSWORK: use parse_config_key() once both are merged */
-	    (starts_with(var, section) && var[strlen(section)] == '.' &&
-	     !strcmp(var + strlen(section), ".hiderefs"))) {
-		char *ref;
-		int len;
-
-		if (!value)
-			return config_error_nonbool(var);
-		ref = xstrdup(value);
-		len = strlen(ref);
-		while (len && ref[len - 1] == '/')
-			ref[--len] = '\0';
-		if (!hide_refs) {
-			hide_refs = xcalloc(1, sizeof(*hide_refs));
-			hide_refs->strdup_strings = 1;
-		}
-		string_list_append(hide_refs, ref);
-	}
-	return 0;
-}
-
-int ref_is_hidden(const char *refname)
-{
-	int i;
-
-	if (!hide_refs)
-		return 0;
-	for (i = hide_refs->nr - 1; i >= 0; i--) {
-		const char *match = hide_refs->items[i].string;
-		int neg = 0;
-		int len;
-
-		if (*match == '!') {
-			neg = 1;
-			match++;
-		}
-
-		if (!starts_with(refname, match))
-			continue;
-		len = strlen(match);
-		if (!refname[len] || refname[len] == '/')
-			return !neg;
-	}
-	return 0;
-}
-
 struct expire_reflog_cb {
 	unsigned int flags;
 	reflog_expiry_should_prune_fn *should_prune_fn;
diff --git a/refs.c b/refs.c
index 5a8ef0c..6b2fc39 100644
--- a/refs.c
+++ b/refs.c
@@ -328,3 +328,53 @@ int read_ref_at(const char *refname, unsigned int flags, unsigned long at_time,
 
 	return 1;
 }
+
+static struct string_list *hide_refs;
+
+int parse_hide_refs_config(const char *var, const char *value, const char *section)
+{
+	if (!strcmp("transfer.hiderefs", var) ||
+	    /* NEEDSWORK: use parse_config_key() once both are merged */
+	    (starts_with(var, section) && var[strlen(section)] == '.' &&
+	     !strcmp(var + strlen(section), ".hiderefs"))) {
+		char *ref;
+		int len;
+
+		if (!value)
+			return config_error_nonbool(var);
+		ref = xstrdup(value);
+		len = strlen(ref);
+		while (len && ref[len - 1] == '/')
+			ref[--len] = '\0';
+		if (!hide_refs) {
+			hide_refs = xcalloc(1, sizeof(*hide_refs));
+			hide_refs->strdup_strings = 1;
+		}
+		string_list_append(hide_refs, ref);
+	}
+	return 0;
+}
+
+int ref_is_hidden(const char *refname)
+{
+	int i;
+
+	if (!hide_refs)
+		return 0;
+	for (i = hide_refs->nr - 1; i >= 0; i--) {
+		const char *match = hide_refs->items[i].string;
+		int neg = 0;
+		int len;
+		if (*match == '!') {
+			neg = 1;
+			match++;
+		}
+
+		if (!starts_with(refname, match))
+			continue;
+		len = strlen(match);
+		if (!refname[len] || refname[len] == '/')
+			return !neg;
+	}
+	return 0;
+}
-- 
2.0.4.315.gad8727a-twtrsrc
Previous: David TurnerNext: David Turner
Message 10 of 54 in “refs lmdb backend”
  1. 00/43 refs lmdb backendDavid Turner, Sep 3, 2015
  2. 01/43 refs.c: create a public version of verify_refname_availableDavid Turner, Sep 3, 2015
  3. Junio C HamanoSep 3, 2015
  4. David TurnerSep 4, 2015
  5. 02/43 refs: make repack_without_refs and is_branch publicDavid Turner, Sep 3, 2015
  6. 04/43 refs.c: add a new refs.c file to hold all common refs codeDavid Turner, Sep 3, 2015
  7. 05/43 refs.c: move update_ref to refs.cDavid Turner, Sep 3, 2015
  8. 06/43 refs.c: move delete_ref and delete_refs to the common codeDavid Turner, Sep 3, 2015
  9. 07/43 refs.c: move read_ref_at to the common refs fileDavid Turner, Sep 3, 2015
  10. 08/43 refs.c: move the hidden refs functions to the common codeDavid Turner, Sep 3, 2015
  11. 09/43 refs.c: move dwim and friend functions to the common refs codeDavid Turner, Sep 3, 2015
  12. 10/43 refs.c: move warn_if_dangling_symref* to the common codeDavid Turner, Sep 3, 2015
  13. 11/43 refs.c: move read_ref, read_ref_full and ref_exists to the common codeDavid Turner, Sep 3, 2015
  14. 12/43 refs.c: move resolve_refdup to commonDavid Turner, Sep 3, 2015
  15. 13/43 refs.c: move check_refname_format to the common codeDavid Turner, Sep 3, 2015
  16. 14/43 refs.c: move is_branch to the common codeDavid Turner, Sep 3, 2015
  17. 15/43 refs.c: move prettify_refname to the common codeDavid Turner, Sep 3, 2015
  18. 16/43 refs.c: move ref iterators to the common codeDavid Turner, Sep 3, 2015
  19. 17/43 refs.c: move head_ref_namespaced to the common codeDavid Turner, Sep 3, 2015
  20. 18/43 refs-be-files.c: add a backend method structure with transaction functionsDavid Turner, Sep 3, 2015
  21. 19/43 refs-be-files.c: add methods for misc ref operationsDavid Turner, Sep 3, 2015
  22. 20/43 refs-be-files.c: add methods for the ref iteratorsDavid Turner, Sep 3, 2015
  23. Junio C HamanoSep 25, 2015
  24. David TurnerSep 25, 2015
  25. Junio C HamanoSep 25, 2015
  26. 21/43 refs-be-files.c: add method for for_each_reftype_...David Turner, Sep 3, 2015
  27. 22/43 refs-be-files.c: add do_for_each_per_worktree_refDavid Turner, Sep 3, 2015
  28. 23/43 refs.c: move refname_is_safe to the common codeDavid Turner, Sep 3, 2015
  29. 24/43 refs.h: document make refname_is_safe and add it to headerDavid Turner, Sep 3, 2015
  30. David TurnerSep 3, 2015
  31. 25/43 refs.c: move copy_msg to the common codeDavid Turner, Sep 3, 2015
  32. 26/43 refs.c: move peel_object to the common codeDavid Turner, Sep 3, 2015
  33. 27/43 refs.c: move should_autocreate_reflog to common codeDavid Turner, Sep 3, 2015
  34. 28/43 refs.c: add ref backend init functionDavid Turner, Sep 3, 2015
  35. 29/43 refs.c: add methods for reflogDavid Turner, Sep 3, 2015
  36. 30/43 refs.c: add method for initial ref transaction commitDavid Turner, Sep 3, 2015
  37. 31/43 initdb: move safe_create_dir into common codeDavid Turner, Sep 3, 2015
  38. 32/43 refs.c: add method for initializing refs dbDavid Turner, Sep 3, 2015
  39. 33/43 refs.c: make struct ref_transaction genericDavid Turner, Sep 3, 2015
  40. 34/43 refs-be-files.c: add method to rename refsDavid Turner, Sep 3, 2015
  41. 35/43 refs-be-files.c: add method to expire reflogsDavid Turner, Sep 3, 2015
  42. 36/43 run-command: track total number of commands runDavid Turner, Sep 3, 2015
  43. 37/43 refs: move some defines from refs-be-files.c to refs.hDavid Turner, Sep 3, 2015
  44. 38/43 refs: make some files backend functions publicDavid Turner, Sep 3, 2015
  45. 39/43 refs: break out a ref conflict checkDavid Turner, Sep 3, 2015
  46. 40/43 refs: allow ref backend to be set for cloneDavid Turner, Sep 3, 2015
  47. 41/43 refs: add register_refs_backendDavid Turner, Sep 3, 2015
  48. 42/43 refs: add LMDB refs backendDavid Turner, Sep 3, 2015
  49. Junio C HamanoSep 3, 2015
  50. 43/43 refs: tests for db backendDavid Turner, Sep 3, 2015
  51. Junio C HamanoSep 3, 2015
  52. David TurnerSep 4, 2015
  53. David TurnerSep 17, 2015
  54. Junio C HamanoSep 17, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.