receive-pack: make it a builtin
authorJunio C Hamano <gitster@pobox.com>
Tue, 9 Sep 2008 08:27:08 +0000 (01:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Sep 2008 16:27:45 +0000 (09:27 -0700)
It is a good thing to do in general, but more importantly, transport
routines can only be used by built-ins, which is what I'll be adding next.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
builtin-receive-pack.c [moved from receive-pack.c with 99% similarity]
builtin.h
git.c

index f4c31c8714e33efe8c88b152fb8cc3cbf3bb3f16..f9c54ffd2f1de5698ce1bafcd42fb9260e252e00 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -294,7 +294,6 @@ PROGRAMS += git-mktag$X
 PROGRAMS += git-mktree$X
 PROGRAMS += git-pack-redundant$X
 PROGRAMS += git-patch-id$X
-PROGRAMS += git-receive-pack$X
 PROGRAMS += git-send-pack$X
 PROGRAMS += git-shell$X
 PROGRAMS += git-show-index$X
@@ -546,6 +545,7 @@ BUILTIN_OBJS += builtin-prune-packed.o
 BUILTIN_OBJS += builtin-prune.o
 BUILTIN_OBJS += builtin-push.o
 BUILTIN_OBJS += builtin-read-tree.o
+BUILTIN_OBJS += builtin-receive-pack.o
 BUILTIN_OBJS += builtin-reflog.o
 BUILTIN_OBJS += builtin-remote.o
 BUILTIN_OBJS += builtin-rerere.o
similarity index 99%
rename from receive-pack.c
rename to builtin-receive-pack.c
index b81678a9705c3f4bb7a6ff47e2af87db70e0ef66..6d6027ead17b86519d69c3dfc9b98c01e916d277 100644 (file)
@@ -462,14 +462,14 @@ static int delete_only(struct command *cmd)
        return 1;
 }
 
-int main(int argc, char **argv)
+int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 {
        int i;
        char *dir = NULL;
 
        argv++;
        for (i = 1; i < argc; i++) {
-               char *arg = *argv++;
+               const char *arg = *argv++;
 
                if (*arg == '-') {
                        /* Do flag handling here */
@@ -477,7 +477,7 @@ int main(int argc, char **argv)
                }
                if (dir)
                        usage(receive_pack_usage);
-               dir = arg;
+               dir = xstrdup(arg);
        }
        if (!dir)
                usage(receive_pack_usage);
index e67cb2090e8c111be4b137939953f3e006f31dfd..5d7cdca70c011b817b824ef77c5da71b2b80c64a 100644 (file)
--- a/builtin.h
+++ b/builtin.h
@@ -78,6 +78,7 @@ extern int cmd_prune(int argc, const char **argv, const char *prefix);
 extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
 extern int cmd_push(int argc, const char **argv, const char *prefix);
 extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_reflog(int argc, const char **argv, const char *prefix);
 extern int cmd_remote(int argc, const char **argv, const char *prefix);
 extern int cmd_config(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index adf73524098bdb308dea17b651536517a1588fef..2f5b4d72ee249821f88617a4d5a8bbf3a0204340 100644 (file)
--- a/git.c
+++ b/git.c
@@ -328,6 +328,7 @@ static void handle_internal_command(int argc, const char **argv)
                { "prune-packed", cmd_prune_packed, RUN_SETUP },
                { "push", cmd_push, RUN_SETUP },
                { "read-tree", cmd_read_tree, RUN_SETUP },
+               { "receive-pack", cmd_receive_pack },
                { "reflog", cmd_reflog, RUN_SETUP },
                { "remote", cmd_remote, RUN_SETUP },
                { "repo-config", cmd_config },