Skip to content

Commit 7e74a73

Browse files
committed
Merge branch 'cw/maint-exec-defpath' into maint
* cw/maint-exec-defpath: autoconf: Check if <paths.h> exists and set HAVE_PATHS_H exec_cmd.c: replace hard-coded path list with one from <paths.h>
2 parents 356169c + bb15e38 commit 7e74a73

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ all::
3131
# Define EXPATDIR=/foo/bar if your expat header and library files are in
3232
# /foo/bar/include and /foo/bar/lib directories.
3333
#
34+
# Define HAVE_PATHS_H if you have paths.h and want to use the default PATH
35+
# it specifies.
36+
#
3437
# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
3538
#
3639
# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
@@ -735,10 +738,12 @@ EXTLIBS =
735738
ifeq ($(uname_S),Linux)
736739
NO_STRLCPY = YesPlease
737740
NO_MKSTEMPS = YesPlease
741+
HAVE_PATHS_H = YesPlease
738742
endif
739743
ifeq ($(uname_S),GNU/kFreeBSD)
740744
NO_STRLCPY = YesPlease
741745
NO_MKSTEMPS = YesPlease
746+
HAVE_PATHS_H = YesPlease
742747
endif
743748
ifeq ($(uname_S),UnixWare)
744749
CC = cc
@@ -867,6 +872,7 @@ ifeq ($(uname_S),FreeBSD)
867872
NO_STRTOUMAX = YesPlease
868873
endif
869874
PYTHON_PATH = /usr/local/bin/python
875+
HAVE_PATHS_H = YesPlease
870876
endif
871877
ifeq ($(uname_S),OpenBSD)
872878
NO_STRCASESTR = YesPlease
@@ -875,6 +881,7 @@ ifeq ($(uname_S),OpenBSD)
875881
NEEDS_LIBICONV = YesPlease
876882
BASIC_CFLAGS += -I/usr/local/include
877883
BASIC_LDFLAGS += -L/usr/local/lib
884+
HAVE_PATHS_H = YesPlease
878885
endif
879886
ifeq ($(uname_S),NetBSD)
880887
ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
@@ -884,6 +891,7 @@ ifeq ($(uname_S),NetBSD)
884891
BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
885892
USE_ST_TIMESPEC = YesPlease
886893
NO_MKSTEMPS = YesPlease
894+
HAVE_PATHS_H = YesPlease
887895
endif
888896
ifeq ($(uname_S),AIX)
889897
DEFAULT_PAGER = more
@@ -905,6 +913,7 @@ ifeq ($(uname_S),GNU)
905913
# GNU/Hurd
906914
NO_STRLCPY=YesPlease
907915
NO_MKSTEMPS = YesPlease
916+
HAVE_PATHS_H = YesPlease
908917
endif
909918
ifeq ($(uname_S),IRIX)
910919
NO_SETENV = YesPlease
@@ -1354,6 +1363,10 @@ else
13541363
LIB_OBJS += thread-utils.o
13551364
endif
13561365

1366+
ifdef HAVE_PATHS_H
1367+
BASIC_CFLAGS += -DHAVE_PATHS_H
1368+
endif
1369+
13571370
ifdef DIR_HAS_BSD_GROUP_SEMANTICS
13581371
COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
13591372
endif

config.mak.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ NO_OPENSSL=@NO_OPENSSL@
3131
NO_CURL=@NO_CURL@
3232
NO_EXPAT=@NO_EXPAT@
3333
NO_LIBGEN_H=@NO_LIBGEN_H@
34+
HAVE_PATHS_H=@HAVE_PATHS_H@
3435
NEEDS_LIBICONV=@NEEDS_LIBICONV@
3536
NEEDS_SOCKET=@NEEDS_SOCKET@
3637
NEEDS_RESOLV=@NEEDS_RESOLV@

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,12 @@ AC_CHECK_HEADER([libgen.h],
724724
[NO_LIBGEN_H=YesPlease])
725725
AC_SUBST(NO_LIBGEN_H)
726726
#
727+
# Define HAVE_PATHS_H if you have paths.h.
728+
AC_CHECK_HEADER([paths.h],
729+
[HAVE_PATHS_H=YesPlease],
730+
[HAVE_PATHS_H=])
731+
AC_SUBST(HAVE_PATHS_H)
732+
#
727733
# Define NO_STRCASESTR if you don't have strcasestr.
728734
GIT_CHECK_FUNC(strcasestr,
729735
[NO_STRCASESTR=],

exec_cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void setup_path(void)
107107
if (old_path)
108108
strbuf_addstr(&new_path, old_path);
109109
else
110-
strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin");
110+
strbuf_addstr(&new_path, _PATH_DEFPATH);
111111

112112
setenv("PATH", new_path.buf, 1);
113113

git-compat-util.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ extern char *gitbasename(char *);
164164
#define PATH_SEP ':'
165165
#endif
166166

167+
#ifdef HAVE_PATHS_H
168+
#include <paths.h>
169+
#endif
170+
#ifndef _PATH_DEFPATH
171+
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
172+
#endif
173+
167174
#ifndef STRIP_EXTENSION
168175
#define STRIP_EXTENSION ""
169176
#endif

0 commit comments

Comments
 (0)