{"thread":{"id":"23332","subject":"[PATCH] Replace hard-coded path with one configurable at make time","startedAt":"2010-04-04T20:48:50Z","lastAt":"2010-04-15T19:15:04Z","messageCount":24,"participants":["Chris Webb","Junio C Hamano","Erik Faye-Lund","Tait","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"138557","messageId":"186fa4afcc08ad6ba10906a231c437536fbdb8e9.1270412075.git.chris@arachsys.com","threadId":"23332","inReplyTo":null,"subject":"[PATCH] Replace hard-coded path with one configurable at make time","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-04T20:48:50Z","receivedAt":"2010-04-04T20:48:50Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"In exec_cmd.c and git-instaweb.sh, git hard-codes a default path of\n/usr/local/bin:/usr/bin:/bin. Introduce a make variable allowing this to be\noverridden by passing defpath to make.\n---\nI haven't worked out the capitalisation convention in the makefile, so I'm\nnot sure if this should be DEFPATH or defpath. (For example, prefix is\nlower-case but DESTDIR is all-caps.)\n\n Makefile        |    6 +++++-\n exec_cmd.c      |    2 +-\n git-instaweb.sh |    4 ++--\n 3 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 11ec3e2..2f4b39e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -278,6 +278,7 @@ endif\n lib = lib\n # DESTDIR=\n pathsep = :\n+defpath = /usr/local/bin:/usr/bin:/bin\n \n # JavaScript minifier invocation that can function as filter\n JSMIN =\n@@ -1426,6 +1427,7 @@ gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n htmldir_SQ = $(subst ','\\'',$(htmldir))\n prefix_SQ = $(subst ','\\'',$(prefix))\n+defpath_SQ = $(subst ','\\'',$(defpath))\n \n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n@@ -1588,6 +1590,7 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.\n \t    -e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \\\n \t    -e '/@@GITWEB_JS@@/d' \\\n \t    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \\\n+\t    -e 's|@@DEFPATH@@|$(defpath_SQ)|g' \\\n \t    $@.sh > $@+ && \\\n \tchmod +x $@+ && \\\n \tmv $@+ $@\n@@ -1774,7 +1777,8 @@ endif\n exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n \t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n-\t'-DPREFIX=\"$(prefix_SQ)\"'\n+\t'-DPREFIX=\"$(prefix_SQ)\"' \\\n+\t'-DDEFPATH=\"$(defpath_SQ)\"'\n \n builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n \t-DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir_SQ)\"'\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex b2c07c7..39c6a59 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -107,7 +107,7 @@ void setup_path(void)\n \tif (old_path)\n \t\tstrbuf_addstr(&new_path, old_path);\n \telse\n-\t\tstrbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n+\t\tstrbuf_addstr(&new_path, DEFPATH);\n \n \tsetenv(\"PATH\", new_path.buf, 1);\n \ndiff --git a/git-instaweb.sh b/git-instaweb.sh\nindex 6a65f25..72d8b12 100755\n--- a/git-instaweb.sh\n+++ b/git-instaweb.sh\n@@ -212,7 +212,7 @@ server.errorlog = \"$fqgitdir/gitweb/error.log\"\n # variable above and uncomment this\n #accesslog.filename = \"$fqgitdir/gitweb/access.log\"\n \n-setenv.add-environment = ( \"PATH\" => \"/usr/local/bin:/usr/bin:/bin\" )\n+setenv.add-environment = ( \"PATH\" => \"@@DEFPATH@@\" )\n \n cgi.assign = ( \".cgi\" => \"\" )\n \n@@ -361,7 +361,7 @@ error_log\t$fqgitdir/gitweb/error.log\n access_log\t$fqgitdir/gitweb/access.log\n \n #cgi setup\n-cgi_env\t\tPATH=/usr/local/bin:/usr/bin:/bin,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH\n+cgi_env\t\tPATH=@@DEFPATH@@,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH\n cgi_interp\t$PERL\n cgi_ext\t\tcgi,pl\n \n-- \n1.7.0.3\n"},{"id":"138560","messageId":"7vk4sm7vao.fsf@alter.siamese.dyndns.org","threadId":"23332","inReplyTo":"186fa4afcc08ad6ba10906a231c437536fbdb8e9.1270412075.git.chris@arachsys.com","subject":"Re: [PATCH] Replace hard-coded path with one configurable at make time","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-04T21:38:23Z","receivedAt":"2010-04-04T21:38:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Webb <chris@arachsys.com> writes:\n\n> In exec_cmd.c and git-instaweb.sh, git hard-codes a default path of\n> /usr/local/bin:/usr/bin:/bin. Introduce a make variable allowing this to be\n> overridden by passing defpath to make.\n\nA question and an issue.\n\n * What's the point of making this configurable, other than \"because we\n   can\"?\n\n * Use of \"$(x_SQ)\" is about protecting whitespaces and single quotes in\n   the literal from make and shell, but does not have anything to do with\n   protecting things like $foo in that literal from the location $x is\n   eventually embedded in.  As long as paths on DEFPATH do not have double\n   quote in it (which would be a sane assumption), the patch to exec_cmd.c\n   would work fine, but I don't know if you need an extra quoting when\n   DEFPATH is used in shell scripts.  E.g. DEFPATH=$GIT_EXEC_PATH:/usr/bin\n   would have GIT_EXEC_PATH expanded in mongoose configuration file, but\n   will not be expanded in exec_cmd.c, leading to an inconsistent\n   behaviour.\n\n   Does this matter?\n  \n"},{"id":"138565","messageId":"20100404222801.GB31315@arachsys.com","threadId":"23332","inReplyTo":"7vk4sm7vao.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Replace hard-coded path with one configurable at make time","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-04T22:28:01Z","receivedAt":"2010-04-04T22:28:01Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>  * What's the point of making this configurable, other than \"because we\n>    can\"?\n\nI have a local patch against git to fix these paths, as I run it on slightly\nunusual systems with a non-standard directory layout (no /usr, but\n/local/bin in some cases) and I don't like to see incorrect paths compiled\ninto my binaries. It occurred to me that if I want to fix it one way\nlocally, others may well want to vary it too for different reasons, e.g. to\nadd /opt/bin or /usr/gnu to the default path.\n\nUltimately, I guess it feels like it should be configurable rather than\nneeding to be patched in the source for the same reason prefix or gitexecdir\nis, but this is definitely for a minority audience!\n\nWere it just exec_cmd.c, I would just have changed it to use _PATH_DEFPATH\nfrom <paths.h> in preference to a make variable, as that should always give\nan appropriate value for a correctly put-together system and is a sensible\nplace to treat as the central definition of 'default path'. However, in this\ncase it's needed in the shell script too and I don't think I can easily get\nat _PATH_DEFPATH from there.\n\n>  * Use of \"$(x_SQ)\" is about protecting whitespaces and single quotes in\n>    the literal from make and shell, but does not have anything to do with\n>    protecting things like $foo in that literal from the location $x is\n>    eventually embedded in.  As long as paths on DEFPATH do not have double\n>    quote in it (which would be a sane assumption), the patch to exec_cmd.c\n>    would work fine, but I don't know if you need an extra quoting when\n>    DEFPATH is used in shell scripts.  E.g. DEFPATH=$GIT_EXEC_PATH:/usr/bin\n>    would have GIT_EXEC_PATH expanded in mongoose configuration file, but\n>    will not be expanded in exec_cmd.c, leading to an inconsistent\n>    behaviour.\n\nOh I see, yes; I didn't worry about quoting it correctly in the generated\nshell script, assuming it would be reasonable... but if I'm assuming it's\nreasonable there's no point in the _SQ to protect the shell invoking sed in\nthe first place.\n\nI also notice that the makefile makes the assumption that ' might occur in\npathological paths and so needs quoting, but then uses sed 's|x|y|g' for\n(say) @@PERL@@ which will break for other pathological paths containing | or\n\\1 and so on. Tidying that up fully might be entertaining!\n\nCheers,\n\nChris.\n"},{"id":"138765","messageId":"20100406163525.GF15306@arachsys.com","threadId":"23332","inReplyTo":"20100404222801.GB31315@arachsys.com","subject":"Re: [PATCH] Replace hard-coded path with one configurable at make time","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-06T16:35:25Z","receivedAt":"2010-04-06T16:35:25Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Chris Webb <chris@arachsys.com> writes:\n\n> Were it just exec_cmd.c, I would just have changed it to use _PATH_DEFPATH\n> from <paths.h> in preference to a make variable, as that should always give\n> an appropriate value for a correctly put-together system and is a sensible\n> place to treat as the central definition of 'default path'. However, in this\n> case it's needed in the shell script too and I don't think I can easily get\n> at _PATH_DEFPATH from there.\n\nHaving looked at this again, I think it's probably better to tackle the two\npieces separately. It would be cleaner to fix exec_cmd.c to use the correct\nsystem-wide _PATH_DEFPATH from <paths.h> if possible, as in the following\npatch, rather than introduce yet another make variable.\n\nSimilarly, looking more closely at what the path gets used for, I think\ngit-instaweb.sh is wrong to hard-code a default path anyway: it should\nsurely pass through the path inherited from the invoking user rather than\nsilently overriding it. I'll do a separate patch for that.\n\nCheers,\n\nChris.\n"},{"id":"138766","messageId":"20100406163643.GG15306@arachsys.com","threadId":"23332","inReplyTo":"20100406163525.GF15306@arachsys.com","subject":"[PATCH] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-06T16:36:43Z","receivedAt":"2010-04-06T16:36:43Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"In exec_cmd.c, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin.\nGet an appropriate value for the system from <paths.h> if possible instead.\n\nSigned-off-by: Chris Webb <chris@arachsys.com>\n---\n exec_cmd.c        |    2 +-\n git-compat-util.h |    5 +++++\n 2 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex b2c07c7..bf22570 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -107,7 +107,7 @@ void setup_path(void)\n \tif (old_path)\n \t\tstrbuf_addstr(&new_path, old_path);\n \telse\n-\t\tstrbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n+\t\tstrbuf_addstr(&new_path, _PATH_DEFPATH);\n \n \tsetenv(\"PATH\", new_path.buf, 1);\n \ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 7e62b55..7592be7 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -92,6 +92,7 @@\n #include <assert.h>\n #include <regex.h>\n #include <utime.h>\n+#include <paths.h>\n #ifndef __MINGW32__\n #include <sys/wait.h>\n #include <sys/poll.h>\n@@ -164,6 +165,10 @@ extern char *gitbasename(char *);\n #define PATH_SEP ':'\n #endif\n \n+#ifndef _PATH_DEFPATH\n+#define _PATH_DEFPATH \"/usr/local/bin:/usr/bin:/bin\"\n+#endif\n+\n #ifndef STRIP_EXTENSION\n #define STRIP_EXTENSION \"\"\n #endif\n-- \n1.7.0.3\n"},{"id":"138767","messageId":"20100406165721.GH28707@arachsys.com","threadId":"23332","inReplyTo":"20100406163525.GF15306@arachsys.com","subject":"[PATCH] git-instaweb: pass through invoking user's path to gitweb CGI script","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-06T16:57:21Z","receivedAt":"2010-04-06T16:57:21Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"When used with lighttpd or mongoose, git-instaweb previously passed a\nhard-coded, default value of PATH to the gitweb CGI script. Use the invoking\nuser's value for PATH for this instead. (This is already the behaviour for\nother web servers supported by git-instaweb.)\n\nSigned-off-by: Chris Webb <chris@arachsys.com>\n---\n git-instaweb.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-instaweb.sh b/git-instaweb.sh\nindex 6a65f25..0e1cb07 100755\n--- a/git-instaweb.sh\n+++ b/git-instaweb.sh\n@@ -212,7 +212,7 @@ server.errorlog = \"$fqgitdir/gitweb/error.log\"\n # variable above and uncomment this\n #accesslog.filename = \"$fqgitdir/gitweb/access.log\"\n \n-setenv.add-environment = ( \"PATH\" => \"/usr/local/bin:/usr/bin:/bin\" )\n+setenv.add-environment = ( \"PATH\" => env.PATH )\n \n cgi.assign = ( \".cgi\" => \"\" )\n \n@@ -361,7 +361,7 @@ error_log\t$fqgitdir/gitweb/error.log\n access_log\t$fqgitdir/gitweb/access.log\n \n #cgi setup\n-cgi_env\t\tPATH=/usr/local/bin:/usr/bin:/bin,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH\n+cgi_env\t\tPATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH\n cgi_interp\t$PERL\n cgi_ext\t\tcgi,pl\n \n-- \n1.7.0.3\n"},{"id":"138820","messageId":"n2u40aa078e1004070357m143cfaccvdc754a3bc5fe1ae1@mail.gmail.com","threadId":"23332","inReplyTo":"20100406163643.GG15306@arachsys.com","subject":"Re: [PATCH] Replace hard-coded path with one from <paths.h>","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-04-07T10:57:37Z","receivedAt":"2010-04-07T10:57:37Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Tue, Apr 6, 2010 at 6:36 PM, Chris Webb <chris@arachsys.com> wrote:\n> In exec_cmd.c, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin.\n> Get an appropriate value for the system from <paths.h> if possible instead.\n>\n> Signed-off-by: Chris Webb <chris@arachsys.com>\n> ---\n>  exec_cmd.c        |    2 +-\n>  git-compat-util.h |    5 +++++\n>  2 files changed, 6 insertions(+), 1 deletions(-)\n>\n> diff --git a/exec_cmd.c b/exec_cmd.c\n> index b2c07c7..bf22570 100644\n> --- a/exec_cmd.c\n> +++ b/exec_cmd.c\n> @@ -107,7 +107,7 @@ void setup_path(void)\n>        if (old_path)\n>                strbuf_addstr(&new_path, old_path);\n>        else\n> -               strbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n> +               strbuf_addstr(&new_path, _PATH_DEFPATH);\n>\n>        setenv(\"PATH\", new_path.buf, 1);\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 7e62b55..7592be7 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -92,6 +92,7 @@\n>  #include <assert.h>\n>  #include <regex.h>\n>  #include <utime.h>\n> +#include <paths.h>\n\nThis breaks on Windows due to missing paths.h. I guess you need some\nguard to detect if the header is present or not.\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"138958","messageId":"20100408105850.GD2146@arachsys.com","threadId":"23332","inReplyTo":"n2u40aa078e1004070357m143cfaccvdc754a3bc5fe1ae1@mail.gmail.com","subject":"Re: [PATCH] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-08T10:58:51Z","receivedAt":"2010-04-08T10:58:51Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Erik Faye-Lund <kusmabite@googlemail.com> writes:\n\n> > +#include <paths.h>\n> \n> This breaks on Windows due to missing paths.h. I guess you need some\n> guard to detect if the header is present or not.\n\nIs this true of all WIN32, or just __MINGW32__ / __CYGWIN__? Presumably\n/usr/local/bin:/usr/bin:/bin is the wrong default PATH on windows too, so\nperhaps I should sort that at the same point---what would a canonical\ndefault PATH be for Windows?\n\nCheers,\n\nChris.\n"},{"id":"138959","messageId":"m2x40aa078e1004080426u98fbe6b2zfa9a2726172f725@mail.gmail.com","threadId":"23332","inReplyTo":"20100408105850.GD2146@arachsys.com","subject":"Re: [PATCH] Replace hard-coded path with one from <paths.h>","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-04-08T11:26:07Z","receivedAt":"2010-04-08T11:26:07Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, Apr 8, 2010 at 12:58 PM, Chris Webb <chris@arachsys.com> wrote:\n> Erik Faye-Lund <kusmabite@googlemail.com> writes:\n>\n>> > +#include <paths.h>\n>>\n>> This breaks on Windows due to missing paths.h. I guess you need some\n>> guard to detect if the header is present or not.\n>\n> Is this true of all WIN32, or just __MINGW32__ / __CYGWIN__?\n\nI've only tested it on mingw (msysGit). I don't know about cygwin and msvc.\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"138960","messageId":"20100408115706.GE2077@arachsys.com","threadId":"23332","inReplyTo":"m2x40aa078e1004080426u98fbe6b2zfa9a2726172f725@mail.gmail.com","subject":"[PATCH v2] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-08T11:57:07Z","receivedAt":"2010-04-08T11:57:07Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"In exec_cmd.c, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin.\nGet an appropriate value for the system from <paths.h> if possible instead.\nDo not attempt to #include <paths.h> under Windows.\n\nSigned-off-by: Chris Webb <chris@arachsys.com>\n---\n exec_cmd.c        |    2 +-\n git-compat-util.h |    6 ++++++\n 2 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex b2c07c7..bf22570 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -107,7 +107,7 @@ void setup_path(void)\n \tif (old_path)\n \t\tstrbuf_addstr(&new_path, old_path);\n \telse\n-\t\tstrbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n+\t\tstrbuf_addstr(&new_path, _PATH_DEFPATH);\n \n \tsetenv(\"PATH\", new_path.buf, 1);\n \ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 7e62b55..9443b9b 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -70,6 +70,8 @@\n #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */\n #include <winsock2.h>\n #include <windows.h>\n+#else\n+#include <paths.h>\n #endif\n \n #include <unistd.h>\n@@ -164,6 +166,10 @@ extern char *gitbasename(char *);\n #define PATH_SEP ':'\n #endif\n \n+#ifndef _PATH_DEFPATH\n+#define _PATH_DEFPATH \"/usr/local/bin:/usr/bin:/bin\"\n+#endif\n+\n #ifndef STRIP_EXTENSION\n #define STRIP_EXTENSION \"\"\n #endif\n-- \n1.7.0.3\n"},{"id":"138961","messageId":"z2o40aa078e1004080508z17c5e71by371bbe6e1cdb8c50@mail.gmail.com","threadId":"23332","inReplyTo":"20100408115706.GE2077@arachsys.com","subject":"Re: [PATCH v2] Replace hard-coded path with one from <paths.h>","fromName":"Erik Faye-Lund","fromEmail":"kusmabite@googlemail.com","sentAt":"2010-04-08T12:08:30Z","receivedAt":"2010-04-08T12:08:30Z","isPatch":true,"sender":{"key":"kusmabite@gmail.com","avatar":"https://avatars.githubusercontent.com/u/47073?v=4"},"body":"On Thu, Apr 8, 2010 at 1:57 PM, Chris Webb <chris@arachsys.com> wrote:\n> In exec_cmd.c, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin.\n> Get an appropriate value for the system from <paths.h> if possible instead.\n> Do not attempt to #include <paths.h> under Windows.\n>\n> Signed-off-by: Chris Webb <chris@arachsys.com>\n> ---\n>  exec_cmd.c        |    2 +-\n>  git-compat-util.h |    6 ++++++\n>  2 files changed, 7 insertions(+), 1 deletions(-)\n>\n> diff --git a/exec_cmd.c b/exec_cmd.c\n> index b2c07c7..bf22570 100644\n> --- a/exec_cmd.c\n> +++ b/exec_cmd.c\n> @@ -107,7 +107,7 @@ void setup_path(void)\n>        if (old_path)\n>                strbuf_addstr(&new_path, old_path);\n>        else\n> -               strbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n> +               strbuf_addstr(&new_path, _PATH_DEFPATH);\n>\n>        setenv(\"PATH\", new_path.buf, 1);\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 7e62b55..9443b9b 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -70,6 +70,8 @@\n>  #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */\n>  #include <winsock2.h>\n>  #include <windows.h>\n> +#else\n> +#include <paths.h>\n>  #endif\n>\n\nAre you sure that all non-Windows platforms have paths.h? It seems\nthat at least some Open Solaris versions[1] are missing it as well.\nPerhaps this should be guarded by a HAVE_PATHS_H define instead?\n\n[1]: http://mail-index.netbsd.org/tech-pkg/2008/11/24/msg002103.html\n\n-- \nErik \"kusma\" Faye-Lund\n"},{"id":"139012","messageId":"20100409054536.GB2151@arachsys.com","threadId":"23332","inReplyTo":"z2o40aa078e1004080508z17c5e71by371bbe6e1cdb8c50@mail.gmail.com","subject":"Re: [PATCH v2] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-09T05:45:36Z","receivedAt":"2010-04-09T05:45:36Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Erik Faye-Lund <kusmabite@googlemail.com> writes:\n\n> Are you sure that all non-Windows platforms have paths.h? It seems\n> that at least some Open Solaris versions[1] are missing it as well.\n> Perhaps this should be guarded by a HAVE_PATHS_H define instead?\n\nYes, you're probably right. I'll just set HAVE_PATHS_H for the platforms I'm\nsure (or can check) have it for now.\n\nCheers,\n\nChris.\n"},{"id":"139094","messageId":"20100409235455.GI2480@ece.pdx.edu","threadId":"23332","inReplyTo":"20100408105850.GD2146@arachsys.com","subject":"Re: [PATCH] Replace hard-coded path with one from <paths.h>","fromName":"Tait","fromEmail":"git.git@t41t.com","sentAt":"2010-04-09T23:54:55Z","receivedAt":"2010-04-09T23:54:55Z","isPatch":true,"sender":{"key":"git.git@t41t.com","avatar":null},"body":"> > > +#include <paths.h>\n> >\n> > This breaks on Windows due to missing paths.h. I guess you need some\n> > guard to detect if the header is present or not.\n>\n> Is this true of all WIN32, or just __MINGW32__ / __CYGWIN__? Presumably\n> /usr/local/bin:/usr/bin:/bin is the wrong default PATH on windows too, so\n> perhaps I should sort that at the same point---what would a canonical\n> default PATH be for Windows?\n\nPaths.h is not found on my version of mingw/msys.\n\nThe \"canonical\" Windows path is usually the system directory, and system32\nand system32\\Wbem under the system directory. The system directory could\nbe anywhere. C:\\WINDOWS is common, but the WINDOWS (or even the C:) are\nsubject to change on any given installation. So for example on my computer,\n\tC:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem\n\nis the path before adding in PowerShell, Resource Kits, GTK, etc. Windows\nalso assumes '.' is part of your path, even though it's not explicitly\npresent in %PATH%.\n\nMy version of mingw seems to prepend to the above,\n\t.:/usr/local/bin:/mingw/bin:/bin\n\nbesides also using : instead of ; as a separator.\n"},{"id":"139401","messageId":"20100413090604.GB770@arachsys.com","threadId":"23332","inReplyTo":"20100409054536.GB2151@arachsys.com","subject":"Re: [PATCH v2] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-13T09:06:04Z","receivedAt":"2010-04-13T09:06:04Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Chris Webb <chris@arachsys.com> writes:\n\n> Erik Faye-Lund <kusmabite@googlemail.com> writes:\n> \n> > Are you sure that all non-Windows platforms have paths.h? It seems\n> > that at least some Open Solaris versions[1] are missing it as well.\n> > Perhaps this should be guarded by a HAVE_PATHS_H define instead?\n> \n> Yes, you're probably right. I'll just set HAVE_PATHS_H for the platforms I'm\n> sure (or can check) have it for now.\n\nSorry for the slow follow up. Replacement patch in follow-up that tries this\nonly on Linux, *BSD and GNU where it's known to work. Should be completely\nsafe now!\n\nBest wishes,\n\nChris.\n"},{"id":"139402","messageId":"20100413090713.GC770@arachsys.com","threadId":"23332","inReplyTo":"20100413090604.GB770@arachsys.com","subject":"[PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-13T09:07:13Z","receivedAt":"2010-04-13T09:07:13Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"In exec_cmd.c, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin.\nGet an appropriate value for the system from <paths.h> if possible instead. We\nonly try to include <paths.h> on Linux, FreeBSD, NetBSD, OpenBSD and GNU where\nit is known to exist.\n\nSigned-off-by: Chris Webb <chris@arachsys.com>\n---\n Makefile          |   10 ++++++++++\n exec_cmd.c        |    2 +-\n git-compat-util.h |    6 ++++++\n 3 files changed, 17 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 910f471..f4fe941 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -735,10 +735,12 @@ EXTLIBS =\n ifeq ($(uname_S),Linux)\n \tNO_STRLCPY = YesPlease\n \tNO_MKSTEMPS = YesPlease\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),GNU/kFreeBSD)\n \tNO_STRLCPY = YesPlease\n \tNO_MKSTEMPS = YesPlease\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),UnixWare)\n \tCC = cc\n@@ -867,6 +869,7 @@ ifeq ($(uname_S),FreeBSD)\n \t\tNO_STRTOUMAX = YesPlease\n \tendif\n \tPYTHON_PATH = /usr/local/bin/python\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),OpenBSD)\n \tNO_STRCASESTR = YesPlease\n@@ -875,6 +878,7 @@ ifeq ($(uname_S),OpenBSD)\n \tNEEDS_LIBICONV = YesPlease\n \tBASIC_CFLAGS += -I/usr/local/include\n \tBASIC_LDFLAGS += -L/usr/local/lib\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),NetBSD)\n \tifeq ($(shell expr \"$(uname_R)\" : '[01]\\.'),2)\n@@ -884,6 +888,7 @@ ifeq ($(uname_S),NetBSD)\n \tBASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib\n \tUSE_ST_TIMESPEC = YesPlease\n \tNO_MKSTEMPS = YesPlease\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),AIX)\n \tNO_STRCASESTR=YesPlease\n@@ -904,6 +909,7 @@ ifeq ($(uname_S),GNU)\n \t# GNU/Hurd\n \tNO_STRLCPY=YesPlease\n \tNO_MKSTEMPS = YesPlease\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),IRIX)\n \tNO_SETENV = YesPlease\n@@ -1353,6 +1359,10 @@ else\n \tLIB_OBJS += thread-utils.o\n endif\n \n+ifdef HAVE_PATHS_H\n+\tBASIC_CFLAGS += -DHAVE_PATHS_H\n+endif\n+\n ifdef DIR_HAS_BSD_GROUP_SEMANTICS\n \tCOMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS\n endif\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex b2c07c7..bf22570 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -107,7 +107,7 @@ void setup_path(void)\n \tif (old_path)\n \t\tstrbuf_addstr(&new_path, old_path);\n \telse\n-\t\tstrbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n+\t\tstrbuf_addstr(&new_path, _PATH_DEFPATH);\n \n \tsetenv(\"PATH\", new_path.buf, 1);\n \ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 7e62b55..ed1accc 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -164,6 +164,12 @@ extern char *gitbasename(char *);\n #define PATH_SEP ':'\n #endif\n \n+#ifdef HAVE_PATHS_H\n+#include <paths.h>\n+#else\n+#define _PATH_DEFPATH \"/usr/local/bin:/usr/bin:/bin\"\n+#endif\n+\n #ifndef STRIP_EXTENSION\n #define STRIP_EXTENSION \"\"\n #endif\n-- \n1.7.0.3\n"},{"id":"139433","messageId":"7vsk6zt93s.fsf@alter.siamese.dyndns.org","threadId":"23332","inReplyTo":"20100413090713.GC770@arachsys.com","subject":"Re: [PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-13T20:01:43Z","receivedAt":"2010-04-13T20:01:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Webb <chris@arachsys.com> writes:\n\n> In exec_cmd.c, git hard-codes a default path of\n> /usr/local/bin:/usr/bin:/bin.  Get an appropriate value for the system\n> from <paths.h> if possible instead. We only try to include <paths.h> on\n> Linux, FreeBSD, NetBSD, OpenBSD and GNU where it is known to exist.\n>\n> Signed-off-by: Chris Webb <chris@arachsys.com>\n> ---\n>  Makefile          |   10 ++++++++++\n>  exec_cmd.c        |    2 +-\n>  git-compat-util.h |    6 ++++++\n>  3 files changed, 17 insertions(+), 1 deletions(-)\n>\n> diff --git a/Makefile b/Makefile\n> index 910f471..f4fe941 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -735,10 +735,12 @@ EXTLIBS =\n>  ifeq ($(uname_S),Linux)\n>  \tNO_STRLCPY = YesPlease\n>  \tNO_MKSTEMPS = YesPlease\n> +\tHAVE_PATHS_H = YesPlease\n>  endif\n\nOk.  Somebody else may want to add an autoconf support on top of this, but\nthis is good as-is, I think.\n\nThanks.\n"},{"id":"139458","messageId":"20100414072248.GA30975@arachsys.com","threadId":"23332","inReplyTo":"7vsk6zt93s.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-14T07:22:48Z","receivedAt":"2010-04-14T07:22:48Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ok.  Somebody else may want to add an autoconf support on top of this, but\n> this is good as-is, I think.\n\nThanks; sorry it took me three attempts to get such a simple patch right!\n\nCheers,\n\nChris.\n"},{"id":"139577","messageId":"m3hbncgaxu.fsf@localhost.localdomain","threadId":"23332","inReplyTo":"20100413090713.GC770@arachsys.com","subject":"Re: [PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-15T12:25:14Z","receivedAt":"2010-04-15T12:25:14Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Chris Webb <chris@arachsys.com> writes:\n\n> In exec_cmd.c, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin.\n> Get an appropriate value for the system from <paths.h> if possible instead. We\n> only try to include <paths.h> on Linux, FreeBSD, NetBSD, OpenBSD and GNU where\n> it is known to exist.\n> \n> Signed-off-by: Chris Webb <chris@arachsys.com>\n> ---\n>  Makefile          |   10 ++++++++++\n>  exec_cmd.c        |    2 +-\n>  git-compat-util.h |    6 ++++++\n>  3 files changed, 17 insertions(+), 1 deletions(-)\n> \n> diff --git a/Makefile b/Makefile\n> index 910f471..f4fe941 100644\n> --- a/Makefile\n> +++ b/Makefile\n\nAll other such variables are described at the top of main Makefile,\nfor example:\n\n  #\n  # Define NO_LIBGEN_H if you don't have libgen.h.\n\nI think that HAVE_PATHS_H should also have such one-line description.\nBy the way it the very first variable with HAVE_* rather than NEEDS_*\nor NO_* name.\n\n[...]\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 7e62b55..ed1accc 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -164,6 +164,12 @@ extern char *gitbasename(char *);\n>  #define PATH_SEP ':'\n>  #endif\n>  \n> +#ifdef HAVE_PATHS_H\n> +#include <paths.h>\n> +#else\n> +#define _PATH_DEFPATH \"/usr/local/bin:/usr/bin:/bin\"\n> +#endif\n> +\n>  #ifndef STRIP_EXTENSION\n>  #define STRIP_EXTENSION \"\"\n>  #endif\n\nWhy not\n\n  +#ifdef HAVE_PATHS_H\n  +#include <paths.h>\n  +#endif\n  +#ifndef _PATH_DEFPATH\n  +#define _PATH_DEFPATH \"/usr/local/bin:/usr/bin:/bin\"\n  +#endif\n\nThis way you are covered if some other header provides _PATH_DEFPATH.\nOr is your way better?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"139578","messageId":"m3d3y0gath.fsf@localhost.localdomain","threadId":"23332","inReplyTo":"7vsk6zt93s.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-15T12:27:49Z","receivedAt":"2010-04-15T12:27:49Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Chris Webb <chris@arachsys.com> writes:\n> \n> > In exec_cmd.c, git hard-codes a default path of\n> > /usr/local/bin:/usr/bin:/bin.  Get an appropriate value for the system\n> > from <paths.h> if possible instead. We only try to include <paths.h> on\n> > Linux, FreeBSD, NetBSD, OpenBSD and GNU where it is known to exist.\n> >\n> > Signed-off-by: Chris Webb <chris@arachsys.com>\n> > ---\n> >  Makefile          |   10 ++++++++++\n> >  exec_cmd.c        |    2 +-\n> >  git-compat-util.h |    6 ++++++\n> >  3 files changed, 17 insertions(+), 1 deletions(-)\n> >\n> > diff --git a/Makefile b/Makefile\n> > index 910f471..f4fe941 100644\n> > --- a/Makefile\n> > +++ b/Makefile\n> > @@ -735,10 +735,12 @@ EXTLIBS =\n> >  ifeq ($(uname_S),Linux)\n> >  \tNO_STRLCPY = YesPlease\n> >  \tNO_MKSTEMPS = YesPlease\n> > +\tHAVE_PATHS_H = YesPlease\n> >  endif\n> \n> Ok.  Somebody else may want to add an autoconf support on top of this, but\n> this is good as-is, I think.\n\nSomething like that?\n\n-- >8 --\nSubject: [PATCH] autoconf: Check if <paths.h> exists\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n config.mak.in |    1 +\n configure.ac  |    6 ++++++\n 2 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/config.mak.in b/config.mak.in\nindex e8d96e8..f0aeb8e 100644\n--- a/config.mak.in\n+++ b/config.mak.in\n@@ -31,6 +31,7 @@ NO_OPENSSL=@NO_OPENSSL@\n NO_CURL=@NO_CURL@\n NO_EXPAT=@NO_EXPAT@\n NO_LIBGEN_H=@NO_LIBGEN_H@\n+HAVE_PATHS_H=@HAVE_PATHS_H@\n NEEDS_LIBICONV=@NEEDS_LIBICONV@\n NEEDS_SOCKET=@NEEDS_SOCKET@\n NO_SYS_SELECT_H=@NO_SYS_SELECT_H@\ndiff --git a/configure.ac b/configure.ac\nindex 108a97f..9dc0320 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -633,6 +633,12 @@ AC_CHECK_HEADER([libgen.h],\n [NO_LIBGEN_H=YesPlease])\n AC_SUBST(NO_LIBGEN_H)\n #\n+# Define HAVE_PATHS_H if you have paths.h.\n+AC_CHECK_HEADER([paths.h],\n+[HAVE_PATHS_H=YesPlease],\n+[HAVE_PATHS_H=])\n+AC_SUBST(HAVE_PATHS_H)\n+#\n # Define NO_STRCASESTR if you don't have strcasestr.\n GIT_CHECK_FUNC(strcasestr,\n [NO_STRCASESTR=],\n-- \n1.7.0.1\n"},{"id":"139580","messageId":"20100415124043.GH12365@arachsys.com","threadId":"23332","inReplyTo":"m3hbncgaxu.fsf@localhost.localdomain","subject":"Re: [PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-15T12:40:43Z","receivedAt":"2010-04-15T12:40:43Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> All other such variables are described at the top of main Makefile,\n> for example:\n> \n>   #\n>   # Define NO_LIBGEN_H if you don't have libgen.h.\n> \n> I think that HAVE_PATHS_H should also have such one-line description.\n> By the way it the very first variable with HAVE_* rather than NEEDS_*\n> or NO_* name.\n\nTo be honest, I used the name suggested to me earlier in the thread without\na great deal of checking to see how consistent it was with existing naming\nconvention.\n\nBlacklisting OSes with a NO_PATHS_H #define feels like a mistake, as unknown\nOSes will fail rather than assuming a safe (if slightly untidy) default. I\ngot caught out assuming that Windows was sane in this regard, for instance.\n\nTo me, NEEDS_PATH_H hints that a system with paths.h would break if it\nweren't included, rather than that this is an extra feature available on\nthis OS. But if NEEDS_* is used elsewhere to enable optional extras on\nsystems which support them, I agree we should change to NEEDS_PATH_H to be\nconsistent.\n\n> Why not\n> \n>   +#ifdef HAVE_PATHS_H\n>   +#include <paths.h>\n>   +#endif\n>   +#ifndef _PATH_DEFPATH\n>   +#define _PATH_DEFPATH \"/usr/local/bin:/usr/bin:/bin\"\n>   +#endif\n> \n> This way you are covered if some other header provides _PATH_DEFPATH.\n\nYes, makes sense, although I think _PATH_DEFPATH is very unlikely to be\nprovided outside of <paths.h>.\n\nBest wishes,\n\nChris.\n"},{"id":"139582","messageId":"201004151458.02156.jnareb@gmail.com","threadId":"23332","inReplyTo":"20100415124043.GH12365@arachsys.com","subject":"Re: [PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-04-15T12:57:59Z","receivedAt":"2010-04-15T12:57:59Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Thu, 15 April 2010, Chris Webb wrote:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > All other such variables are described at the top of main Makefile,\n> > for example:\n> > \n> >   #\n> >   # Define NO_LIBGEN_H if you don't have libgen.h.\n> > \n> > I think that HAVE_PATHS_H should also have such one-line description.\n> > By the way it the very first variable with HAVE_* rather than NEEDS_*\n> > or NO_* name.\n> \n> To be honest, I used the name suggested to me earlier in the thread without\n> a great deal of checking to see how consistent it was with existing naming\n> convention.\n\nActually HAVE_STH_H is the convention used in autoconf documentation.\nIt is Git convention of NO_STH_H (well, the single example of NO_LIBGEN_H)\nthat is non-standard... but this convention predates [optional] autoconf\nsupport in Git.\n\n> \n> Blacklisting OSes with a NO_PATHS_H #define feels like a mistake, as unknown\n> OSes will fail rather than assuming a safe (if slightly untidy) default. I\n> got caught out assuming that Windows was sane in this regard, for instance.\n\nWell, there is only one example of checking for _headers_, namely\nNO_LIBGEN_H, so it is not that you are against some majority.\n\nIn short: if there is no voice against HAVE_PATHS_H, lets have it this\nway.\n\n> \n> To me, NEEDS_PATH_H hints that a system with paths.h would break if it\n> weren't included, rather than that this is an extra feature available on\n> this OS. But if NEEDS_* is used elsewhere to enable optional extras on\n> systems which support them, I agree we should change to NEEDS_PATH_H to be\n> consistent.\n\nWell, things like NEEDS_LIBGEN or NEEDS_SSL_WITH_CRYPTO are about a few\nsystems that needs *extra* work.  I don't think NEEDS_PATH_H is a good\nvariable name.\n\n\n-- \nJakub Narebski\nPoland\n"},{"id":"139586","messageId":"20100415130101.GJ12365@arachsys.com","threadId":"23332","inReplyTo":"201004151458.02156.jnareb@gmail.com","subject":"Re: [PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-15T13:01:01Z","receivedAt":"2010-04-15T13:01:01Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Well, there is only one example of checking for _headers_, namely\n> NO_LIBGEN_H, so it is not that you are against some majority.\n> \n> In short: if there is no voice against HAVE_PATHS_H, lets have it this\n> way.\n\nOkay, sounds good to me. I'll respin with the style changes you suggested.\n\nBest wishes,\n\nChris.\n"},{"id":"139587","messageId":"81fdf71bae0e4d2abdae5740056b7fffb7683c54.1271337404.git.chris@arachsys.com","threadId":"23332","inReplyTo":"20100415130101.GJ12365@arachsys.com","subject":"[PATCH v4] Replace hard-coded path with one from <paths.h>","fromName":"Chris Webb","fromEmail":"chris@arachsys.com","sentAt":"2010-04-15T13:21:45Z","receivedAt":"2010-04-15T13:21:45Z","isPatch":true,"sender":{"key":"chris@arachsys.com","avatar":"https://avatars.githubusercontent.com/u/299056?v=4"},"body":"In exec_cmd.c, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin.\nGet an appropriate value for the system from <paths.h> if possible instead. We\nonly try to include <paths.h> on Linux, FreeBSD, NetBSD, OpenBSD and GNU where\nit is known to exist.\n\nSigned-off-by: Chris Webb <chris@arachsys.com>\n---\n Makefile          |   13 +++++++++++++\n exec_cmd.c        |    2 +-\n git-compat-util.h |    7 +++++++\n 3 files changed, 21 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 910f471..81aa2ba 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -31,6 +31,9 @@ all::\n # Define EXPATDIR=/foo/bar if your expat header and library files are in\n # /foo/bar/include and /foo/bar/lib directories.\n #\n+# Define HAVE_PATHS_H if you have paths.h and want to use the default PATH\n+# it specifies.\n+#\n # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.\n #\n # Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks\n@@ -735,10 +738,12 @@ EXTLIBS =\n ifeq ($(uname_S),Linux)\n \tNO_STRLCPY = YesPlease\n \tNO_MKSTEMPS = YesPlease\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),GNU/kFreeBSD)\n \tNO_STRLCPY = YesPlease\n \tNO_MKSTEMPS = YesPlease\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),UnixWare)\n \tCC = cc\n@@ -867,6 +872,7 @@ ifeq ($(uname_S),FreeBSD)\n \t\tNO_STRTOUMAX = YesPlease\n \tendif\n \tPYTHON_PATH = /usr/local/bin/python\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),OpenBSD)\n \tNO_STRCASESTR = YesPlease\n@@ -875,6 +881,7 @@ ifeq ($(uname_S),OpenBSD)\n \tNEEDS_LIBICONV = YesPlease\n \tBASIC_CFLAGS += -I/usr/local/include\n \tBASIC_LDFLAGS += -L/usr/local/lib\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),NetBSD)\n \tifeq ($(shell expr \"$(uname_R)\" : '[01]\\.'),2)\n@@ -884,6 +891,7 @@ ifeq ($(uname_S),NetBSD)\n \tBASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib\n \tUSE_ST_TIMESPEC = YesPlease\n \tNO_MKSTEMPS = YesPlease\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),AIX)\n \tNO_STRCASESTR=YesPlease\n@@ -904,6 +912,7 @@ ifeq ($(uname_S),GNU)\n \t# GNU/Hurd\n \tNO_STRLCPY=YesPlease\n \tNO_MKSTEMPS = YesPlease\n+\tHAVE_PATHS_H = YesPlease\n endif\n ifeq ($(uname_S),IRIX)\n \tNO_SETENV = YesPlease\n@@ -1353,6 +1362,10 @@ else\n \tLIB_OBJS += thread-utils.o\n endif\n \n+ifdef HAVE_PATHS_H\n+\tBASIC_CFLAGS += -DHAVE_PATHS_H\n+endif\n+\n ifdef DIR_HAS_BSD_GROUP_SEMANTICS\n \tCOMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS\n endif\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex b2c07c7..bf22570 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -107,7 +107,7 @@ void setup_path(void)\n \tif (old_path)\n \t\tstrbuf_addstr(&new_path, old_path);\n \telse\n-\t\tstrbuf_addstr(&new_path, \"/usr/local/bin:/usr/bin:/bin\");\n+\t\tstrbuf_addstr(&new_path, _PATH_DEFPATH);\n \n \tsetenv(\"PATH\", new_path.buf, 1);\n \ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 7e62b55..92c2182 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -164,6 +164,13 @@ extern char *gitbasename(char *);\n #define PATH_SEP ':'\n #endif\n \n+#ifdef HAVE_PATHS_H\n+#include <paths.h>\n+#endif\n+#ifndef _PATH_DEFPATH\n+#define _PATH_DEFPATH \"/usr/local/bin:/usr/bin:/bin\"\n+#endif\n+\n #ifndef STRIP_EXTENSION\n #define STRIP_EXTENSION \"\"\n #endif\n-- \n1.7.0.3\n"},{"id":"139614","messageId":"7v633sjznr.fsf@alter.siamese.dyndns.org","threadId":"23332","inReplyTo":"m3d3y0gath.fsf@localhost.localdomain","subject":"Re: [PATCH v3] Replace hard-coded path with one from <paths.h>","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-15T19:15:04Z","receivedAt":"2010-04-15T19:15:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>> \n>> Ok.  Somebody else may want to add an autoconf support on top of this, but\n>> this is good as-is, I think.\n>\n> Something like that?\n\nLooks good.\n"}]}