Skip to content

Commit 455bda9

Browse files
committed
Merge branch 'cw/maint-exec-defpath'
* 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 1bdd46c + bb15e38 commit 455bda9

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
@@ -739,10 +742,12 @@ EXTLIBS =
739742
ifeq ($(uname_S),Linux)
740743
NO_STRLCPY = YesPlease
741744
NO_MKSTEMPS = YesPlease
745+
HAVE_PATHS_H = YesPlease
742746
endif
743747
ifeq ($(uname_S),GNU/kFreeBSD)
744748
NO_STRLCPY = YesPlease
745749
NO_MKSTEMPS = YesPlease
750+
HAVE_PATHS_H = YesPlease
746751
endif
747752
ifeq ($(uname_S),UnixWare)
748753
CC = cc
@@ -871,6 +876,7 @@ ifeq ($(uname_S),FreeBSD)
871876
NO_STRTOUMAX = YesPlease
872877
endif
873878
PYTHON_PATH = /usr/local/bin/python
879+
HAVE_PATHS_H = YesPlease
874880
endif
875881
ifeq ($(uname_S),OpenBSD)
876882
NO_STRCASESTR = YesPlease
@@ -879,6 +885,7 @@ ifeq ($(uname_S),OpenBSD)
879885
NEEDS_LIBICONV = YesPlease
880886
BASIC_CFLAGS += -I/usr/local/include
881887
BASIC_LDFLAGS += -L/usr/local/lib
888+
HAVE_PATHS_H = YesPlease
882889
endif
883890
ifeq ($(uname_S),NetBSD)
884891
ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2)
@@ -888,6 +895,7 @@ ifeq ($(uname_S),NetBSD)
888895
BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
889896
USE_ST_TIMESPEC = YesPlease
890897
NO_MKSTEMPS = YesPlease
898+
HAVE_PATHS_H = YesPlease
891899
endif
892900
ifeq ($(uname_S),AIX)
893901
NO_STRCASESTR=YesPlease
@@ -908,6 +916,7 @@ ifeq ($(uname_S),GNU)
908916
# GNU/Hurd
909917
NO_STRLCPY=YesPlease
910918
NO_MKSTEMPS = YesPlease
919+
HAVE_PATHS_H = YesPlease
911920
endif
912921
ifeq ($(uname_S),IRIX)
913922
NO_SETENV = YesPlease
@@ -1357,6 +1366,10 @@ else
13571366
LIB_OBJS += thread-utils.o
13581367
endif
13591368

1369+
ifdef HAVE_PATHS_H
1370+
BASIC_CFLAGS += -DHAVE_PATHS_H
1371+
endif
1372+
13601373
ifdef DIR_HAS_BSD_GROUP_SEMANTICS
13611374
COMPAT_CFLAGS += -DDIR_HAS_BSD_GROUP_SEMANTICS
13621375
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)