{"thread":{"id":"17078","subject":"[PATCH 2/6] Refactor git_set_argv0_path() to git_extract_argv0_path()","startedAt":"2009-01-10T13:50:47Z","lastAt":"2009-01-13T19:43:16Z","messageCount":16,"participants":["Steffen Prohaska","Johannes Schindelin","Junio C Hamano","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"99888","messageId":"1231595452-27698-1-git-send-email-prohaska@zib.de","threadId":"17078","inReplyTo":null,"subject":"[PATCH 1/6] Move computation of absolute paths from Makefile to runtime and compute prefix on the fly if RUNTIME_PREFIX set","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-10T13:50:47Z","receivedAt":"2009-01-10T13:50:47Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"This is the first commit of a series that adds support for\nrelocatable binaries (called RUNTIME_PREFIX).  Such binaries can be\nmoved together with the system configuration files to a different\ndirectory, as long as the relative paths from the binary to the\nconfiguration files is preserved.  This functionality is essential\non Windows where we deliver git binaries with an installer that\nallows to freely choose the installation location.  The commit\nseries implements RUNTIME_PREFIX only on Windows.  Adding support\non Unix should not be too hard, though.\n\nThis first commits makes all paths relative in the Makefile and\nteaches system_path() to add the prefix instead.  We used to\ncompute absolute paths in the Makefile and passed them to C as\ndefines.  We now pass relative paths to C and call system_path() to\nadd the prefix at runtime.\n\nIf RUNTIME_PREFIX is unset we use the static prefix.  This will be\nthe default on Unix.  Thus, the behavior on Unix will stay\nidentical to the old implementation, which added the prefix in the\nMakefile.\n\nIf RUNTIME_PREFIX is set the prefix is computed from the location\nof the executable.  In this case, system_path() tries to strip\nknown directories that executables can be located in from the path\nof the executable.  If the path is successfully stripped it is used\nas the prefix.  For example, if the executable is\n\"/msysgit/bin/git\" and BINDIR is \"bin\", then the prefix computed is\n\"/msysgit\".\n\nIf the runtime prefix computation fails, we fall back to the static\nprefix specified in the makefile.  This can be the case if the\nexecutable is not installed at a known location.  Note that our\ntest system sets GIT_CONFIG_NOSYSTEM to tell git to ignore global\nconfiguration files during testing.  Hence testing does not trigger\nthe fall back.\n\nNote that the implementation requires argv0_path to be set to an\nabsolute path, which is currently the case only on Windows.\nargv0_path must point to the directory of the executable.  We use\nassert() to verify this in debug builds.  On Windows, the wrapper\nfor main() (see compat/mingw.h) guarantees that argv0_path is\ncorrectly initialized.  On Unix, further work is required before\nRUNTIME_PREFIX can be enabled.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n Makefile       |   45 +++++++++++++++++++++++++++++----------------\n builtin-help.c |    4 ++--\n exec_cmd.c     |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++----\n 3 files changed, 81 insertions(+), 22 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex dee97c1..a7728a3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -179,28 +179,32 @@ STRIP ?= strip\n # Among the variables below, these:\n #   gitexecdir\n #   template_dir\n+#   mandir\n+#   infodir\n #   htmldir\n #   ETC_GITCONFIG (but not sysconfdir)\n-# can be specified as a relative path ../some/where/else (which must begin\n-# with ../); this is interpreted as relative to $(bindir) and \"git\" at\n+# can be specified as a relative path some/where/else;\n+# this is interpreted as relative to $(prefix) and \"git\" at\n # runtime figures out where they are based on the path to the executable.\n # This can help installing the suite in a relocatable way.\n \n prefix = $(HOME)\n-bindir = $(prefix)/bin\n-mandir = $(prefix)/share/man\n-infodir = $(prefix)/share/info\n-gitexecdir = $(prefix)/libexec/git-core\n+bindir_relative = bin\n+bindir = $(prefix)/$(bindir_relative)\n+mandir = share/man\n+infodir = share/info\n+gitexecdir = libexec/git-core\n sharedir = $(prefix)/share\n-template_dir = $(sharedir)/git-core/templates\n-htmldir=$(sharedir)/doc/git-doc\n+template_dir = share/git-core/templates\n+htmldir = share/doc/git-doc\n ifeq ($(prefix),/usr)\n sysconfdir = /etc\n+ETC_GITCONFIG = $(sysconfdir)/gitconfig\n else\n sysconfdir = $(prefix)/etc\n+ETC_GITCONFIG = etc/gitconfig\n endif\n lib = lib\n-ETC_GITCONFIG = $(sysconfdir)/gitconfig\n # DESTDIR=\n \n # default configuration for gitweb\n@@ -1027,6 +1031,9 @@ ifdef INTERNAL_QSORT\n \tCOMPAT_CFLAGS += -DINTERNAL_QSORT\n \tCOMPAT_OBJS += compat/qsort.o\n endif\n+ifdef RUNTIME_PREFIX\n+\tCOMPAT_CFLAGS += -DRUNTIME_PREFIX\n+endif\n \n ifdef NO_PTHREADS\n \tTHREADED_DELTA_SEARCH =\n@@ -1086,6 +1093,7 @@ ETC_GITCONFIG_SQ = $(subst ','\\'',$(ETC_GITCONFIG))\n \n DESTDIR_SQ = $(subst ','\\'',$(DESTDIR))\n bindir_SQ = $(subst ','\\'',$(bindir))\n+bindir_relative_SQ = $(subst ','\\'',$(bindir_relative))\n mandir_SQ = $(subst ','\\'',$(mandir))\n infodir_SQ = $(subst ','\\'',$(infodir))\n gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n@@ -1251,7 +1259,12 @@ git.o git.spec \\\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<\n \n exec_cmd.o: exec_cmd.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' $<\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \\\n+\t\t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n+\t\t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n+\t\t'-DPREFIX=\"$(prefix_SQ)\"' \\\n+\t\t$<\n+\n builtin-init-db.o: builtin-init-db.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ)\"' $<\n \n@@ -1400,17 +1413,17 @@ remove-dashes:\n \n ### Installation rules\n \n-ifeq ($(firstword $(subst /, ,$(template_dir))),..)\n-template_instdir = $(bindir)/$(template_dir)\n-else\n+ifeq ($(abspath $(template_dir)),$(template_dir))\n template_instdir = $(template_dir)\n+else\n+template_instdir = $(prefix)/$(template_dir)\n endif\n export template_instdir\n \n-ifeq ($(firstword $(subst /, ,$(gitexecdir))),..)\n-gitexec_instdir = $(bindir)/$(gitexecdir)\n-else\n+ifeq ($(abspath $(gitexecdir)),$(gitexecdir))\n gitexec_instdir = $(gitexecdir)\n+else\n+gitexec_instdir = $(prefix)/$(gitexecdir)\n endif\n gitexec_instdir_SQ = $(subst ','\\'',$(gitexec_instdir))\n export gitexec_instdir\ndiff --git a/builtin-help.c b/builtin-help.c\nindex f076efa..9b57a74 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -329,7 +329,7 @@ static void setup_man_path(void)\n \t * old_path, the ':' at the end will let 'man' to try\n \t * system-wide paths after ours to find the manual page. If\n \t * there is old_path, we need ':' as delimiter. */\n-\tstrbuf_addstr(&new_path, GIT_MAN_PATH);\n+\tstrbuf_addstr(&new_path, system_path(GIT_MAN_PATH));\n \tstrbuf_addch(&new_path, ':');\n \tif (old_path)\n \t\tstrbuf_addstr(&new_path, old_path);\n@@ -375,7 +375,7 @@ static void show_man_page(const char *git_cmd)\n static void show_info_page(const char *git_cmd)\n {\n \tconst char *page = cmd_to_page(git_cmd);\n-\tsetenv(\"INFOPATH\", GIT_INFO_PATH, 1);\n+\tsetenv(\"INFOPATH\", system_path(GIT_INFO_PATH), 1);\n \texeclp(\"info\", \"info\", \"gitman\", page, NULL);\n }\n \ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex cdd35f9..669b82e 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -9,11 +9,57 @@ static const char *argv0_path;\n \n const char *system_path(const char *path)\n {\n-\tif (!is_absolute_path(path) && argv0_path) {\n-\t\tstruct strbuf d = STRBUF_INIT;\n-\t\tstrbuf_addf(&d, \"%s/%s\", argv0_path, path);\n-\t\tpath = strbuf_detach(&d, NULL);\n+\tstatic const char *prefix;\n+\n+\tif (is_absolute_path(path)) {\n+\t\treturn path;\n+\t}\n+\n+#ifdef RUNTIME_PREFIX\n+\tassert(argv0_path);\n+\tassert(is_absolute_path(argv0_path));\n+\n+\tif (!prefix) {\n+\t\tconst char *strip[] = {\n+\t\t\tGIT_EXEC_PATH,\n+\t\t\tBINDIR,\n+\t\t\t0\n+\t\t};\n+\t\tconst char **s;\n+\n+\t\tfor (s = strip; *s; s++) {\n+\t\t\tconst char *sargv = argv0_path + strlen(argv0_path);\n+\t\t\tconst char *ss = *s + strlen(*s);\n+\t\t\twhile (argv0_path < sargv && *s < ss\n+\t\t\t\t&& (*sargv == *ss ||\n+\t\t\t\t    (is_dir_sep(*sargv) && is_dir_sep(*ss)))) {\n+\t\t\t\tsargv--;\n+\t\t\t\tss--;\n+\t\t\t}\n+\t\t\tif (*s == ss) {\n+\t\t\t\tstruct strbuf d = STRBUF_INIT;\n+\t\t\t\t/* We also skip the trailing directory separator. */\n+\t\t\t\tassert(sargv - argv0_path - 1 >= 0);\n+\t\t\t\tstrbuf_add(&d, argv0_path, sargv - argv0_path - 1);\n+\t\t\t\tprefix = strbuf_detach(&d, NULL);\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n \t}\n+\n+\tif (!prefix) {\n+\t\tprefix = PREFIX;\n+\t\tfprintf(stderr, \"RUNTIME_PREFIX requested, \"\n+\t\t\t\t\"but prefix computation failed.  \"\n+\t\t\t\t\"Using static fallback '%s'.\\n\", prefix);\n+\t}\n+#else\n+\tprefix = PREFIX;\n+#endif\n+\n+\tstruct strbuf d = STRBUF_INIT;\n+\tstrbuf_addf(&d, \"%s/%s\", prefix, path);\n+\tpath = strbuf_detach(&d, NULL);\n \treturn path;\n }\n \n-- \n1.6.1.85.g32c5d\n"},{"id":"99884","messageId":"1231595452-27698-2-git-send-email-prohaska@zib.de","threadId":"17078","inReplyTo":"1231595452-27698-1-git-send-email-prohaska@zib.de","subject":"[PATCH 2/6] Refactor git_set_argv0_path() to git_extract_argv0_path()","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-10T13:50:48Z","receivedAt":"2009-01-10T13:50:48Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"From: Steve Haslam <shaslam@lastminute.com>\n\nThis commit moves the code that computes the dirname of argv[0]\nfrom git.c's main() to git_set_argv0_path() and renames the function\nto git_extract_argv0_path().  This makes the code in git.c's main\nless cluttered, and we can use the dirname computation from other\nmain() functions too.\n\n[ spr:\n - split Steve's original commit and wrote new commit message.\n - Integrated Johannes Schindelin's\n   cca1704897e7fdb182f68d4c48a437c5d7bc5203 while rebasing onto master.\n]\n\nSigned-off-by: Steve Haslam <shaslam@lastminute.com>\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n exec_cmd.c |   14 ++++++++++++--\n exec_cmd.h |    2 +-\n git.c      |   19 +++++--------------\n 3 files changed, 18 insertions(+), 17 deletions(-)\n\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex 669b82e..576c9ae 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -63,9 +63,19 @@ const char *system_path(const char *path)\n \treturn path;\n }\n \n-void git_set_argv0_path(const char *path)\n+const char *git_extract_argv0_path(const char *argv0)\n {\n-\targv0_path = path;\n+\tconst char *slash = argv0 + strlen(argv0);\n+\n+\twhile (argv0 <= slash && !is_dir_sep(*slash))\n+\t\tslash--;\n+\n+\tif (slash >= argv0) {\n+\t\targv0_path = xstrndup(argv0, slash - argv0);\n+\t\treturn slash + 1;\n+\t}\n+\n+\treturn argv0;\n }\n \n void git_set_argv_exec_path(const char *exec_path)\ndiff --git a/exec_cmd.h b/exec_cmd.h\nindex 594f961..392e903 100644\n--- a/exec_cmd.h\n+++ b/exec_cmd.h\n@@ -2,7 +2,7 @@\n #define GIT_EXEC_CMD_H\n \n extern void git_set_argv_exec_path(const char *exec_path);\n-extern void git_set_argv0_path(const char *path);\n+extern const char* git_extract_argv0_path(const char *path);\n extern const char* git_exec_path(void);\n extern void setup_path(void);\n extern const char **prepare_git_cmd(const char **argv);\ndiff --git a/git.c b/git.c\nindex a53e24f..b99b1b2 100644\n--- a/git.c\n+++ b/git.c\n@@ -419,22 +419,13 @@ static void execv_dashed_external(const char **argv)\n \n int main(int argc, const char **argv)\n {\n-\tconst char *cmd = argv[0] && *argv[0] ? argv[0] : \"git-help\";\n-\tchar *slash = (char *)cmd + strlen(cmd);\n+\tconst char *cmd;\n \tint done_alias = 0;\n \n-\t/*\n-\t * Take the basename of argv[0] as the command\n-\t * name, and the dirname as the default exec_path\n-\t * if we don't have anything better.\n-\t */\n-\twhile (cmd <= slash && !is_dir_sep(*slash))\n-\t\tslash--;\n-\tif (cmd <= slash) {\n-\t\t*slash++ = 0;\n-\t\tgit_set_argv0_path(cmd);\n-\t\tcmd = slash;\n-\t}\n+\tif (argv[0] && *argv[0])\n+\t\tcmd = git_extract_argv0_path(argv[0]);\n+\telse\n+\t\tcmd = \"git-help\";\n \n \t/*\n \t * \"git-xxxx\" is the same as \"git xxxx\", but we obviously:\n-- \n1.6.1.85.g32c5d\n"},{"id":"99887","messageId":"1231595452-27698-3-git-send-email-prohaska@zib.de","threadId":"17078","inReplyTo":"1231595452-27698-2-git-send-email-prohaska@zib.de","subject":"[PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-10T13:50:49Z","receivedAt":"2009-01-10T13:50:49Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"From: Steve Haslam <shaslam@lastminute.com>\n\nIf the user specified the full path to git-upload-pack as the -u option to\n\"git clone\" when cloning a remote repository, and git was not on the default\nPATH on the remote machine, git-upload-pack was failing to exec\ngit-pack-objects.\n\nBy making the argv[0] path (if any) available to setup_path(), this will\nallow finding the \"git\" executable in the same directory as\n\"git-upload-pack\". The default built in to exec_cmd.c is to look for \"git\"\nin the \".../libexec/git-core\" directory, but it is not installed there (any\nlonger).\n\nMuch the same applies to invoking git-receive-pack from a non-PATH location\nusing the \"--exec\" argument to \"git push\".\n\n[ spr: split Steve's original commit into two commits. ]\n\nSigned-off-by: Steve Haslam <shaslam@lastminute.com>\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n builtin-receive-pack.c |    3 +++\n upload-pack.c          |    3 +++\n 2 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-receive-pack.c b/builtin-receive-pack.c\nindex db67c31..bbedcfe 100644\n--- a/builtin-receive-pack.c\n+++ b/builtin-receive-pack.c\n@@ -579,6 +579,9 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)\n \tint i;\n \tchar *dir = NULL;\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \targv++;\n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = *argv++;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex e5adbc0..c469a60 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -616,6 +616,9 @@ int main(int argc, char **argv)\n \tint i;\n \tint strict = 0;\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tfor (i = 1; i < argc; i++) {\n \t\tchar *arg = argv[i];\n \n-- \n1.6.1.85.g32c5d\n"},{"id":"99885","messageId":"1231595452-27698-4-git-send-email-prohaska@zib.de","threadId":"17078","inReplyTo":"1231595452-27698-3-git-send-email-prohaska@zib.de","subject":"[PATCH 4/6] Add calls to git_extract_argv0_path() in programs that call git_config_*","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-10T13:50:50Z","receivedAt":"2009-01-10T13:50:50Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"Programs that use git_config need to find the global configuration.\nWhen runtime prefix computation is enabled, this requires that\ngit_extract_argv0_path() is called early in the program's main().\n\nThis commit adds the necessary calls.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n daemon.c             |    3 +++\n fast-import.c        |    4 ++++\n hash-object.c        |    4 ++++\n http-push.c          |    3 +++\n imap-send.c          |    4 ++++\n index-pack.c         |    4 ++++\n merge-index.c        |    4 ++++\n merge-tree.c         |    4 ++++\n mktag.c              |    4 ++++\n mktree.c             |    4 ++++\n pack-redundant.c     |    4 ++++\n patch-id.c           |    4 ++++\n unpack-file.c        |    4 ++++\n update-server-info.c |    4 ++++\n var.c                |    4 ++++\n 15 files changed, 58 insertions(+), 0 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex 540700e..1c5e604 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -937,6 +937,9 @@ int main(int argc, char **argv)\n \tgid_t gid = 0;\n \tint i;\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tfor (i = 1; i < argc; i++) {\n \t\tchar *arg = argv[i];\n \ndiff --git a/fast-import.c b/fast-import.c\nindex a6bce66..7762205 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -150,6 +150,7 @@ Format of STDIN stream:\n #include \"refs.h\"\n #include \"csum-file.h\"\n #include \"quote.h\"\n+#include \"exec_cmd.h\"\n \n #define PACK_ID_BITS 16\n #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)\n@@ -2405,6 +2406,9 @@ int main(int argc, const char **argv)\n {\n \tunsigned int i, show_stats = 1;\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tsetup_git_directory();\n \tgit_config(git_pack_config, NULL);\n \tif (!pack_compression_seen && core_compression_seen)\ndiff --git a/hash-object.c b/hash-object.c\nindex 846e91a..a689cc6 100644\n--- a/hash-object.c\n+++ b/hash-object.c\n@@ -8,6 +8,7 @@\n #include \"blob.h\"\n #include \"quote.h\"\n #include \"parse-options.h\"\n+#include \"exec_cmd.h\"\n \n static void hash_fd(int fd, const char *type, int write_object, const char *path)\n {\n@@ -81,6 +82,9 @@ int main(int argc, const char **argv)\n \n \ttype = blob_type;\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tgit_config(git_default_config, NULL);\n \n \targc = parse_options(argc, argv, hash_object_options, hash_object_usage, 0);\ndiff --git a/http-push.c b/http-push.c\nindex a4b7d08..dd2b2b1 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -2179,6 +2179,9 @@ int main(int argc, char **argv)\n \tstruct ref *ref;\n \tchar *rewritten_url = NULL;\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tsetup_git_directory();\n \n \tremote = xcalloc(sizeof(*remote), 1);\ndiff --git a/imap-send.c b/imap-send.c\nindex c3fa0df..6e92aee 100644\n--- a/imap-send.c\n+++ b/imap-send.c\n@@ -23,6 +23,7 @@\n  */\n \n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n #ifdef NO_OPENSSL\n typedef void *SSL;\n #endif\n@@ -1389,6 +1390,9 @@ int main(int argc, char **argv)\n \tint total, n = 0;\n \tint nongit_ok;\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \t/* init the random number generator */\n \tarc4_init();\n \ndiff --git a/index-pack.c b/index-pack.c\nindex 2931511..0df297b 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -8,6 +8,7 @@\n #include \"tree.h\"\n #include \"progress.h\"\n #include \"fsck.h\"\n+#include \"exec_cmd.h\"\n \n static const char index_pack_usage[] =\n \"git index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }\";\n@@ -880,6 +881,9 @@ int main(int argc, char **argv)\n \tstruct pack_idx_entry **idx_objects;\n \tunsigned char pack_sha1[20];\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \t/*\n \t * We wish to read the repository's config file if any, and\n \t * for that it is necessary to call setup_git_directory_gently().\ndiff --git a/merge-index.c b/merge-index.c\nindex 7827e87..5d89ead 100644\n--- a/merge-index.c\n+++ b/merge-index.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"run-command.h\"\n+#include \"exec_cmd.h\"\n \n static const char *pgm;\n static const char *arguments[9];\n@@ -93,6 +94,9 @@ int main(int argc, char **argv)\n \tif (argc < 3)\n \t\tusage(\"git-merge-index [-o] [-q] <merge-program> (-a | [--] <filename>*)\");\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tsetup_git_directory();\n \tread_cache();\n \ndiff --git a/merge-tree.c b/merge-tree.c\nindex 2d1413e..165ccfc 100644\n--- a/merge-tree.c\n+++ b/merge-tree.c\n@@ -2,6 +2,7 @@\n #include \"tree-walk.h\"\n #include \"xdiff-interface.h\"\n #include \"blob.h\"\n+#include \"exec_cmd.h\"\n \n static const char merge_tree_usage[] = \"git-merge-tree <base-tree> <branch1> <branch2>\";\n static int resolve_directories = 1;\n@@ -344,6 +345,9 @@ int main(int argc, char **argv)\n \tif (argc != 4)\n \t\tusage(merge_tree_usage);\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tsetup_git_directory();\n \n \tbuf1 = get_tree_descriptor(t+0, argv[1]);\ndiff --git a/mktag.c b/mktag.c\nindex ba3d495..ff32f8a 100644\n--- a/mktag.c\n+++ b/mktag.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"tag.h\"\n+#include \"exec_cmd.h\"\n \n /*\n  * A signature file has a very simple fixed format: four lines\n@@ -159,6 +160,9 @@ int main(int argc, char **argv)\n \tif (argc != 1)\n \t\tusage(\"git-mktag < signaturefile\");\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tsetup_git_directory();\n \n \tif (strbuf_read(&buf, 0, 4096) < 0) {\ndiff --git a/mktree.c b/mktree.c\nindex 514fd9b..8ac0d57 100644\n--- a/mktree.c\n+++ b/mktree.c\n@@ -6,6 +6,7 @@\n #include \"cache.h\"\n #include \"quote.h\"\n #include \"tree.h\"\n+#include \"exec_cmd.h\"\n \n static struct treeent {\n \tunsigned mode;\n@@ -70,6 +71,9 @@ int main(int ac, char **av)\n \tunsigned char sha1[20];\n \tint line_termination = '\\n';\n \n+\tif (av[0] && *av[0])\n+\t\tgit_extract_argv0_path(av[0]);\n+\n \tsetup_git_directory();\n \n \twhile ((1 < ac) && av[1][0] == '-') {\ndiff --git a/pack-redundant.c b/pack-redundant.c\nindex e93eb96..8ff119b 100644\n--- a/pack-redundant.c\n+++ b/pack-redundant.c\n@@ -7,6 +7,7 @@\n */\n \n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n \n #define BLKSIZE 512\n \n@@ -601,6 +602,9 @@ int main(int argc, char **argv)\n \tunsigned char *sha1;\n \tchar buf[42]; /* 40 byte sha1 + \\n + \\0 */\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tsetup_git_directory();\n \n \tfor (i = 1; i < argc; i++) {\ndiff --git a/patch-id.c b/patch-id.c\nindex 871f1d2..ff460e2 100644\n--- a/patch-id.c\n+++ b/patch-id.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n \n static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)\n {\n@@ -79,6 +80,9 @@ int main(int argc, char **argv)\n \tif (argc != 1)\n \t\tusage(patch_id_usage);\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tgenerate_id_list();\n \treturn 0;\n }\ndiff --git a/unpack-file.c b/unpack-file.c\nindex bcdc8bb..f8bfda7 100644\n--- a/unpack-file.c\n+++ b/unpack-file.c\n@@ -1,5 +1,6 @@\n #include \"cache.h\"\n #include \"blob.h\"\n+#include \"exec_cmd.h\"\n \n static char *create_temp_file(unsigned char *sha1)\n {\n@@ -25,6 +26,9 @@ int main(int argc, char **argv)\n {\n \tunsigned char sha1[20];\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tif (argc != 2)\n \t\tusage(\"git-unpack-file <sha1>\");\n \tif (get_sha1(argv[1], sha1))\ndiff --git a/update-server-info.c b/update-server-info.c\nindex 7e8209e..286a4dd 100644\n--- a/update-server-info.c\n+++ b/update-server-info.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n \n static const char update_server_info_usage[] =\n \"git update-server-info [--force]\";\n@@ -19,6 +20,9 @@ int main(int ac, char **av)\n \tif (i != ac)\n \t\tusage(update_server_info_usage);\n \n+\tif (av[0] && *av[0])\n+\t\tgit_extract_argv0_path(av[0]);\n+\n \tsetup_git_directory();\n \n \treturn !!update_server_info(force);\ndiff --git a/var.c b/var.c\nindex f1eb314..33457dc 100644\n--- a/var.c\n+++ b/var.c\n@@ -4,6 +4,7 @@\n  * Copyright (C) Eric Biederman, 2005\n  */\n #include \"cache.h\"\n+#include \"exec_cmd.h\"\n \n static const char var_usage[] = \"git var [-l | <variable>]\";\n \n@@ -56,6 +57,9 @@ int main(int argc, char **argv)\n \t\tusage(var_usage);\n \t}\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tsetup_git_directory_gently(&nongit);\n \tval = NULL;\n \n-- \n1.6.1.85.g32c5d\n"},{"id":"99886","messageId":"1231595452-27698-5-git-send-email-prohaska@zib.de","threadId":"17078","inReplyTo":"1231595452-27698-4-git-send-email-prohaska@zib.de","subject":"[PATCH 5/6] Modify setup_path() to only add git_exec_path() to PATH","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-10T13:50:51Z","receivedAt":"2009-01-10T13:50:51Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"Searching git programs only in the highest priority location is\nsufficient.  It does not make sense that some of the required\nprograms are located at the highest priority location but other\nprograms are picked up from a lower priority exec-path.  If\nexec-path is overridden a complete set of commands should be\nprovided, otherwise several different versions could get mixed,\nwhich is likely to cause confusion.\n\nIf a user explicitly overrides the default location (by --exec-path\nor GIT_EXEC_PATH), we now expect that all the required programs are\nfound there.  Instead of adding the directories \"argv_exec_path\",\n\"getenv(EXEC_PATH_ENVIRONMENT)\", and \"system_path(GIT_EXEC_PATH)\"\nto PATH, we now rely on git_exec_path(), which implements the same\norder, but only returns the highest priority location to search for\nexecutables.\n\nAccessing only the location with highest priority is also required\nfor testing executables built with RUNTIME_PREFIX.  The call to\nsystem_path() should be avoided if RUNTIME_PREFIX is set and the\nexecutable is not installed at its final destination.  Because we\ntest before installing, we want to avoid calling system_path()\nduring tests.  The modifications in this commit avoid calling\nsystem_path(GIT_EXEC_PATH) if a higher-priority location is\nprovided, which is the case when running the tests.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n exec_cmd.c |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex 576c9ae..ec38b0a 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -117,9 +117,7 @@ void setup_path(void)\n \tconst char *old_path = getenv(\"PATH\");\n \tstruct strbuf new_path = STRBUF_INIT;\n \n-\tadd_path(&new_path, argv_exec_path);\n-\tadd_path(&new_path, getenv(EXEC_PATH_ENVIRONMENT));\n-\tadd_path(&new_path, system_path(GIT_EXEC_PATH));\n+\tadd_path(&new_path, git_exec_path());\n \tadd_path(&new_path, argv0_path);\n \n \tif (old_path)\n-- \n1.6.1.85.g32c5d\n"},{"id":"99889","messageId":"1231595452-27698-6-git-send-email-prohaska@zib.de","threadId":"17078","inReplyTo":"1231595452-27698-5-git-send-email-prohaska@zib.de","subject":"[PATCH 6/6] Windows: Revert to default paths and convert them by RUNTIME_PREFIX","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-10T13:50:52Z","receivedAt":"2009-01-10T13:50:52Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"The RUNTIME_PREFIX mechanism allows us to use the default paths on\nWindows too.  Defining RUNTIME_PREFIX explicitly requests for\ntranslation of paths relative to the executable at runtime.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n Makefile |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex a7728a3..a5f6cad 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -789,6 +789,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tSNPRINTF_RETURNS_BOGUS = YesPlease\n \tNO_SVN_TESTS = YesPlease\n \tNO_PERL_MAKEMAKER = YesPlease\n+\tRUNTIME_PREFIX = YesPlease\n \tNO_POSIX_ONLY_PROGRAMS = YesPlease\n \tNO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease\n \tCOMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/regex -Icompat/fnmatch\n@@ -797,9 +798,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tCOMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/regex/regex.o compat/winansi.o\n \tEXTLIBS += -lws2_32\n \tX = .exe\n-\tgitexecdir = ../libexec/git-core\n-\ttemplate_dir = ../share/git-core/templates/\n-\tETC_GITCONFIG = ../etc/gitconfig\n endif\n ifneq (,$(findstring arm,$(uname_M)))\n \tARM_SHA1 = YesPlease\n-- \n1.6.1.85.g32c5d\n"},{"id":"99894","messageId":"alpine.DEB.1.00.0901101532430.30769@pacific.mpi-cbg.de","threadId":"17078","inReplyTo":"1231595452-27698-3-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-10T14:34:50Z","receivedAt":"2009-01-10T14:34:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 10 Jan 2009, Steffen Prohaska wrote:\n\n> From: Steve Haslam <shaslam@lastminute.com>\n> \n> If the user specified the full path to git-upload-pack as the -u option to\n> \"git clone\" when cloning a remote repository, and git was not on the default\n> PATH on the remote machine, git-upload-pack was failing to exec\n> git-pack-objects.\n> \n> By making the argv[0] path (if any) available to setup_path(), this will\n> allow finding the \"git\" executable in the same directory as\n> \"git-upload-pack\". The default built in to exec_cmd.c is to look for \"git\"\n> in the \".../libexec/git-core\" directory, but it is not installed there (any\n> longer).\n> \n> Much the same applies to invoking git-receive-pack from a non-PATH location\n> using the \"--exec\" argument to \"git push\".\n> \n> [ spr: split Steve's original commit into two commits. ]\n\nI think you do not want to have that [ ... ] in the commit message, but \nafter the \"--\".\n\nFurther, it would make sense to have these 2 patches independently, \nprovided that a test is added with which we could verify that the patches \nare actually necessary for upload-pack/receive-pack.\n\nLogically, and to avoid committing a broken revision, 1/6 should come \nlast, methinks.\n\nCiao,\nDscho\n"},{"id":"99901","messageId":"81783342-81AA-415A-8EF3-1CD9F5390483@zib.de","threadId":"17078","inReplyTo":"alpine.DEB.1.00.0901101532430.30769@pacific.mpi-cbg.de","subject":"Re: [PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-10T15:55:32Z","receivedAt":"2009-01-10T15:55:32Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jan 10, 2009, at 3:34 PM, Johannes Schindelin wrote:\n\n> On Sat, 10 Jan 2009, Steffen Prohaska wrote:\n>\n>> From: Steve Haslam <shaslam@lastminute.com>\n>>\n>> If the user specified the full path to git-upload-pack as the -u  \n>> option to\n>> \"git clone\" when cloning a remote repository, and git was not on  \n>> the default\n>> PATH on the remote machine, git-upload-pack was failing to exec\n>> git-pack-objects.\n>>\n>> By making the argv[0] path (if any) available to setup_path(), this  \n>> will\n>> allow finding the \"git\" executable in the same directory as\n>> \"git-upload-pack\". The default built in to exec_cmd.c is to look  \n>> for \"git\"\n>> in the \".../libexec/git-core\" directory, but it is not installed  \n>> there (any\n>> longer).\n>>\n>> Much the same applies to invoking git-receive-pack from a non-PATH  \n>> location\n>> using the \"--exec\" argument to \"git push\".\n>>\n>> [ spr: split Steve's original commit into two commits. ]\n>\n> I think you do not want to have that [ ... ] in the commit message,  \n> but\n> after the \"--\".\n>\n> Further, it would make sense to have these 2 patches independently,\n> provided that a test is added with which we could verify that the  \n> patches\n> are actually necessary for upload-pack/receive-pack.\n\n\nSteve,\ncould you comment on this.  You are the original author of the patch.\n\n\tSteffen \n"},{"id":"99903","messageId":"9CECD102-6D3E-487D-BA1E-C0269D055965@zib.de","threadId":"17078","inReplyTo":"alpine.DEB.1.00.0901101532430.30769@pacific.mpi-cbg.de","subject":"Re: [PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-10T16:01:11Z","receivedAt":"2009-01-10T16:01:11Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jan 10, 2009, at 3:34 PM, Johannes Schindelin wrote:\n\n> Logically, and to avoid committing a broken revision, 1/6 should come\n> last, methinks.\n\nRUNTIME_PREFIX is not defined before 6/6. But I agree,\n1/6 should probably be moved after 5/6.\n\n\tSteffen\n"},{"id":"99922","messageId":"7viqomx5iq.fsf@gitster.siamese.dyndns.org","threadId":"17078","inReplyTo":"9CECD102-6D3E-487D-BA1E-C0269D055965@zib.de","subject":"Re: [PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-10T20:36:29Z","receivedAt":"2009-01-10T20:36:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steffen Prohaska <prohaska@zib.de> writes:\n\n> On Jan 10, 2009, at 3:34 PM, Johannes Schindelin wrote:\n>\n>> Logically, and to avoid committing a broken revision, 1/6 should come\n>> last, methinks.\n>\n> RUNTIME_PREFIX is not defined before 6/6. But I agree,\n> 1/6 should probably be moved after 5/6.\n>\n> \tSteffen\n\nHmm, I actually was thinking about applying that (and that one only) early\nto my tree, to make sure it is regression-free.\n"},{"id":"99937","messageId":"E976B246-AD14-4B03-B204-F6A1014071DF@zib.de","threadId":"17078","inReplyTo":"7viqomx5iq.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-11T10:04:23Z","receivedAt":"2009-01-11T10:04:23Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jan 10, 2009, at 9:36 PM, Junio C Hamano wrote:\n\n> Steffen Prohaska <prohaska@zib.de> writes:\n>\n>> On Jan 10, 2009, at 3:34 PM, Johannes Schindelin wrote:\n>>\n>>> Logically, and to avoid committing a broken revision, 1/6 should  \n>>> come\n>>> last, methinks.\n>>\n>> RUNTIME_PREFIX is not defined before 6/6. But I agree,\n>> 1/6 should probably be moved after 5/6.\n>>\n> Hmm, I actually was thinking about applying that (and that one only)  \n> early\n> to my tree, to make sure it is regression-free.\n\nDoes \"early\" mean that you want to wait and see how the discussion\nabout the other patches evolves before you consider applying them,\nor does \"and that one only\" mean that you tend to not apply the\nother patches at all?\n\n\tSteffen\n"},{"id":"99938","messageId":"7v1vvata6o.fsf@gitster.siamese.dyndns.org","threadId":"17078","inReplyTo":"E976B246-AD14-4B03-B204-F6A1014071DF@zib.de","subject":"Re: [PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-11T10:21:35Z","receivedAt":"2009-01-11T10:21:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Steffen Prohaska <prohaska@zib.de> writes:\n\n>> Hmm, I actually was thinking about applying that (and that one only)\n>> early\n>> to my tree, to make sure it is regression-free.\n>\n> Does \"early\" mean that you want to wait and see how the discussion\n> about the other patches evolves before you consider applying them,\n> or does \"and that one only\" mean that you tend to not apply the\n> other patches at all?\n\nMy initial impression after reading 1/6 was that no matter how the actual\nruntime prefix detection logic that is implemented in the later parts of\nthe series for particular platform will turn out to be, the update to the\nMakefile that is done by 1/6 won't have to change.  If I apply 1/6 first\nwithout applying anything else, we can make sure that it would not regress\nfor Unix people (and catch regressions early if any), while Windows people\npolish the platform specific parts of the implementation in the later\nparts of the series that can be replaced.\n\nBecause changes to Makefile variables tend to have unexpected side effects\n(people have their own definition to override them in their build\nprocedures and you can easily break them unless you are careful), I wanted\nto make sure the common part is solid before waiting for the other part.\n\nBut if you think it is better not to apply any one, until other parts\nmature, it is Ok by me, too.\n"},{"id":"99953","messageId":"C817EA53-5326-4C60-B781-41B90514F3A7@zib.de","threadId":"17078","inReplyTo":"7v1vvata6o.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2009-01-11T12:57:59Z","receivedAt":"2009-01-11T12:57:59Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Jan 11, 2009, at 11:21 AM, Junio C Hamano wrote:\n\n> My initial impression after reading 1/6 was that no matter how the  \n> actual\n> runtime prefix detection logic that is implemented in the later  \n> parts of\n> the series for particular platform will turn out to be, the update  \n> to the\n> Makefile that is done by 1/6 won't have to change.  If I apply 1/6  \n> first\n> without applying anything else, we can make sure that it would not  \n> regress\n> for Unix people (and catch regressions early if any), while Windows  \n> people\n> polish the platform specific parts of the implementation in the later\n> parts of the series that can be replaced.\n>\n> Because changes to Makefile variables tend to have unexpected side  \n> effects\n> (people have their own definition to override them in their build\n> procedures and you can easily break them unless you are careful), I  \n> wanted\n> to make sure the common part is solid before waiting for the other  \n> part.\n>\n> But if you think it is better not to apply any one, until other parts\n> mature, it is Ok by me, too.\n\nI think you should apply it.\n\n\tSteffen\n"},{"id":"100299","messageId":"200901132036.05261.j6t@kdbg.org","threadId":"17078","inReplyTo":"1231595452-27698-3-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 3/6] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-01-13T19:36:05Z","receivedAt":"2009-01-13T19:36:05Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Samstag, 10. Januar 2009, Steffen Prohaska wrote:\n> diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c\n> index db67c31..bbedcfe 100644\n> --- a/builtin-receive-pack.c\n> +++ b/builtin-receive-pack.c\n> @@ -579,6 +579,9 @@ int cmd_receive_pack(int argc, const char **argv, const\n> char *prefix) int i;\n>  \tchar *dir = NULL;\n>\n> +\tif (argv[0] && *argv[0])\n> +\t\tgit_extract_argv0_path(argv[0]);\n> +\n\nThis is not necessary because receive-pack is meanwhile a builtin.\n\n> diff --git a/upload-pack.c b/upload-pack.c\n> index e5adbc0..c469a60 100644\n> --- a/upload-pack.c\n> +++ b/upload-pack.c\n> @@ -616,6 +616,9 @@ int main(int argc, char **argv)\n>  \tint i;\n>  \tint strict = 0;\n>\n> +\tif (argv[0] && *argv[0])\n> +\t\tgit_extract_argv0_path(argv[0]);\n> +\n>  \tfor (i = 1; i < argc; i++) {\n>  \t\tchar *arg = argv[i];\n\nThis hunk should be merged into 4/6.\n\n-- Hannes\n"},{"id":"100300","messageId":"200901132037.35096.j6t@kdbg.org","threadId":"17078","inReplyTo":"1231595452-27698-2-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 2/6] Refactor git_set_argv0_path() to git_extract_argv0_path()","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-01-13T19:37:35Z","receivedAt":"2009-01-13T19:37:35Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Samstag, 10. Januar 2009, Steffen Prohaska wrote:\n> @@ -63,9 +63,19 @@ const char *system_path(const char *path)\n>  \treturn path;\n>  }\n>\n> -void git_set_argv0_path(const char *path)\n> +const char *git_extract_argv0_path(const char *argv0)\n>  {\n> -\targv0_path = path;\n\nPlease insert the 'if (argv0 && *argv0)' here to simplify the call sites.\nOr you could introduce this check later in 4/6 because the call site in\nthis patch (main() of git.c) is simpler if it keeps the check.\n\n> +\tconst char *slash = argv0 + strlen(argv0);\n> +\n> +\twhile (argv0 <= slash && !is_dir_sep(*slash))\n> +\t\tslash--;\n> +\n> +\tif (slash >= argv0) {\n> +\t\targv0_path = xstrndup(argv0, slash - argv0);\n> +\t\treturn slash + 1;\n> +\t}\n> +\n> +\treturn argv0;\n>  }\n\n-- Hannes\n"},{"id":"100301","messageId":"200901132043.16789.j6t@kdbg.org","threadId":"17078","inReplyTo":"1231595452-27698-1-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 1/6] Move computation of absolute paths from Makefile to runtime and compute prefix on the fly if RUNTIME_PREFIX set","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2009-01-13T19:43:16Z","receivedAt":"2009-01-13T19:43:16Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Samstag, 10. Januar 2009, Steffen Prohaska wrote:\n> This is the first commit of a series that adds support for\n> relocatable binaries (called RUNTIME_PREFIX).  Such binaries can be\n> moved together with the system configuration files to a different\n> directory, as long as the relative paths from the binary to the\n> configuration files is preserved.  This functionality is essential\n> on Windows where we deliver git binaries with an installer that\n> allows to freely choose the installation location.  The commit\n> series implements RUNTIME_PREFIX only on Windows.  Adding support\n> on Unix should not be too hard, though.\n\nThis series looks sane, and my comments on 2/6 and 3/6 certainly do not \nindicate any showstoppers. I've just started using it; so far there are no \nproblems.\n\n-- Hannes\n"}]}