Re: [PATCH] upload-pack: Initialize the exec-path.

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

 



Hi,

On Tue, 12 Feb 2008, Johannes Schindelin wrote:

> On Tue, 12 Feb 2008, Johannes Sixt wrote:
> 
> > Johannes Schindelin schrieb:
> >
> > > So, let's make git-upload-pack a builtin, no?
> > 
> > How about this (almost) one-liner instead?
> 
> I'm fine with it.

But I also made this:

-- snipsnap --
[PATCH] Make upload-pack a builtin

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---
 Makefile                               |    2 +-
 upload-pack.c => builtin-upload-pack.c |    8 +++++---
 builtin.h                              |    1 +
 git.c                                  |    1 +
 4 files changed, 8 insertions(+), 4 deletions(-)
 rename upload-pack.c => builtin-upload-pack.c (98%)

diff --git a/Makefile b/Makefile
index 83c359a..1792039 100644
--- a/Makefile
+++ b/Makefile
@@ -259,7 +259,6 @@ PROGRAMS = \
 	git-show-index$X \
 	git-unpack-file$X \
 	git-update-server-info$X \
-	git-upload-pack$X \
 	git-pack-redundant$X git-var$X \
 	git-merge-tree$X git-imap-send$X \
 	git-merge-recursive$X \
@@ -392,6 +391,7 @@ BUILTIN_OBJS = \
 	builtin-update-index.o \
 	builtin-update-ref.o \
 	builtin-upload-archive.o \
+	builtin-upload-pack.o \
 	builtin-verify-pack.o \
 	builtin-verify-tag.o \
 	builtin-write-tree.o \
diff --git a/upload-pack.c b/builtin-upload-pack.c
similarity index 98%
rename from upload-pack.c
rename to builtin-upload-pack.c
index 7e04311..207754c 100644
--- a/upload-pack.c
+++ b/builtin-upload-pack.c
@@ -10,6 +10,7 @@
 #include "revision.h"
 #include "list-objects.h"
 #include "run-command.h"
+#include "builtin.h"
 
 static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
 
@@ -593,14 +594,14 @@ static void upload_pack(void)
 	}
 }
 
-int main(int argc, char **argv)
+int cmd_upload_pack(int argc, const char **argv, const char *prefix)
 {
 	char *dir;
 	int i;
 	int strict = 0;
 
 	for (i = 1; i < argc; i++) {
-		char *arg = argv[i];
+		const char *arg = argv[i];
 
 		if (arg[0] != '-')
 			break;
@@ -620,12 +621,13 @@ int main(int argc, char **argv)
 
 	if (i != argc-1)
 		usage(upload_pack_usage);
-	dir = argv[i];
+	dir = xstrdup(argv[i]);
 
 	if (!enter_repo(dir, strict))
 		die("'%s': unable to chdir or not a git archive", dir);
 	if (is_repository_shallow())
 		die("attempt to fetch/clone from a shallow repository");
 	upload_pack();
+	free(dir);
 	return 0;
 }
diff --git a/builtin.h b/builtin.h
index 3d1628c..5e7d661 100644
--- a/builtin.h
+++ b/builtin.h
@@ -85,6 +85,7 @@ extern int cmd_unpack_objects(int argc, const char **argv, const char *prefix);
 extern int cmd_update_index(int argc, const char **argv, const char *prefix);
 extern int cmd_update_ref(int argc, const char **argv, const char *prefix);
 extern int cmd_upload_archive(int argc, const char **argv, const char *prefix);
+extern int cmd_upload_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_upload_tar(int argc, const char **argv, const char *prefix);
 extern int cmd_verify_tag(int argc, const char **argv, const char *prefix);
 extern int cmd_version(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 0cb8688..f0d831c 100644
--- a/git.c
+++ b/git.c
@@ -362,6 +362,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "update-index", cmd_update_index, RUN_SETUP },
 		{ "update-ref", cmd_update_ref, RUN_SETUP },
 		{ "upload-archive", cmd_upload_archive },
+		{ "upload-pack", cmd_upload_pack },
 		{ "verify-tag", cmd_verify_tag, RUN_SETUP },
 		{ "version", cmd_version },
 		{ "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
-- 
1.5.4.1.1276.g92036

-
To unsubscribe from this list: 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]

  Powered by Linux