[PATCH] Make update-ref a builtin.

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

 



Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 This is applied on top of `next` and my other reflog changes.
 I put it together just to reduce the disk usage - as Linus noted
 PowerPC ain't too slim on its executables...

 Makefile                             |    6 +++---
 update-ref.c => builtin-update-ref.c |    9 +++++----
 builtin.h                            |    1 +
 git.c                                |    1 +
 4 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 5f8ea18..7dfeb97 100644
--- a/Makefile
+++ b/Makefile
@@ -161,7 +161,7 @@ PROGRAMS = \
 	git-ssh-upload$X git-unpack-file$X \
 	git-unpack-objects$X git-update-index$X git-update-server-info$X \
 	git-upload-pack$X git-verify-pack$X git-write-tree$X \
-	git-update-ref$X git-symbolic-ref$X \
+	git-symbolic-ref$X \
 	git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
 	git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
 
@@ -172,7 +172,7 @@ BUILT_INS = git-log$X git-whatchanged$X 
 	git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
 	git-ls-files$X git-ls-tree$X \
 	git-read-tree$X git-commit-tree$X \
-	git-apply$X git-show-branch$X git-diff-files$X \
+	git-update-ref$X git-apply$X git-show-branch$X git-diff-files$X \
 	git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X
 
 # what 'all' will build and 'install' will install, in gitexecdir
@@ -228,7 +228,7 @@ BUILTIN_OBJS = \
 	builtin-read-tree.o builtin-commit-tree.o \
 	builtin-apply.o builtin-show-branch.o builtin-diff-files.o \
 	builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o \
-	builtin-cat-file.o
+	builtin-update-ref.o builtin-cat-file.o
 
 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 LIBS = $(GITLIBS) -lz
diff --git a/update-ref.c b/builtin-update-ref.c
similarity index 85%
rename from update-ref.c
rename to builtin-update-ref.c
index a1e6bb9..2c62286 100644
--- a/update-ref.c
+++ b/builtin-update-ref.c
@@ -1,10 +1,11 @@
 #include "cache.h"
 #include "refs.h"
+#include "builtin.h"
 
-static const char git_update_ref_usage[] =
+static const char builtin_update_ref_usage[] =
 "git-update-ref <refname> <value> [<oldval>] [-m <reason>]";
 
-int main(int argc, char **argv)
+int cmd_update_ref(int argc, const char **argv, char **envp)
 {
 	const char *refname=NULL, *value=NULL, *oldval=NULL, *msg=NULL;
 	struct ref_lock *lock;
@@ -17,7 +18,7 @@ int main(int argc, char **argv)
 	for (i = 1; i < argc; i++) {
 		if (!strcmp("-m", argv[i])) {
 			if (i+1 >= argc)
-				usage(git_update_ref_usage);
+				usage(builtin_update_ref_usage);
 			msg = argv[++i];
 			if (!*msg)
 				die("Refusing to perform update with empty message.");
@@ -39,7 +40,7 @@ int main(int argc, char **argv)
 		}
 	}
 	if (!refname || !value)
-		usage(git_update_ref_usage);
+		usage(builtin_update_ref_usage);
 
 	if (get_sha1(value, sha1))
 		die("%s: not a valid SHA1", value);
diff --git a/builtin.h b/builtin.h
index 738ec3d..397b770 100644
--- a/builtin.h
+++ b/builtin.h
@@ -28,6 +28,7 @@ extern int cmd_grep(int argc, const char
 extern int cmd_rm(int argc, const char **argv, char **envp);
 extern int cmd_add(int argc, const char **argv, char **envp);
 extern int cmd_rev_list(int argc, const char **argv, char **envp);
+extern int cmd_update_ref(int argc, const char **argv, char **envp);
 extern int cmd_check_ref_format(int argc, const char **argv, char **envp);
 extern int cmd_init_db(int argc, const char **argv, char **envp);
 extern int cmd_tar_tree(int argc, const char **argv, char **envp);
diff --git a/git.c b/git.c
index 10ea934..f37b020 100644
--- a/git.c
+++ b/git.c
@@ -57,6 +57,7 @@ static void handle_internal_command(int 
 		{ "init-db", cmd_init_db },
 		{ "tar-tree", cmd_tar_tree },
 		{ "upload-tar", cmd_upload_tar },
+		{ "update-ref", cmd_update_ref },
 		{ "check-ref-format", cmd_check_ref_format },
 		{ "ls-files", cmd_ls_files },
 		{ "ls-tree", cmd_ls_tree },
-- 
1.3.3.g45d8

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]