{"thread":{"id":"15612","subject":"[PATCH 1/7] Windows: Add workaround for MSYS' path conversion","startedAt":"2008-09-21T16:24:31Z","lastAt":"2008-09-22T05:57:04Z","messageCount":11,"participants":["Steffen Prohaska","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"91239","messageId":"1222014278-11071-1-git-send-email-prohaska@zib.de","threadId":"15612","inReplyTo":null,"subject":"[PATCH 0/7 v2] prefix discovery at runtime (on Windows)","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-21T16:24:31Z","receivedAt":"2008-09-21T16:24:31Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"This is the second version of the patch series that fixes discovery of\nthe installation prefix at runtime on Windows.  It introduces a compile\nflag RUNTIME_PREFIX, which can be set to explicitly request prefix\ncomputation at runtime.\n\nYou can find the first version at\n\n  http://article.gmane.org/gmane.comp.version-control.git/92605\n\nI mainly improved some of the commit messages and rebased to the\ncurrent master.\n\nPATCH 6/7 might need further discussion.  Hannes noted that PATCH 6/7\ntouches a sensible part of exec_cmd.c, although he thinks that the\nproposed change might be good.  See\nhttp://article.gmane.org/gmane.comp.version-control.git/92626 for his\ncomment.  I did not modify PATCH 6/7.\n\n        Steffen\n\n [PATCH 1/7] Windows: Add workaround for MSYS' path conversion\n [PATCH 2/7] system_path(): Add prefix computation at runtime if RUNTIME_PREFIX set\n [PATCH 3/7] Refactor git_set_argv0_path() to git_extract_argv0_path()\n [PATCH 4/7] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.\n [PATCH 5/7] Add calls to git_extract_argv0_path() in programs that call git_config_*\n [PATCH 6/7] Modify setup_path() to only add git_exec_path() to PATH\n [PATCH 7/7] Windows: Revert to default paths and convert them by RUNTIME_PREFIX\n"},{"id":"91232","messageId":"1222014278-11071-2-git-send-email-prohaska@zib.de","threadId":"15612","inReplyTo":"1222014278-11071-1-git-send-email-prohaska@zib.de","subject":"[PATCH 1/7] Windows: Add workaround for MSYS' path conversion","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-21T16:24:32Z","receivedAt":"2008-09-21T16:24:32Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"MSYS' automatic path conversion causes problems when passing paths as\ndefines ('-D' arguments to the compiler).  MSYS tries to be smart and\nconverts absolute paths to native Windows paths, e.g. if MSYS sees\n\"/bin\" it converts it to \"c:/msysgit/bin\".  But we want completely\nunmodified paths; e.g. if we set bindir in the Makefile to \"/bin\", the\ndefine BINDIR shall expand to \"/bin\".  Conversion to absolute Windows\npath will takes place later, during runtime.\n\nThis commit adds a workaround by replacing \"/\" with its octal\nrepresentation \"\\057\", effectively hiding the path from MSYS' path\nconversion mechanism.  MSYS does no longer see the absolute path and\ntherefore leaves it alone.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n Makefile |   14 ++++++++++----\n 1 files changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 3c0664a..140a2b2 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1066,6 +1066,12 @@ template_dir_SQ = $(subst ','\\'',$(template_dir))\n htmldir_SQ = $(subst ','\\'',$(htmldir))\n prefix_SQ = $(subst ','\\'',$(prefix))\n \n+ETC_GITCONFIG_SQ_C = $(subst /,\\057,$(ETC_GITCONFIG_SQ))\n+bindir_SQ_C = $(subst /,\\057,$(bindir_SQ))\n+gitexecdir_SQ_C = $(subst /,\\057,$(gitexecdir_SQ))\n+htmldir_SQ_C = $(subst /,\\057,$(htmldir_SQ))\n+template_dir_SQ_C = $(subst /,\\057,$(template_dir_SQ))\n+\n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n TCLTK_PATH_SQ = $(subst ','\\'',$(TCLTK_PATH))\n@@ -1117,7 +1123,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n \n builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \\\n-\t\t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n+\t\t'-DGIT_HTML_PATH=\"$(htmldir_SQ_C)\"' \\\n \t\t'-DGIT_MAN_PATH=\"$(mandir_SQ)\"' \\\n \t\t'-DGIT_INFO_PATH=\"$(infodir_SQ)\"' $<\n \n@@ -1224,12 +1230,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) '-DGIT_EXEC_PATH=\"$(gitexecdir_SQ_C)\"' -DBINDIR='\"$(bindir_SQ_C)\"' $<\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+\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ_C)\"' $<\n \n config.o: config.c GIT-CFLAGS\n-\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"' $<\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ_C)\"' $<\n \n http.o: http.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='\"git/$(GIT_VERSION)\"' $<\n-- \n1.6.0.2.GIT\n"},{"id":"91236","messageId":"1222014278-11071-3-git-send-email-prohaska@zib.de","threadId":"15612","inReplyTo":"1222014278-11071-2-git-send-email-prohaska@zib.de","subject":"[PATCH 2/7] system_path(): Add prefix computation at runtime if RUNTIME_PREFIX set","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-21T16:24:33Z","receivedAt":"2008-09-21T16:24:33Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"This commit modifies system_path() to compute the prefix at runtime if\nconfigured to do so.  If RUNTIME_PREFIX is defined, system_path() tries\nto strip known directories that executables can be located in from the\npath of the executable.  If the path is successfully stripped it is used\nas the prefix.  For example, if the executable is \"/msysgit/bin/git\" and\nBINDIR is \"/bin\", then the prefix is computed as \"/msysgit\".\n\nWe report an error if the runtime prefix computation fails, which can\nhappen if the executable is not installed at a known location.  The user\nshould know that the global configuration is not picked up, because this\ncan cause unexpected behavior.  If we explicitly want to ignore system\nwide paths, we can set the environment variable GIT_CONFIG_NOSYSTEM, as\nour tests do.\n\nThe implementation requires that argv0_path is set up properly, which is\ncurrently the case only on Windows.  argv0_path must point to the\nabsolute path of the directory of the executable, which is verified by\ntwo calls to assert().  On Windows, the wrapper for main() (see\ncompat/mingw.h) guarantees that this is the case.  On Unix, further work\nis required before RUNTIME_PREFIX can be enabled.\n\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n Makefile   |    3 +++\n exec_cmd.c |   45 +++++++++++++++++++++++++++++++++++++++++----\n 2 files changed, 44 insertions(+), 4 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 140a2b2..8181f74 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1006,6 +1006,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 THREADED_DELTA_SEARCH\n \tBASIC_CFLAGS += -DTHREADED_DELTA_SEARCH\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex ce6741e..9fa89b8 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -9,11 +9,48 @@ 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+#ifdef RUNTIME_PREFIX\n+\tstatic const char *prefix;\n+\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\tstrbuf_add(&d, argv0_path, sargv - argv0_path);\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\tfprintf(stderr, \"RUNTIME_PREFIX requested for path '%s', \"\n+\t\t\t\t\"but prefix computation failed.\\n\", path);\n+\t\treturn path;\n+\t}\n+\n+\tstruct strbuf d = STRBUF_INIT;\n+\tstrbuf_addf(&d, \"%s/%s\", prefix, path);\n+\tpath = strbuf_detach(&d, NULL);\n+#endif\n \treturn path;\n }\n \n-- \n1.6.0.2.GIT\n"},{"id":"91238","messageId":"1222014278-11071-4-git-send-email-prohaska@zib.de","threadId":"15612","inReplyTo":"1222014278-11071-3-git-send-email-prohaska@zib.de","subject":"[PATCH 3/7] Refactor git_set_argv0_path() to git_extract_argv0_path()","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-21T16:24:34Z","receivedAt":"2008-09-21T16:24:34Z","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 direname computation from other\nmain() functions too.\n\n[spr: split Steve's original commit and wrote new commit message. ]\n\nSigned-off-by: Steve Haslam <shaslam@lastminute.com>\nSigned-off-by: Steffen Prohaska <prohaska@zib.de>\n---\n exec_cmd.c |   15 +++++++++++++--\n exec_cmd.h |    2 +-\n git.c      |   20 +++++---------------\n 3 files changed, 19 insertions(+), 18 deletions(-)\n\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex 9fa89b8..46ebf7e 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -54,9 +54,20 @@ 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+\tdo\n+\t\t--slash;\n+\twhile (slash >= argv0 && !is_dir_sep(*slash));\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 905acc2..b2b95e8 100644\n--- a/git.c\n+++ b/git.c\n@@ -416,23 +416,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-\tdo\n-\t\t--slash;\n-\twhile (cmd <= slash && !is_dir_sep(*slash));\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.0.2.GIT\n"},{"id":"91234","messageId":"1222014278-11071-5-git-send-email-prohaska@zib.de","threadId":"15612","inReplyTo":"1222014278-11071-4-git-send-email-prohaska@zib.de","subject":"[PATCH 4/7] Glean libexec path from argv[0] for git-upload-pack and git-receive-pack.","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-21T16:24:35Z","receivedAt":"2008-09-21T16:24:35Z","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 receive-pack.c |    3 +++\n upload-pack.c  |    3 +++\n 2 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/receive-pack.c b/receive-pack.c\nindex b81678a..3872180 100644\n--- a/receive-pack.c\n+++ b/receive-pack.c\n@@ -467,6 +467,9 @@ int main(int argc, char **argv)\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\tchar *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.0.2.GIT\n"},{"id":"91240","messageId":"1222014278-11071-6-git-send-email-prohaska@zib.de","threadId":"15612","inReplyTo":"1222014278-11071-5-git-send-email-prohaska@zib.de","subject":"[PATCH 5/7] Add calls to git_extract_argv0_path() in programs that call git_config_*","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-21T16:24:36Z","receivedAt":"2008-09-21T16:24:36Z","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\nconfiguration.  When runtime prefix computation is enabled, this\nrequires that git_extract_argv0_path() is called early in the\nprogram's main().\n\nThis commit adds the necessary calls in the programs that use\ngit_config.\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 index-pack.c  |    4 ++++\n unpack-file.c |    4 ++++\n var.c         |    4 ++++\n 6 files changed, 23 insertions(+), 0 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex 0e026f6..c46ddd4 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -956,6 +956,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 ccdf2e5..8a74f38 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@@ -2395,6 +2396,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 a4d127c..6d9f948 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@@ -83,6 +84,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/index-pack.c b/index-pack.c\nindex a6e91fe..c6ac0e6 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@@ -877,6 +878,9 @@ int main(int argc, char **argv)\n \tunsigned char pack_sha1[20];\n \tint nongit = 0;\n \n+\tif (argv[0] && *argv[0])\n+\t\tgit_extract_argv0_path(argv[0]);\n+\n \tsetup_git_directory_gently(&nongit);\n \tgit_config(git_index_pack_config, NULL);\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/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.0.2.GIT\n"},{"id":"91235","messageId":"1222014278-11071-7-git-send-email-prohaska@zib.de","threadId":"15612","inReplyTo":"1222014278-11071-6-git-send-email-prohaska@zib.de","subject":"[PATCH 6/7] Modify setup_path() to only add git_exec_path() to PATH","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-21T16:24:37Z","receivedAt":"2008-09-21T16:24:37Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"We should search git programs only in the highest-priority location.\nThe old code added the directories \"argv_exec_path\",\n\"getenv(EXEC_PATH_ENVIRONMENT)\", and \"system_path(GIT_EXEC_PATH)\" to\nPATH.  The same order is implemented in git_exec_path(), which returns\nthe highest priority location to search for executables.  If the user\nexplicitly overrides the default location (by --exec-path or\nGIT_EXEC_PATH) we can expect that all the required programs are there.\nIt does not make sense that only some of the required programs are\nlocated at the highest priority location and other programs are picked\nup from a lower priority exec-path.  If exec-path is overridden\na complete set of commands should be provided, otherwise several\ndifferent versions might easily get mixed, which is likely to spread\nconfusion.\n\nAccessing the location with highest priority only is also required for\ntesting of executables built with RUNTIME_PREFIX.  Calling\nsystem_path(GIT_EXEC_PATH) is avoided if a higher-priority location is\nprovided, which is the case for the tests.  The call to system_path()\nmust be avoided, if RUNTIME_PREFIX is set, because the call would fail\nif the executable is not installed at its final destination.  But we\ntest before installing.\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 46ebf7e..2a86670 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -111,9 +111,7 @@ void setup_path(void)\n \n \tstrbuf_init(&new_path, 0);\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.0.2.GIT\n"},{"id":"91233","messageId":"1222014278-11071-8-git-send-email-prohaska@zib.de","threadId":"15612","inReplyTo":"1222014278-11071-7-git-send-email-prohaska@zib.de","subject":"[PATCH 7/7] Windows: Revert to default paths and convert them by RUNTIME_PREFIX","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-21T16:24:38Z","receivedAt":"2008-09-21T16:24:38Z","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 (absolute) paths\non Windows too.  Defining RUNTIME_PREFIX explicitly requests for\ntranslation of paths during runtime, depending on the path to the\nexecutable.\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 8181f74..98278f0 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -767,6 +767,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@@ -775,9 +776,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.0.2.GIT\n"},{"id":"91269","messageId":"200809212357.23228.johannes.sixt@telecom.at","threadId":"15612","inReplyTo":"1222014278-11071-2-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 1/7] Windows: Add workaround for MSYS' path conversion","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2008-09-21T21:57:23Z","receivedAt":"2008-09-21T21:57:23Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Sonntag, 21. September 2008, Steffen Prohaska wrote:\n> MSYS' automatic path conversion causes problems when passing paths as\n> defines ('-D' arguments to the compiler).  MSYS tries to be smart and\n> converts absolute paths to native Windows paths, e.g. if MSYS sees\n> \"/bin\" it converts it to \"c:/msysgit/bin\".  But we want completely\n> unmodified paths; e.g. if we set bindir in the Makefile to \"/bin\", the\n> define BINDIR shall expand to \"/bin\".  Conversion to absolute Windows\n> path will takes place later, during runtime.\n>\n> This commit adds a workaround by replacing \"/\" with its octal\n> representation \"\\057\", effectively hiding the path from MSYS' path\n> conversion mechanism.  MSYS does no longer see the absolute path and\n> therefore leaves it alone.\n\nThis is disgusting, don't you think so, too?\n\nThe reason that you need this patch is because you insist that paths in the \nMakefile remain defined as:\n\nbindir = $(prefix)/bin\nmandir = $(prefix)/share/man\ninfodir = $(prefix)/share/info\ngitexecdir = $(prefix)/libexec/git-core\netc...\n\neven if RUNTIME_PREFIX is enabled (and you seem to imply that $(prefix) is \nempty, but this is not enforced by any patch).\n\nWouldn't it be quite natural that enabling RUNTIME_PREFIX implies that the \nabove paths are relative, and, therefore, the Makefile must define them as\n\nbindir = bin\nmandir = share/man\ninfodir = share/info\ngitexecdir = libexec/git-core\netc...\n\nbecause the prefix is ... determined at runtime? Now the paths should not be \nmangled anymore.\n\n-- Hannes\n"},{"id":"91270","messageId":"200809212358.48125.johannes.sixt@telecom.at","threadId":"15612","inReplyTo":"1222014278-11071-8-git-send-email-prohaska@zib.de","subject":"Re: [PATCH 7/7] Windows: Revert to default paths and convert them by RUNTIME_PREFIX","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2008-09-21T21:58:48Z","receivedAt":"2008-09-21T21:58:48Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Sonntag, 21. September 2008, Steffen Prohaska wrote:\n> The RUNTIME_PREFIX mechanism allows us to use the default (absolute) paths\n> on Windows too.  Defining RUNTIME_PREFIX explicitly requests for\n> translation of paths during runtime, depending on the path to the\n> executable.\n>\n> Signed-off-by: Steffen Prohaska <prohaska@zib.de>\n> ---\n>  Makefile |    4 +---\n>  1 files changed, 1 insertions(+), 3 deletions(-)\n>\n> diff --git a/Makefile b/Makefile\n> index 8181f74..98278f0 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -767,6 +767,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\n> -Icompat/fnmatch @@ -775,9 +776,6 @@ ifneq (,$(findstring\n> MINGW,$(uname_S)))\n>  \tCOMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o\n> compat/regex/regex.o compat/winansi.o EXTLIBS += -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\nThis cannot be the complete patch. The part that sets $(prefix) to the empty \nstring is missing, otherwise the runtime prefix discovery would never \ntrigger, right? (But see also my comment on [PATCH 1/7].)\n\n-- Hannes\n"},{"id":"91280","messageId":"627E3F3B-D557-474B-BA20-3ABDEC9E2813@zib.de","threadId":"15612","inReplyTo":"200809212358.48125.johannes.sixt@telecom.at","subject":"Re: [PATCH 7/7] Windows: Revert to default paths and convert them by RUNTIME_PREFIX","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2008-09-22T05:57:04Z","receivedAt":"2008-09-22T05:57:04Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Sep 21, 2008, at 11:58 PM, Johannes Sixt wrote:\n\n> On Sonntag, 21. September 2008, Steffen Prohaska wrote:\n>> The RUNTIME_PREFIX mechanism allows us to use the default  \n>> (absolute) paths\n>> on Windows too.  Defining RUNTIME_PREFIX explicitly requests for\n>> translation of paths during runtime, depending on the path to the\n>> executable.\n>>\n>> Signed-off-by: Steffen Prohaska <prohaska@zib.de>\n>> ---\n>> Makefile |    4 +---\n>> 1 files changed, 1 insertions(+), 3 deletions(-)\n>>\n>> diff --git a/Makefile b/Makefile\n>> index 8181f74..98278f0 100644\n>> --- a/Makefile\n>> +++ b/Makefile\n>> @@ -767,6 +767,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/ \n>> regex\n>> -Icompat/fnmatch @@ -775,9 +776,6 @@ ifneq (,$(findstring\n>> MINGW,$(uname_S)))\n>> \tCOMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o\n>> compat/regex/regex.o compat/winansi.o EXTLIBS += -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>\n> This cannot be the complete patch. The part that sets $(prefix) to  \n> the empty\n> string is missing, otherwise the runtime prefix discovery would never\n> trigger, right? (But see also my comment on [PATCH 1/7].)\n\nRight.  There are still some differences between msysgit's Makefile and\nthe official one, so I forgot to include all necessary changes.\n\nI'll modify the implementation as you propose in your comment\non [PATCH 1/7].\n\n\tSteffen\n"}]}