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

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 12, 2008, 12:45 UTC
Message-ID
<alpine.LSU.1.00.0802121245140.3870@racer.site>
In-Reply-To
<alpine.LSU.1.00.0802121149220.3870@racer.site>
Hi,
On Tue, 12 Feb 2008, Johannes Schindelin wrote:
Show 9 quoted lines
> 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@gmx.de>
---
 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
Previous: Johannes SchindelinNext: Elijah Newren
Message 8 of 11 in “Unable to clone an ssh repository (with ugly installation-specific workaround)”
  1. Elijah NewrenFeb 12, 2008
  2. David SymondsFeb 12, 2008
  3. Jakub NarebskiFeb 12, 2008
  4. Johannes SixtFeb 12, 2008
  5. Johannes SchindelinFeb 12, 2008
  6. upload-pack: Initialize the exec-path.Johannes Sixt, Feb 12, 2008
  7. Johannes SchindelinFeb 12, 2008
  8. Johannes SchindelinFeb 12, 2008
  9. Elijah NewrenFeb 13, 2008
  10. Elijah NewrenFeb 13, 2008
  11. Stephen SinclairFeb 13, 2008

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.