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

[PATCH] Make git-check-format-ref a builtin.

From
Lukas Sandström <lukass@etek.chalmers.se>
Date
May 18, 2006, 12:15 UTC
Message-ID
<446C657B.7020100@etek.chalmers.se>
Signed-off-by: Lukas Sandström <lukass@etek.chalmers.se>

--- It was already written in C, but now it's 219k less in my ~/bin dir.

 Makefile                   |    4 ++--
 builtin-check-ref-format.c |   13 +++++++++++++
 builtin.h                  |    2 ++
 git.c                      |    1 +
 4 files changed, 18 insertions(+), 2 deletions(-)
 create mode 100644 builtin-check-ref-format.c
2e18872b12d1635a6814053f3cfc3c9e433db428
diff --git a/Makefile b/Makefile
index 3a28580..b737cb8 100644
--- a/Makefile
+++ b/Makefile
@@ -170,7 +170,7 @@ PROGRAMS = \
 
 BUILT_INS = git-log$X git-whatchanged$X git-show$X \
 	git-count-objects$X git-diff$X git-push$X \
-	git-grep$X git-add$X
+	git-grep$X git-add$X git-check-ref-format$X
 
 # what 'all' will build and 'install' will install, in gitexecdir
 ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
@@ -218,7 +218,7 @@ LIB_OBJS = \
 
 BUILTIN_OBJS = \
 	builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
-	builtin-grep.o builtin-add.o
+	builtin-grep.o builtin-add.o builtin-check-ref-format.o
 
 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 LIBS = $(GITLIBS) -lz
diff --git a/builtin-check-ref-format.c b/builtin-check-ref-format.c
new file mode 100644
index 0000000..ac29383
--- /dev/null
+++ b/builtin-check-ref-format.c
@@ -0,0 +1,13 @@
+/*
+ * GIT - The information manager from hell
+ */
+
+#include "cache.h"
+#include "refs.h"
+
+int cmd_check_ref_format(int argc, const char **argv, char **envp)
+{
+	if (argc != 2)
+		usage("git check-ref-format refname");
+	return check_ref_format(argv[1]) == 0 ? 0 : 1;
+}
diff --git a/builtin.h b/builtin.h
index ccd0e31..a26f2c2 100644
--- a/builtin.h
+++ b/builtin.h
@@ -27,4 +27,6 @@ extern int cmd_push(int argc, const char
 extern int cmd_grep(int argc, const char **argv, char **envp);
 extern int cmd_add(int argc, const char **argv, char **envp);
 
+extern int cmd_check_ref_format(int argc, const char **argv, char **envp);
+
 #endif
diff --git a/git.c b/git.c
index 6a470cf..62baf25 100644
--- a/git.c
+++ b/git.c
@@ -52,6 +52,7 @@ static void handle_internal_command(int 
 		{ "diff", cmd_diff },
 		{ "grep", cmd_grep },
 		{ "add", cmd_add },
+		{ "check-ref-format", cmd_check_ref_format }
 	};
 	int i;
 
-- 
1.3.2.g3c45-dirty
Next: Lukas Sandström
Message 1 of 2 in “Make git-check-format-ref a builtin.”
  1. Make git-check-format-ref a builtin.Lukas Sandström, May 18, 2006
  2. Remove the non-builtin git-check-ref-formatLukas Sandström, May 18, 2006

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.