{"thread":{"id":"47346","subject":"[PATCH v4 1/4] Makefile: generate Perl header from template file","startedAt":"2017-11-29T15:56:52Z","lastAt":"2018-04-24T02:57:06Z","messageCount":34,"participants":["Dan Jacques","Ævar Arnfjörð Bjarmason","Johannes Sixt","Johannes Schindelin","Andreas Schwab","Junio C Hamano","Daniel Jacques","Jonathan Nieder"],"isPatch":true,"patchVersion":4,"patchTotal":4},"messages":[{"id":"333785","messageId":"20171129155637.89075-2-dnj@google.com","threadId":"47346","inReplyTo":"20171129155637.89075-1-dnj@google.com","subject":"[PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-29T15:56:34Z","receivedAt":"2017-11-29T15:56:52Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Currently, the generated Perl script headers are emitted by commands in\nthe Makefile. This mechanism restricts options to introduce alternative\nheader content, needed by Perl runtime prefix support, and obscures the\norigin of the Perl script header.\n\nChange the Makefile to generate a header by processing a template file and\nmove the header content into the \"perl/\" subdirectory. The processed\ngenerated will now be stored in the \"GIT-PERL-HEADER\" file. This allows\nthe content of the Perl header to be controlled by changing the path of\nthe template in the Makefile.\n\nSigned-off-by: Dan Jacques <dnj@google.com>\nThanks-to: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nThanks-to: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n .gitignore                           |  1 +\n Makefile                             | 24 +++++++++++++++---------\n perl/header_fixed_prefix.pl.template |  1 +\n 3 files changed, 17 insertions(+), 9 deletions(-)\n create mode 100644 perl/header_fixed_prefix.pl.template\n\ndiff --git a/.gitignore b/.gitignore\nindex 833ef3b0b..89bd7bd8a 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -3,6 +3,7 @@\n /GIT-LDFLAGS\n /GIT-PREFIX\n /GIT-PERL-DEFINES\n+/GIT-PERL-HEADER\n /GIT-PYTHON-VARS\n /GIT-SCRIPT-DEFINES\n /GIT-USER-AGENT\ndiff --git a/Makefile b/Makefile\nindex e53750ca0..f7c4ac207 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1964,18 +1964,15 @@ perl/PM.stamp: FORCE\n perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n \t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)\n \n+PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template\n PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)\n-$(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-VERSION-FILE\n+\n+$(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n-\tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \\\n-\tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n-\tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e '1{' \\\n \t    -e '\ts|#!.*perl|#!$(PERL_PATH_SQ)|' \\\n-\t    -e '\th' \\\n-\t    -e '\ts=.*=use lib (split(/$(pathsep)/, $$ENV{GITPERLLIB} || \"'\"$$INSTLIBDIR\"'\"));=' \\\n-\t    -e '\tH' \\\n-\t    -e '\tx' \\\n+\t    -e '\trGIT-PERL-HEADER' \\\n+\t    -e '\tG' \\\n \t    -e '}' \\\n \t    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n \t    $< >$@+ && \\\n@@ -1989,6 +1986,15 @@ GIT-PERL-DEFINES: FORCE\n \t\techo \"$$FLAGS\" >$@; \\\n \t    fi\n \n+GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n+\t$(QUIET_GEN)$(RM) $@ && \\\n+\tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \\\n+\tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n+\tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n+\tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n+\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n+\t    $< >$@+ && \\\n+\tmv $@+ $@\n \n .PHONY: gitweb\n gitweb:\n@@ -2707,7 +2713,7 @@ ifndef NO_TCLTK\n endif\n \t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS\n \t$(RM) GIT-USER-AGENT GIT-PREFIX\n-\t$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PYTHON-VARS\n+\t$(RM) GIT-SCRIPT-DEFINES GIT-PERL-DEFINES GIT-PERL-HEADER GIT-PYTHON-VARS\n \n .PHONY: all install profile-clean clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\ndiff --git a/perl/header_fixed_prefix.pl.template b/perl/header_fixed_prefix.pl.template\nnew file mode 100644\nindex 000000000..9a4bc4d30\n--- /dev/null\n+++ b/perl/header_fixed_prefix.pl.template\n@@ -0,0 +1 @@\n+use lib (split(/@@PATHSEP@@/, $ENV{GITPERLLIB} || \"@@INSTLIBDIR@@\"));\n-- \n2.15.0.chromium12\n\n"},{"id":"333786","messageId":"20171129155637.89075-1-dnj@google.com","threadId":"47346","inReplyTo":null,"subject":"[PATCH v4 0/4] RUNTIME_PREFIX relocatable Git","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-29T15:56:33Z","receivedAt":"2017-11-29T15:56:55Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Previous threads:\nv1: https://public-inbox.org/git/20171116170523.28696-1-dnj@google.com/\nv2: https://public-inbox.org/git/20171119173141.4896-1-dnj@google.com/\nv3: https://public-inbox.org/git/20171127164055.93283-1-dnj@google.com/\n\nThis is a small update to incorporate some Windows fixes from Johannes.\nAt this point, it passes the full test suite on Linux, Mac, and FreeBSD,\nas well as the Travis.ci test suites, with and without\nRUNTIME_PREFIX/RUNTIME_PREFIX_PERL flags.\n\nI'm happy with the patch set, and feel that it is ready to move forward.\nHowever, while it's been looked at by several people, and I have\nincorporated reviewer feedback, the patch set hasn't received any formal\nLGTM-style responses yet. I'm not sure what standard of review is required\nto move forward with a patch on this project, so maybe this is totally\nfine, but I wanted to make sure to point this out.\n\nI also want to note Ævar Arnfjörð Bjarmason's RFC:\nhttps://public-inbox.org/git/20171129153436.24471-1-avarab@gmail.com/T/\n\nThe proposed patch set conflicts with the Perl installation directory\nchanges in this patch set, as avarab@ notes. The proposed Perl installation\nprocess would simplify patch 0002 in this patch set. I don't think the\nlanding order is terribly impactful - if this lands first, the patch in the\nRFC would delete a few more lines, and if this lands later, patch 0002\nwould largely not be necessary.\n\nCheers,\n-Dan\n\nBuilt using this \"config.mak\" w/ autoconf:\n\n=== BEGIN config.mak ===\n\nRUNTIME_PREFIX = YesPlease\nRUNTIME_PREFIX_PERL = YesPlease\ngitexecdir = libexec/git-core\ntemplate_dir = share/git-core/templates\nsysconfdir = etc\n\n=== END config.mak ===\n\nChanges in v4 from v3:\n\n- Incorporated some quoting and Makefile dependency fixes, courtesy of\n  <johannes.schindelin@gmx.de>.\n\nChanges in v3 from v2:\n\n- Broken into multiple patches now that Perl is isolated in its own\n  RUNTIME_PREFIX_PERL flag.\n- Working with avarab@, several changes to Perl script runtime prefix\n  support:\n  - Moved Perl header body content from Makefile into external template\n    file(s).\n  - Added generic \"perllibdir\" variable to override Perl installation\n    path.\n  - RUNTIME_PREFIX_PERL generated script header is more descriptive and\n    consistent with how the C version operates.\n  - Fixed Generated Perl header Makefile dependency, should rebuild\n    when dependent files and flags change.\n- Changed some of the new RUNTIME_PREFIX trace strings to use consistent\n  formatting and terminology.\n\nChanges in v2 from v1:\n\n- Added comments and formatting to improve readability of\n  platform-sepecific executable path resolution sleds in\n  `git_get_exec_path`.\n- Consolidated \"cached_exec_path\" and \"argv_exec_path\" globals\n  into \"exec_path_value\".\n- Use `strbuf_realpath` instead of `realpath` for procfs resolution.\n- Removed new environment variable exports. Git with RUNTIME_PREFIX no\n  longer exports or consumes any additional environment information.\n- Updated Perl script resolution strategy: rather than having Git export\n  the relative executable path to the Perl scripts, they now resolve\n  it independently when RUNTIME_PREFIX_PERL is enabled.\n- Updated resolution strategy for \"gettext()\": use system_path() instead\n  of special environment variable.\n- Added `sysctl` executable resolution support for BSDs that don't\n  mount \"procfs\" by default (most of them).\n\nDan Jacques (4):\n  Makefile: generate Perl header from template file\n  Makefile: add support for \"perllibdir\"\n  Makefile: add Perl runtime prefix support\n  exec_cmd: RUNTIME_PREFIX on some POSIX systems\n\n .gitignore                             |   1 +\n Makefile                               | 111 +++++++++++++--\n cache.h                                |   1 +\n common-main.c                          |   4 +-\n config.mak.uname                       |   7 +\n exec_cmd.c                             | 239 ++++++++++++++++++++++++++++-----\n exec_cmd.h                             |   4 +-\n gettext.c                              |   8 +-\n git.c                                  |   2 +-\n perl/Makefile                          |  52 ++++++-\n perl/header_fixed_prefix.pl.template   |   1 +\n perl/header_runtime_prefix.pl.template |  24 ++++\n 12 files changed, 396 insertions(+), 58 deletions(-)\n create mode 100644 perl/header_fixed_prefix.pl.template\n create mode 100644 perl/header_runtime_prefix.pl.template\n\n-- \n2.15.0.chromium12\n\n"},{"id":"333787","messageId":"20171129155637.89075-5-dnj@google.com","threadId":"47346","inReplyTo":"20171129155637.89075-1-dnj@google.com","subject":"[PATCH v4 4/4] exec_cmd: RUNTIME_PREFIX on some POSIX systems","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-29T15:56:37Z","receivedAt":"2017-11-29T15:56:58Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Enable Git to resolve its own binary location using a variety of\nOS-specific and generic methods, including:\n\n- procfs via \"/proc/self/exe\" (Linux)\n- _NSGetExecutablePath (Darwin)\n- KERN_PROC_PATHNAME sysctl on BSDs.\n- argv0, if absolute (all, including Windows).\n\nThis is used to enable RUNTIME_PREFIX support for non-Windows systems,\nnotably Linux and Darwin. When configured with RUNTIME_PREFIX, Git will\ndo a best-effort resolution of its executable path and automatically use\nthis as its \"exec_path\" for relative helper and data lookups, unless\nexplicitly overridden.\n\nSmall incidental formatting cleanup of \"exec_cmd.c\".\n\nSigned-off-by: Dan Jacques <dnj@google.com>\nThanks-to: Robbie Iannucci <iannucci@google.com>\nThanks-to: Junio C Hamano <gitster@pobox.com>\n---\n Makefile         |  35 +++++++-\n cache.h          |   1 +\n common-main.c    |   4 +-\n config.mak.uname |   7 ++\n exec_cmd.c       | 239 +++++++++++++++++++++++++++++++++++++++++++++++--------\n exec_cmd.h       |   4 +-\n gettext.c        |   8 +-\n git.c            |   2 +-\n 8 files changed, 260 insertions(+), 40 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 741d1583f..e663fda1f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -416,6 +416,16 @@ all::\n #\n # Define HAVE_BSD_SYSCTL if your platform has a BSD-compatible sysctl function.\n #\n+# Define HAVE_BSD_KERN_PROC_SYSCTL if your platform supports the KERN_PROC BSD\n+# sysctl function.\n+#\n+# Define PROCFS_EXECUTABLE_PATH if your platform mounts a \"procfs\" filesystem\n+# capable of resolving the path of the current executable. If defined, this\n+# must be the canonical path for the \"procfs\" current executable path.\n+#\n+# Define HAVE_NS_GET_EXECUTABLE_PATH if your platform supports calling\n+# _NSGetExecutablePath to retrieve the path of the running executable.\n+#\n # Define HAVE_GETDELIM if your system has the getdelim() function.\n #\n # Define PAGER_ENV to a SP separated VAR=VAL pairs to define\n@@ -426,6 +436,12 @@ all::\n # to say \"export LESS=FRX (and LV=-c) if the environment variable\n # LESS (and LV) is not set, respectively\".\n #\n+# Define RUNTIME_PREFIX to configure Git to resolve its ancillary tooling and\n+# support files relative to the location of the runtime binary, rather than\n+# hard-coding them into the binary. Git installations built with RUNTIME_PREFIX\n+# can be moved to arbitrary filesystem locations. Users may want to enable\n+# RUNTIME_PREFIX_PERL as well (see below).\n+#\n # Define RUNTIME_PREFIX_PERL to configure Git's PERL commands to locate Git\n # support libraries relative to their filesystem path instead of hard-coding\n # it.\n@@ -466,6 +482,7 @@ ARFLAGS = rcs\n #   mandir\n #   infodir\n #   htmldir\n+#   localedir\n #   perllibdir\n # This can help installing the suite in a relocatable way.\n \n@@ -491,6 +508,7 @@ mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))\n infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))\n sharedir_relative = $(patsubst $(prefix)/%,%,$(sharedir))\n htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))\n+localedir_relative = $(patsubst $(prefix)/%,%,$(localedir))\n \n export prefix bindir sharedir sysconfdir gitwebdir localedir\n \n@@ -1637,10 +1655,23 @@ ifdef HAVE_BSD_SYSCTL\n \tBASIC_CFLAGS += -DHAVE_BSD_SYSCTL\n endif\n \n+ifdef HAVE_BSD_KERN_PROC_SYSCTL\n+\tBASIC_CFLAGS += -DHAVE_BSD_KERN_PROC_SYSCTL\n+endif\n+\n ifdef HAVE_GETDELIM\n \tBASIC_CFLAGS += -DHAVE_GETDELIM\n endif\n \n+ifneq ($(PROCFS_EXECUTABLE_PATH),)\n+\tprocfs_executable_path_SQ = $(subst ','\\'',$(PROCFS_EXECUTABLE_PATH))\n+\tBASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH=\"$(procfs_executable_path_SQ)\"'\n+endif\n+\n+ifdef HAVE_NS_GET_EXECUTABLE_PATH\n+\tBASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH\n+endif\n+\n ifeq ($(TCLTK_PATH),)\n NO_TCLTK = NoThanks\n endif\n@@ -1723,6 +1754,7 @@ bindir_relative_SQ = $(subst ','\\'',$(bindir_relative))\n mandir_relative_SQ = $(subst ','\\'',$(mandir_relative))\n infodir_relative_SQ = $(subst ','\\'',$(infodir_relative))\n localedir_SQ = $(subst ','\\'',$(localedir))\n+localedir_relative_SQ = $(subst ','\\'',$(localedir_relative))\n gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n htmldir_relative_SQ = $(subst ','\\'',$(htmldir_relative))\n@@ -2185,6 +2217,7 @@ endif\n exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX\n exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n+\t'-DGIT_LOCALE_PATH=\"$(localedir_relative_SQ)\"' \\\n \t'-DBINDIR=\"$(bindir_relative_SQ)\"' \\\n \t'-DPREFIX=\"$(prefix_SQ)\"'\n \n@@ -2202,7 +2235,7 @@ attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \\\n \n gettext.sp gettext.s gettext.o: GIT-PREFIX\n gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \\\n-\t-DGIT_LOCALE_PATH='\"$(localedir_SQ)\"'\n+\t-DGIT_LOCALE_PATH='\"$(localedir_relative_SQ)\"'\n \n http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SPARSE_FLAGS += \\\n \t-DCURL_DISABLE_TYPECHECK\ndiff --git a/cache.h b/cache.h\nindex 2e1434505..3d84aa0bf 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -449,6 +449,7 @@ static inline enum object_type object_type(unsigned int mode)\n #define GIT_ICASE_PATHSPECS_ENVIRONMENT \"GIT_ICASE_PATHSPECS\"\n #define GIT_QUARANTINE_ENVIRONMENT \"GIT_QUARANTINE_PATH\"\n #define GIT_OPTIONAL_LOCKS_ENVIRONMENT \"GIT_OPTIONAL_LOCKS\"\n+#define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT \"GIT_TEXTDOMAINDIR\"\n \n /*\n  * This environment variable is expected to contain a boolean indicating\ndiff --git a/common-main.c b/common-main.c\nindex 6a689007e..6516a1f89 100644\n--- a/common-main.c\n+++ b/common-main.c\n@@ -32,12 +32,12 @@ int main(int argc, const char **argv)\n \t */\n \tsanitize_stdfds();\n \n+\tgit_resolve_executable_dir(argv[0]);\n+\n \tgit_setup_gettext();\n \n \tattr_start();\n \n-\tgit_extract_argv0_path(argv[0]);\n-\n \trestore_sigpipe_to_default();\n \n \treturn cmd_main(argc, argv);\ndiff --git a/config.mak.uname b/config.mak.uname\nindex 685a80d13..58fd62b4d 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -37,6 +37,7 @@ ifeq ($(uname_S),Linux)\n \tHAVE_GETDELIM = YesPlease\n \tSANE_TEXT_GREP=-a\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n+\tPROCFS_EXECUTABLE_PATH = /proc/self/exe\n endif\n ifeq ($(uname_S),GNU/kFreeBSD)\n \tHAVE_ALLOCA_H = YesPlease\n@@ -111,6 +112,7 @@ ifeq ($(uname_S),Darwin)\n \tBASIC_CFLAGS += -DPROTECT_HFS_DEFAULT=1\n \tHAVE_BSD_SYSCTL = YesPlease\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n+\tHAVE_NS_GET_EXECUTABLE_PATH = YesPlease\n endif\n ifeq ($(uname_S),SunOS)\n \tNEEDS_SOCKET = YesPlease\n@@ -206,6 +208,7 @@ ifeq ($(uname_S),FreeBSD)\n \tHAVE_PATHS_H = YesPlease\n \tGMTIME_UNRELIABLE_ERRORS = UnfortunatelyYes\n \tHAVE_BSD_SYSCTL = YesPlease\n+\tHAVE_BSD_KERN_PROC_SYSCTL = YesPlease\n \tPAGER_ENV = LESS=FRX LV=-c MORE=FRX\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n endif\n@@ -218,6 +221,8 @@ ifeq ($(uname_S),OpenBSD)\n \tBASIC_LDFLAGS += -L/usr/local/lib\n \tHAVE_PATHS_H = YesPlease\n \tHAVE_BSD_SYSCTL = YesPlease\n+\tHAVE_BSD_KERN_PROC_SYSCTL = YesPlease\n+\tPROCFS_EXECUTABLE_PATH = /proc/curproc/file\n endif\n ifeq ($(uname_S),MirBSD)\n \tNO_STRCASESTR = YesPlease\n@@ -236,6 +241,8 @@ ifeq ($(uname_S),NetBSD)\n \tUSE_ST_TIMESPEC = YesPlease\n \tHAVE_PATHS_H = YesPlease\n \tHAVE_BSD_SYSCTL = YesPlease\n+\tHAVE_BSD_KERN_PROC_SYSCTL = YesPlease\n+\tPROCFS_EXECUTABLE_PATH = /proc/curproc/exe\n endif\n ifeq ($(uname_S),AIX)\n \tDEFAULT_PAGER = more\ndiff --git a/exec_cmd.c b/exec_cmd.c\nindex ce192a2d6..c9006c4c9 100644\n--- a/exec_cmd.c\n+++ b/exec_cmd.c\n@@ -2,53 +2,232 @@\n #include \"exec_cmd.h\"\n #include \"quote.h\"\n #include \"argv-array.h\"\n-#define MAX_ARGS\t32\n \n-static const char *argv_exec_path;\n+#if defined(RUNTIME_PREFIX)\n+\n+#if defined(HAVE_NS_GET_EXECUTABLE_PATH)\n+#include <mach-o/dyld.h>\n+#endif\n+\n+#if defined(HAVE_BSD_KERN_PROC_SYSCTL)\n+#include <sys/param.h>\n+#include <sys/types.h>\n+#include <sys/sysctl.h>\n+#endif\n+\n+#endif /* RUNTIME_PREFIX */\n+\n+#define MAX_ARGS 32\n+\n+static const char *system_prefix(void);\n \n #ifdef RUNTIME_PREFIX\n-static const char *argv0_path;\n+\n+/**\n+ * When using a runtime prefix, Git dynamically resolves paths relative to its\n+ * executable.\n+ *\n+ * The method for determining the path of the executable is highly\n+ * platform-specific.\n+ */\n+\n+/**\n+ * Path to the current Git executable. Resolved on startup by\n+ * 'git_resolve_executable_dir'.\n+ */\n+static const char *executable_dirname;\n \n static const char *system_prefix(void)\n {\n \tstatic const char *prefix;\n \n-\tassert(argv0_path);\n-\tassert(is_absolute_path(argv0_path));\n+\tassert(executable_dirname);\n+\tassert(is_absolute_path(executable_dirname));\n \n \tif (!prefix &&\n-\t    !(prefix = strip_path_suffix(argv0_path, GIT_EXEC_PATH)) &&\n-\t    !(prefix = strip_path_suffix(argv0_path, BINDIR)) &&\n-\t    !(prefix = strip_path_suffix(argv0_path, \"git\"))) {\n+\t    !(prefix = strip_path_suffix(executable_dirname, GIT_EXEC_PATH)) &&\n+\t    !(prefix = strip_path_suffix(executable_dirname, BINDIR)) &&\n+\t    !(prefix = strip_path_suffix(executable_dirname, \"git\"))) {\n \t\tprefix = PREFIX;\n \t\ttrace_printf(\"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\t\t     \"but prefix computation failed.  \"\n+\t\t\t     \"Using static fallback '%s'.\\n\",\n+\t\t\t     prefix);\n \t}\n \treturn prefix;\n }\n \n-void git_extract_argv0_path(const char *argv0)\n+/*\n+ * Resolves the executable path from argv[0], only if it is absolute.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_from_argv0(struct strbuf *buf, const char *argv0)\n {\n \tconst char *slash;\n \n \tif (!argv0 || !*argv0)\n-\t\treturn;\n+\t\treturn -1;\n \n \tslash = find_last_dir_sep(argv0);\n+\tif (slash) {\n+\t\ttrace_printf(\"trace: resolved executable path from argv0: %s\\n\",\n+\t\t\t     argv0);\n+\t\tstrbuf_add_absolute_path(buf, argv0);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+\n+#ifdef PROCFS_EXECUTABLE_PATH\n+/*\n+ * Resolves the executable path by examining a procfs symlink.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_procfs(struct strbuf *buf)\n+{\n+\tif (strbuf_realpath(buf, PROCFS_EXECUTABLE_PATH, 0)) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: resolved executable path from procfs: %s\\n\",\n+\t\t\tbuf->buf);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+#endif /* PROCFS_EXECUTABLE_PATH */\n+\n+#ifdef HAVE_BSD_KERN_PROC_SYSCTL\n+/*\n+ * Resolves the executable path using KERN_PROC_PATHNAME BSD sysctl.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_bsd_sysctl(struct strbuf *buf)\n+{\n+\tint mib[4];\n+\tchar path[MAXPATHLEN];\n+\tsize_t cb = sizeof(path);\n+\n+\tmib[0] = CTL_KERN;\n+\tmib[1] = KERN_PROC;\n+\tmib[2] = KERN_PROC_PATHNAME;\n+\tmib[3] = -1;\n+\tif (!sysctl(mib, 4, path, &cb, NULL, 0)) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: resolved executable path from sysctl: %s\\n\",\n+\t\t\tpath);\n+\t\tstrbuf_addstr(buf, path);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+#endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n+\n+#ifdef HAVE_NS_GET_EXECUTABLE_PATH\n+/*\n+ * Resolves the executable path by querying Darwin applicaton stack.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path_darwin(struct strbuf *buf)\n+{\n+\tchar path[PATH_MAX];\n+\tuint32_t size = sizeof(path);\n+\tif (!_NSGetExecutablePath(path, &size)) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: resolved executable path from Darwin stack: %s\\n\",\n+\t\t\tpath);\n+\t\tstrbuf_addstr(buf, path);\n+\t\treturn 0;\n+\t}\n+\treturn -1;\n+}\n+#endif /* HAVE_NS_GET_EXECUTABLE_PATH */\n+\n+/*\n+ * Resolves the absolute path of the current executable.\n+ *\n+ * Returns 0 on success, -1 on failure.\n+ */\n+static int git_get_exec_path(struct strbuf *buf, const char *argv0)\n+{\n+\t/*\n+\t * Identifying the executable path is operating system specific.\n+\t * Selectively employ all available methods in order of preference,\n+\t * preferring highly-available authoratative methods over\n+\t * selectively-available or non- authoratative methods.\n+\t *\n+\t * All cases fall back on resolving against argv[0] if there isn't a\n+\t * better functional method. However, note that argv[0] can be\n+\t * used-supplied on many operating sysetems, and is not authoratative\n+\t * in those cases.\n+\t *\n+\t * Each of these functions returns 0 on success, so evaluation will stop\n+\t * after the first successful method.\n+\t */\n+\tif (\n+#ifdef HAVE_BSD_KERN_PROC_SYSCTL\n+\t\tgit_get_exec_path_bsd_sysctl(buf) &&\n+#endif /* HAVE_BSD_KERN_PROC_SYSCTL */\n+\n+#ifdef HAVE_NS_GET_EXECUTABLE_PATH\n+\t\tgit_get_exec_path_darwin(buf) &&\n+#endif /* HAVE_NS_GET_EXECUTABLE_PATH */\n+\n+#ifdef PROCFS_EXECUTABLE_PATH\n+\t\tgit_get_exec_path_procfs(buf) &&\n+#endif /* PROCFS_EXECUTABLE_PATH */\n+\n+\t\tgit_get_exec_path_from_argv0(buf, argv0)) {\n+\t\treturn -1;\n+\t}\n \n+\tif (strbuf_normalize_path(buf)) {\n+\t\ttrace_printf(\"trace: could not normalize path: %s\\n\", buf->buf);\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+void git_resolve_executable_dir(const char *argv0)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tchar *resolved;\n+\tconst char *slash;\n+\n+\tif (git_get_exec_path(&buf, argv0)) {\n+\t\ttrace_printf(\n+\t\t\t\"trace: could not determine executable path from: %s\\n\",\n+\t\t\targv0);\n+\t\tstrbuf_release(&buf);\n+\t\treturn;\n+\t}\n+\n+\tresolved = strbuf_detach(&buf, NULL);\n+\tslash = find_last_dir_sep(resolved);\n \tif (slash)\n-\t\targv0_path = xstrndup(argv0, slash - argv0);\n+\t\tresolved[slash - resolved] = '\\0';\n+\n+\texecutable_dirname = resolved;\n+\ttrace_printf(\"trace: resolved executable dir: %s\\n\",\n+\t\t     executable_dirname);\n }\n \n #else\n \n+/**\n+ * When not using a runtime prefix, Git uses a hard-coded path, and there is\n+ * nothing to resolve.\n+ */\n+\n static const char *system_prefix(void)\n {\n \treturn PREFIX;\n }\n \n-void git_extract_argv0_path(const char *argv0)\n+void git_resolve_executable_dir(const char *argv0)\n {\n }\n \n@@ -65,32 +244,28 @@ char *system_path(const char *path)\n \treturn strbuf_detach(&d, NULL);\n }\n \n-void git_set_argv_exec_path(const char *exec_path)\n+static const char *exec_path_value;\n+\n+void git_set_exec_path(const char *exec_path)\n {\n-\targv_exec_path = exec_path;\n+\texec_path_value = exec_path;\n \t/*\n \t * Propagate this setting to external programs.\n \t */\n \tsetenv(EXEC_PATH_ENVIRONMENT, exec_path, 1);\n }\n \n-\n-/* Returns the highest-priority, location to look for git programs. */\n+/* Returns the highest-priority location to look for git programs. */\n const char *git_exec_path(void)\n {\n-\tstatic char *cached_exec_path;\n-\n-\tif (argv_exec_path)\n-\t\treturn argv_exec_path;\n-\n-\tif (!cached_exec_path) {\n+\tif (!exec_path_value) {\n \t\tconst char *env = getenv(EXEC_PATH_ENVIRONMENT);\n \t\tif (env && *env)\n-\t\t\tcached_exec_path = xstrdup(env);\n+\t\t\texec_path_value = xstrdup(env);\n \t\telse\n-\t\t\tcached_exec_path = system_path(GIT_EXEC_PATH);\n+\t\t\texec_path_value = system_path(GIT_EXEC_PATH);\n \t}\n-\treturn cached_exec_path;\n+\treturn exec_path_value;\n }\n \n static void add_path(struct strbuf *out, const char *path)\n@@ -103,10 +278,12 @@ static void add_path(struct strbuf *out, const char *path)\n \n void setup_path(void)\n {\n+\tconst char *exec_path = git_exec_path();\n \tconst char *old_path = getenv(\"PATH\");\n \tstruct strbuf new_path = STRBUF_INIT;\n \n-\tadd_path(&new_path, git_exec_path());\n+\tgit_set_exec_path(exec_path);\n+\tadd_path(&new_path, exec_path);\n \n \tif (old_path)\n \t\tstrbuf_addstr(&new_path, old_path);\n@@ -125,7 +302,8 @@ const char **prepare_git_cmd(struct argv_array *out, const char **argv)\n \treturn out->argv;\n }\n \n-int execv_git_cmd(const char **argv) {\n+int execv_git_cmd(const char **argv)\n+{\n \tstruct argv_array nargv = ARGV_ARRAY_INIT;\n \n \tprepare_git_cmd(&nargv, argv);\n@@ -140,8 +318,7 @@ int execv_git_cmd(const char **argv) {\n \treturn -1;\n }\n \n-\n-int execl_git_cmd(const char *cmd,...)\n+int execl_git_cmd(const char *cmd, ...)\n {\n \tint argc;\n \tconst char *argv[MAX_ARGS + 1];\ndiff --git a/exec_cmd.h b/exec_cmd.h\nindex ff0b48048..2522453cd 100644\n--- a/exec_cmd.h\n+++ b/exec_cmd.h\n@@ -3,8 +3,8 @@\n \n struct argv_array;\n \n-extern void git_set_argv_exec_path(const char *exec_path);\n-extern void git_extract_argv0_path(const char *path);\n+extern void git_set_exec_path(const char *exec_path);\n+extern void git_resolve_executable_dir(const char *path);\n extern const char *git_exec_path(void);\n extern void setup_path(void);\n extern const char **prepare_git_cmd(struct argv_array *out, const char **argv);\ndiff --git a/gettext.c b/gettext.c\nindex db727ea02..6b64d5c2e 100644\n--- a/gettext.c\n+++ b/gettext.c\n@@ -2,7 +2,8 @@\n  * Copyright (c) 2010 Ævar Arnfjörð Bjarmason\n  */\n \n-#include \"git-compat-util.h\"\n+#include \"cache.h\"\n+#include \"exec_cmd.h\"\n #include \"gettext.h\"\n #include \"strbuf.h\"\n #include \"utf8.h\"\n@@ -157,10 +158,11 @@ static void init_gettext_charset(const char *domain)\n \n void git_setup_gettext(void)\n {\n-\tconst char *podir = getenv(\"GIT_TEXTDOMAINDIR\");\n+\tconst char *podir = getenv(GIT_TEXT_DOMAIN_DIR_ENVIRONMENT);\n \n \tif (!podir)\n-\t\tpodir = GIT_LOCALE_PATH;\n+\t\tpodir = system_path(GIT_LOCALE_PATH);\n+\n \tbindtextdomain(\"git\", podir);\n \tsetlocale(LC_MESSAGES, \"\");\n \tsetlocale(LC_TIME, \"\");\ndiff --git a/git.c b/git.c\nindex 9e96dd409..dc4cc1419 100644\n--- a/git.c\n+++ b/git.c\n@@ -65,7 +65,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t */\n \t\tif (skip_prefix(cmd, \"--exec-path\", &cmd)) {\n \t\t\tif (*cmd == '=')\n-\t\t\t\tgit_set_argv_exec_path(cmd + 1);\n+\t\t\t\tgit_set_exec_path(cmd + 1);\n \t\t\telse {\n \t\t\t\tputs(git_exec_path());\n \t\t\t\texit(0);\n-- \n2.15.0.chromium12\n\n"},{"id":"333788","messageId":"20171129155637.89075-4-dnj@google.com","threadId":"47346","inReplyTo":"20171129155637.89075-1-dnj@google.com","subject":"[PATCH v4 3/4] Makefile: add Perl runtime prefix support","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-29T15:56:36Z","receivedAt":"2017-11-29T15:57:01Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Add a new Makefile flag, RUNTIME_PREFIX_PERL, which, when enabled,\nconfigures Perl scripts to locate the Git installation's Perl support\nlibraries by resolving against the script's path, rather than\nhard-coding that path at build-time.\n\nEnabling RUNTIME_PREFIX_PERL overrides the system-specific Perl script\ninstallation path generated by MakeMaker to force installation into a\nplatform-neutral location, \"<prefix>/share/perl5\".\n\nThis change enables Git's Perl scripts to work when their Git installation\nis relocated or moved to another system.\n\nSigned-off-by: Dan Jacques <dnj@google.com>\nThanks-to: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nThanks-to: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Makefile                               | 40 +++++++++++++++++++++++++++++++++-\n perl/header_runtime_prefix.pl.template | 24 ++++++++++++++++++++\n 2 files changed, 63 insertions(+), 1 deletion(-)\n create mode 100644 perl/header_runtime_prefix.pl.template\n\ndiff --git a/Makefile b/Makefile\nindex 80904f8b0..741d1583f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -425,6 +425,10 @@ all::\n #\n # to say \"export LESS=FRX (and LV=-c) if the environment variable\n # LESS (and LV) is not set, respectively\".\n+#\n+# Define RUNTIME_PREFIX_PERL to configure Git's PERL commands to locate Git\n+# support libraries relative to their filesystem path instead of hard-coding\n+# it.\n \n GIT-VERSION-FILE: FORCE\n \t@$(SHELL_PATH) ./GIT-VERSION-GEN\n@@ -485,6 +489,7 @@ pathsep = :\n \n mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))\n infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))\n+sharedir_relative = $(patsubst $(prefix)/%,%,$(sharedir))\n htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))\n \n export prefix bindir sharedir sysconfdir gitwebdir localedir\n@@ -1967,7 +1972,38 @@ perl/PM.stamp: GIT-PERL-DEFINES FORCE\n PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template\n \n PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ)\n-PERL_DEFINES += $(NO_PERL_MAKEMAKER)\n+PERL_DEFINES += $(NO_PERL_MAKEMAKER) $(RUNTIME_PREFIX_PERL)\n+\n+# Support Perl runtime prefix. In this mode, a different header is installed\n+# into Perl scripts. This header expects both the scripts and their support\n+# library to be installed relative to $(prefix), and resolves the path to\n+# the Perl libraries (perllibdir) from the executable's current path\n+# (gitexecdir).\n+#\n+# This configuration requires both $(perllibdir) and $(gitexecdir) to be\n+# relative paths, and will error if this is not the case.\n+ifdef RUNTIME_PREFIX_PERL\n+\n+PERL_HEADER_TEMPLATE = perl/header_runtime_prefix.pl.template\n+PERL_DEFINES += $(gitexecdir)\n+\n+# RUNTIME_PREFIX_PERL requires a $(perllibdir) value.\n+ifeq ($(perllibdir),)\n+perllibdir = $(sharedir_relative)/perl5\n+endif\n+\n+ifneq ($(filter /%,$(firstword $(gitexecdir))),)\n+$(error RUNTIME_PREFIX_PERL requires a relative gitexecdir, not: $(gitexecdir))\n+endif\n+gitexecdir_relative_SQ = $(gitexecdir_SQ)\n+\n+ifneq ($(filter /%,$(firstword $(perllibdir))),)\n+$(error RUNTIME_PREFIX_PERL requires a relative perllibdir, not: $(perllibdir))\n+endif\n+perllibdir_relative_SQ = $(perllibdir_SQ)\n+\n+endif\n+\n PERL_DEFINES += $(perllibdir)\n \n perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n@@ -2001,6 +2037,8 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n \t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n+\t    -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n+\t    -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n \t    $< >$@+ && \\\n \tmv $@+ $@\n \ndiff --git a/perl/header_runtime_prefix.pl.template b/perl/header_runtime_prefix.pl.template\nnew file mode 100644\nindex 000000000..fb9a9924d\n--- /dev/null\n+++ b/perl/header_runtime_prefix.pl.template\n@@ -0,0 +1,24 @@\n+# BEGIN RUNTIME_PREFIX_PERL generated code.\n+#\n+# This finds our Git::* libraries relative to the script's runtime path.\n+BEGIN {\n+\tuse lib split /@@PATHSEP@@/,\n+\t(\n+\t\t$ENV{GITPERLLIB}\n+\t\t||\n+\t\tdo {\n+\t\t\trequire FindBin;\n+\t\t\trequire File::Spec;\n+\t\t\tmy $gitexecdir_relative = '@@GITEXECDIR@@';\n+\t\t\tmy $perllibdir_relative = '@@PERLLIBDIR@@';\n+\n+\t\t\t($FindBin::Bin =~ m=${gitexecdir_relative}$=) ||\n+\t\t\t    die('Unrecognized runtime path.');\n+\t\t\tmy $prefix = substr($FindBin::Bin, 0, -length($gitexecdir_relative));\n+\t\t\tmy $perllibdir = File::Spec->catdir($prefix, $perllibdir_relative);\n+\t\t\t(-e $perllibdir) || die(\"Invalid library path: $perllibdir\");\n+\t\t\t$perllibdir;\n+\t\t}\n+\t);\n+}\n+# END RUNTIME_PREFIX_PERL generated code.\n-- \n2.15.0.chromium12\n\n"},{"id":"333789","messageId":"20171129155637.89075-3-dnj@google.com","threadId":"47346","inReplyTo":"20171129155637.89075-1-dnj@google.com","subject":"[PATCH v4 2/4] Makefile: add support for \"perllibdir\"","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-29T15:56:35Z","receivedAt":"2017-11-29T15:57:09Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Add the \"perllibdir\" Makefile variable, which allows the customization\nof the Perl library installation path.\n\nThe Perl library installation path is currently left entirely to the\nPerl Makefile implementation, either MakeMaker (default) or a fixed path\nwhen NO_PERL_MAKEMAKER is enabled. This patch introduces \"perllibdir\", a\nMakefile variable that can override that Perl module installation path.\n\nAs with some other Makefile variables, \"perllibdir\" may be either\nabsolute or relative. In the latter case, it is treated as relative to\n\"$(prefix)\".\n\nAdd some incidental documentation to perl/Makefile.\n\nExplicitly specifying an installation path is necessary for Perl runtime\nprefix support, as runtime prefix resolution code must know in advance\nwhere the Perl support modules are installed.\n\nSigned-off-by: Dan Jacques <dnj@google.com>\n---\n Makefile      | 18 +++++++++++++-----\n perl/Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++------\n 2 files changed, 59 insertions(+), 11 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex f7c4ac207..80904f8b0 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -462,6 +462,7 @@ ARFLAGS = rcs\n #   mandir\n #   infodir\n #   htmldir\n+#   perllibdir\n # This can help installing the suite in a relocatable way.\n \n prefix = $(HOME)\n@@ -1721,6 +1722,7 @@ gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n htmldir_relative_SQ = $(subst ','\\'',$(htmldir_relative))\n prefix_SQ = $(subst ','\\'',$(prefix))\n+perllibdir_SQ = $(subst ','\\'',$(perllibdir))\n gitwebdir_SQ = $(subst ','\\'',$(gitwebdir))\n \n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n@@ -1955,17 +1957,22 @@ $(SCRIPT_PERL_GEN): perl/perl.mak\n \n perl/perl.mak: perl/PM.stamp\n \n-perl/PM.stamp: FORCE\n+perl/PM.stamp: GIT-PERL-DEFINES FORCE\n \t@$(FIND) perl -type f -name '*.pm' | sort >$@+ && \\\n+\tcat GIT-PERL-DEFINES >>$@+ && \\\n \t$(PERL_PATH) -V >>$@+ && \\\n \t{ cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \\\n \t$(RM) $@+\n \n-perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n-\t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)\n-\n PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template\n-PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)\n+\n+PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ)\n+PERL_DEFINES += $(NO_PERL_MAKEMAKER)\n+PERL_DEFINES += $(perllibdir)\n+\n+perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n+\t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' \\\n+\t  prefix='$(prefix_SQ)' perllibdir='$(perllibdir_SQ)' $(@F)\n \n $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n@@ -1979,6 +1986,7 @@ $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GI\n \tchmod +x $@+ && \\\n \tmv $@+ $@\n \n+PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))\n GIT-PERL-DEFINES: FORCE\n \t@FLAGS='$(PERL_DEFINES)'; \\\n \t    if test x\"$$FLAGS\" != x\"`cat $@ 2>/dev/null`\" ; then \\\ndiff --git a/perl/Makefile b/perl/Makefile\nindex f657de20e..b2aeeb0d8 100644\n--- a/perl/Makefile\n+++ b/perl/Makefile\n@@ -1,6 +1,22 @@\n #\n # Makefile for perl support modules and routine\n #\n+# This Makefile generates \"perl.mak\", which contains the actual build and\n+# installation directions.\n+#\n+# PERL_PATH must be defined to be the path of the Perl interpreter to use.\n+#\n+# prefix must be defined as the Git installation prefix.\n+#\n+# localedir must be defined as the path to the locale data.\n+#\n+# perllibdir may be optionally defined to override the default Perl module\n+# installation directory, which is relative to prefix. If perllibdir is not\n+# absolute, it will be treated as relative to prefix.\n+#\n+# NO_PERL_MAKEMAKER may be defined to use a built-in Makefile generation method\n+# instead of Perl MakeMaker.\n+\n makfile:=perl.mak\n modules =\n \n@@ -12,6 +28,16 @@ ifndef V\n \tQUIET = @\n endif\n \n+# If a library directory is provided, and it is not an absolute path, resolve\n+# it relative to prefix.\n+ifneq ($(perllibdir),)\n+ifneq ($(filter /%,$(firstword $(perllibdir))),)\n+perllib_instdir = $(perllibdir)\n+else\n+perllib_instdir = $(prefix)/$(perllibdir)\n+endif\n+endif\n+\n all install instlibdir: $(makfile)\n \t$(QUIET)$(MAKE) -f $(makfile) $@\n \n@@ -25,7 +51,12 @@ clean:\n $(makfile): PM.stamp\n \n ifdef NO_PERL_MAKEMAKER\n-instdir_SQ = $(subst ','\\'',$(prefix)/lib)\n+\n+ifeq ($(perllib_instdir),)\n+perllib_instdir = $(prefix)/lib\n+endif\n+\n+instdir_SQ = $(subst ','\\'',$(perllib_instdir))\n \n modules += Git\n modules += Git/I18N\n@@ -42,7 +73,7 @@ modules += Git/SVN/Prompt\n modules += Git/SVN/Ra\n modules += Git/SVN/Utils\n \n-$(makfile): ../GIT-CFLAGS Makefile\n+$(makfile): ../GIT-CFLAGS ../GIT-PERL-DEFINES Makefile\n \techo all: private-Error.pm Git.pm Git/I18N.pm > $@\n \tset -e; \\\n \tfor i in $(modules); \\\n@@ -79,12 +110,21 @@ $(makfile): ../GIT-CFLAGS Makefile\n \techo '\tcp private-Error.pm \"$$(DESTDIR)$(instdir_SQ)/Error.pm\"' >> $@\n \techo instlibdir: >> $@\n \techo '\techo $(instdir_SQ)' >> $@\n+\n else\n-$(makfile): Makefile.PL ../GIT-CFLAGS\n-\t$(PERL_PATH) $< PREFIX='$(prefix_SQ)' INSTALL_BASE='' --localedir='$(localedir_SQ)'\n+\n+# This may be empty if perllibdir was empty.\n+instdir_SQ = $(subst ','\\'',$(perllib_instdir))\n+\n+$(makfile): Makefile.PL ../GIT-CFLAGS ../GIT-PERL-DEFINES\n+\t$(PERL_PATH) $< \\\n+\t  PREFIX='$(prefix_SQ)' INSTALL_BASE='' \\\n+\t  LIB='$(instdir_SQ)' \\\n+\t  --localedir='$(localedir_SQ)'\n+\n endif\n \n # this is just added comfort for calling make directly in perl dir\n # (even though GIT-CFLAGS aren't used yet. If ever)\n-../GIT-CFLAGS:\n-\t$(MAKE) -C .. GIT-CFLAGS\n+../GIT-CFLAGS ../GIT-PERL-DEFINES:\n+\t$(MAKE) -C .. $(@F)\n-- \n2.15.0.chromium12\n\n"},{"id":"333807","messageId":"87lgiovokg.fsf@evledraar.booking.com","threadId":"47346","inReplyTo":"20171129155637.89075-3-dnj@google.com","subject":"Re: [PATCH v4 2/4] Makefile: add support for \"perllibdir\"","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-11-29T20:04:47Z","receivedAt":"2017-11-29T20:04:56Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Nov 29 2017, Dan Jacques jotted:\n\n> Add the \"perllibdir\" Makefile variable, which allows the customization\n> of the Perl library installation path.\n>\n> The Perl library installation path is currently left entirely to the\n> Perl Makefile implementation, either MakeMaker (default) or a fixed path\n> when NO_PERL_MAKEMAKER is enabled. This patch introduces \"perllibdir\", a\n> Makefile variable that can override that Perl module installation path.\n>\n> As with some other Makefile variables, \"perllibdir\" may be either\n> absolute or relative. In the latter case, it is treated as relative to\n> \"$(prefix)\".\n>\n> Add some incidental documentation to perl/Makefile.\n>\n> Explicitly specifying an installation path is necessary for Perl runtime\n> prefix support, as runtime prefix resolution code must know in advance\n> where the Perl support modules are installed.\n>\n> Signed-off-by: Dan Jacques <dnj@google.com>\n> ---\n>  Makefile      | 18 +++++++++++++-----\n>  perl/Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++------\n>  2 files changed, 59 insertions(+), 11 deletions(-)\n>\n> diff --git a/Makefile b/Makefile\n> index f7c4ac207..80904f8b0 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -462,6 +462,7 @@ ARFLAGS = rcs\n>  #   mandir\n>  #   infodir\n>  #   htmldir\n> +#   perllibdir\n>  # This can help installing the suite in a relocatable way.\n>\n>  prefix = $(HOME)\n> @@ -1721,6 +1722,7 @@ gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n>  template_dir_SQ = $(subst ','\\'',$(template_dir))\n>  htmldir_relative_SQ = $(subst ','\\'',$(htmldir_relative))\n>  prefix_SQ = $(subst ','\\'',$(prefix))\n> +perllibdir_SQ = $(subst ','\\'',$(perllibdir))\n>  gitwebdir_SQ = $(subst ','\\'',$(gitwebdir))\n>\n>  SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n> @@ -1955,17 +1957,22 @@ $(SCRIPT_PERL_GEN): perl/perl.mak\n>\n>  perl/perl.mak: perl/PM.stamp\n>\n> -perl/PM.stamp: FORCE\n> +perl/PM.stamp: GIT-PERL-DEFINES FORCE\n>  \t@$(FIND) perl -type f -name '*.pm' | sort >$@+ && \\\n> +\tcat GIT-PERL-DEFINES >>$@+ && \\\n>  \t$(PERL_PATH) -V >>$@+ && \\\n>  \t{ cmp $@+ $@ >/dev/null 2>/dev/null || mv $@+ $@; } && \\\n>  \t$(RM) $@+\n>\n> -perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n> -\t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)\n> -\n>  PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template\n> -PERL_DEFINES = $(PERL_PATH_SQ):$(PERLLIB_EXTRA_SQ)\n> +\n> +PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ)\n> +PERL_DEFINES += $(NO_PERL_MAKEMAKER)\n> +PERL_DEFINES += $(perllibdir)\n> +\n> +perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n> +\t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' \\\n> +\t  prefix='$(prefix_SQ)' perllibdir='$(perllibdir_SQ)' $(@F)\n>\n>  $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE\n>  \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n> @@ -1979,6 +1986,7 @@ $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GI\n>  \tchmod +x $@+ && \\\n>  \tmv $@+ $@\n>\n> +PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES))\n>  GIT-PERL-DEFINES: FORCE\n>  \t@FLAGS='$(PERL_DEFINES)'; \\\n>  \t    if test x\"$$FLAGS\" != x\"`cat $@ 2>/dev/null`\" ; then \\\n> diff --git a/perl/Makefile b/perl/Makefile\n> index f657de20e..b2aeeb0d8 100644\n> --- a/perl/Makefile\n> +++ b/perl/Makefile\n> @@ -1,6 +1,22 @@\n>  #\n>  # Makefile for perl support modules and routine\n>  #\n> +# This Makefile generates \"perl.mak\", which contains the actual build and\n> +# installation directions.\n> +#\n> +# PERL_PATH must be defined to be the path of the Perl interpreter to use.\n> +#\n> +# prefix must be defined as the Git installation prefix.\n> +#\n> +# localedir must be defined as the path to the locale data.\n> +#\n> +# perllibdir may be optionally defined to override the default Perl module\n> +# installation directory, which is relative to prefix. If perllibdir is not\n> +# absolute, it will be treated as relative to prefix.\n> +#\n> +# NO_PERL_MAKEMAKER may be defined to use a built-in Makefile generation method\n> +# instead of Perl MakeMaker.\n> +\n>  makfile:=perl.mak\n>  modules =\n>\n> @@ -12,6 +28,16 @@ ifndef V\n>  \tQUIET = @\n>  endif\n>\n> +# If a library directory is provided, and it is not an absolute path, resolve\n> +# it relative to prefix.\n> +ifneq ($(perllibdir),)\n> +ifneq ($(filter /%,$(firstword $(perllibdir))),)\n> +perllib_instdir = $(perllibdir)\n> +else\n> +perllib_instdir = $(prefix)/$(perllibdir)\n> +endif\n> +endif\n\nMaybe I'm missing something, but isn't this \"perllibdir can be relative\"\naim orthagonal to what this patch series is about? I.e. we could just\navoid this work by saying you must say \"prefix=/usr\nperllibdir=/usr/perl\" instead of \"prefix=/usr perllibdir=perl\" as this\nallows.\n\nI started going down this route with my own patch and just threw it\naway.\n\n>  all install instlibdir: $(makfile)\n>  \t$(QUIET)$(MAKE) -f $(makfile) $@\n>\n> @@ -25,7 +51,12 @@ clean:\n>  $(makfile): PM.stamp\n>\n>  ifdef NO_PERL_MAKEMAKER\n> -instdir_SQ = $(subst ','\\'',$(prefix)/lib)\n> +\n> +ifeq ($(perllib_instdir),)\n> +perllib_instdir = $(prefix)/lib\n> +endif\n> +\n> +instdir_SQ = $(subst ','\\'',$(perllib_instdir))\n>\n>  modules += Git\n>  modules += Git/I18N\n> @@ -42,7 +73,7 @@ modules += Git/SVN/Prompt\n>  modules += Git/SVN/Ra\n>  modules += Git/SVN/Utils\n>\n> -$(makfile): ../GIT-CFLAGS Makefile\n> +$(makfile): ../GIT-CFLAGS ../GIT-PERL-DEFINES Makefile\n>  \techo all: private-Error.pm Git.pm Git/I18N.pm > $@\n>  \tset -e; \\\n>  \tfor i in $(modules); \\\n> @@ -79,12 +110,21 @@ $(makfile): ../GIT-CFLAGS Makefile\n>  \techo '\tcp private-Error.pm \"$$(DESTDIR)$(instdir_SQ)/Error.pm\"' >> $@\n>  \techo instlibdir: >> $@\n>  \techo '\techo $(instdir_SQ)' >> $@\n> +\n>  else\n> -$(makfile): Makefile.PL ../GIT-CFLAGS\n> -\t$(PERL_PATH) $< PREFIX='$(prefix_SQ)' INSTALL_BASE='' --localedir='$(localedir_SQ)'\n> +\n> +# This may be empty if perllibdir was empty.\n> +instdir_SQ = $(subst ','\\'',$(perllib_instdir))\n> +\n> +$(makfile): Makefile.PL ../GIT-CFLAGS ../GIT-PERL-DEFINES\n> +\t$(PERL_PATH) $< \\\n> +\t  PREFIX='$(prefix_SQ)' INSTALL_BASE='' \\\n> +\t  LIB='$(instdir_SQ)' \\\n> +\t  --localedir='$(localedir_SQ)'\n> +\n>  endif\n>\n>  # this is just added comfort for calling make directly in perl dir\n>  # (even though GIT-CFLAGS aren't used yet. If ever)\n> -../GIT-CFLAGS:\n> -\t$(MAKE) -C .. GIT-CFLAGS\n> +../GIT-CFLAGS ../GIT-PERL-DEFINES:\n> +\t$(MAKE) -C .. $(@F)\n"},{"id":"333810","messageId":"87k1y8vlzs.fsf@evledraar.booking.com","threadId":"47346","inReplyTo":"20171129155637.89075-4-dnj@google.com","subject":"Re: [PATCH v4 3/4] Makefile: add Perl runtime prefix support","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-11-29T21:00:23Z","receivedAt":"2017-11-29T21:00:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Nov 29 2017, Dan Jacques jotted:\n\n> Add a new Makefile flag, RUNTIME_PREFIX_PERL, which, when enabled,\n> configures Perl scripts to locate the Git installation's Perl support\n> libraries by resolving against the script's path, rather than\n> hard-coding that path at build-time.\n> [...]\n> diff --git a/perl/header_runtime_prefix.pl.template b/perl/header_runtime_prefix.pl.template\n> new file mode 100644\n> index 000000000..fb9a9924d\n> --- /dev/null\n> +++ b/perl/header_runtime_prefix.pl.template\n> @@ -0,0 +1,24 @@\n> +# BEGIN RUNTIME_PREFIX_PERL generated code.\n> +#\n> +# This finds our Git::* libraries relative to the script's runtime path.\n> +BEGIN {\n> +\tuse lib split /@@PATHSEP@@/,\n> +\t(\n> +\t\t$ENV{GITPERLLIB}\n> +\t\t||\n> +\t\tdo {\n> +\t\t\trequire FindBin;\n> +\t\t\trequire File::Spec;\n> +\t\t\tmy $gitexecdir_relative = '@@GITEXECDIR@@';\n> +\t\t\tmy $perllibdir_relative = '@@PERLLIBDIR@@';\n> +\n> +\t\t\t($FindBin::Bin =~ m=${gitexecdir_relative}$=) ||\n> +\t\t\t    die('Unrecognized runtime path.');\n> +\t\t\tmy $prefix = substr($FindBin::Bin, 0, -length($gitexecdir_relative));\n> +\t\t\tmy $perllibdir = File::Spec->catdir($prefix, $perllibdir_relative);\n> +\t\t\t(-e $perllibdir) || die(\"Invalid library path: $perllibdir\");\n> +\t\t\t$perllibdir;\n> +\t\t}\n> +\t);\n> +}\n> +# END RUNTIME_PREFIX_PERL generated code.\n\nAh, I see. To answer my own question in\n<87lgiovokg.fsf@evledraar.booking.com> you're making this stuff a\nrelative path so you can use it here later on. I.e. we $FindBin::Bin,\nand then go from there. Makes sense.\n\nWe could use $ENV{GIT_EXEC_PATH} instead of FindBin here though, I\nmissed that the first time. But that's just a nano-optimization. I just\nwondered whether git wasn't already passing us this info.\n\nThere is one remaining bug here. Git::I18N isn't doing the right thing,\nI installed in /tmp/git and moved to /tmp/git2, and it has:\n\n    our $TEXTDOMAINDIR = $ENV{GIT_TEXTDOMAINDIR} || '/tmp/git/share/locale';\n\nAnd GIT_TEXTDOMAINDIR is not passed by git (it's only used for the tests\nIIRC). Would need a similar treatment as this. Easiest to just set the\npath we find here in $Git::Whatever and pick it up in $Git::I18N later,\nit's not like anyone uses it outside of git.git.\n\nBut that does raise a more general concern for me. Isn't there some way\nwe can run the test suite against an installed git (don't remember),\nthen build, install, move the dir, and run the tests from the moved dir.\n\nThat would have caught this bug, and anything else that may be lurking\nstill.\n"},{"id":"333811","messageId":"87indsvlsg.fsf@evledraar.booking.com","threadId":"47346","inReplyTo":"20171129155637.89075-4-dnj@google.com","subject":"Re: [PATCH v4 3/4] Makefile: add Perl runtime prefix support","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-11-29T21:04:47Z","receivedAt":"2017-11-29T21:04:54Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Nov 29 2017, Dan Jacques jotted:\n\n\n> +\tuse lib split /@@PATHSEP@@/,\n> +\t(\n> +\t\t$ENV{GITPERLLIB}\n> +\t\t||\n> +\t\tdo {\n> +\t\t\trequire FindBin;\n> +\t\t\trequire File::Spec;\n> +\t\t\tmy $gitexecdir_relative = '@@GITEXECDIR@@';\n> +\t\t\tmy $perllibdir_relative = '@@PERLLIBDIR@@';\n> +\n> +\t\t\t($FindBin::Bin =~ m=${gitexecdir_relative}$=) ||\n> +\t\t\t    die('Unrecognized runtime path.');\n> +\t\t\tmy $prefix = substr($FindBin::Bin, 0, -length($gitexecdir_relative));\n> +\t\t\tmy $perllibdir = File::Spec->catdir($prefix, $perllibdir_relative);\n> +\t\t\t(-e $perllibdir) || die(\"Invalid library path: $perllibdir\");\n> +\t\t\t$perllibdir;\n> +\t\t}\n> +\t);\n> +}\n> +# END RUNTIME_PREFIX_PERL generated code.\n\nNoticed after I sent the last E-Mail, this is missing @@INSTLIBDIR@@\nwhich per my reading of it being initially introduced should be here in\naddition to this relative path.\n\nMy reading of the intial patch that added it, as indicated in my patch,\nis that it's the dir we're going to be installing our libs to, so I\ndidn't fiddle with it, but I think with your patches we need that dir\n*and* or own $perllibdir.\n"},{"id":"333812","messageId":"87h8tcvlew.fsf@evledraar.booking.com","threadId":"47346","inReplyTo":"20171129155637.89075-1-dnj@google.com","subject":"Re: [PATCH v4 0/4] RUNTIME_PREFIX relocatable Git","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-11-29T21:12:55Z","receivedAt":"2017-11-29T21:13:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Nov 29 2017, Dan Jacques jotted:\n\n> This is a small update to incorporate some Windows fixes from Johannes.\n> At this point, it passes the full test suite on Linux, Mac, and FreeBSD,\n> as well as the Travis.ci test suites, with and without\n> RUNTIME_PREFIX/RUNTIME_PREFIX_PERL flags.\n>\n> I'm happy with the patch set, and feel that it is ready to move forward.\n> However, while it's been looked at by several people, and I have\n> incorporated reviewer feedback, the patch set hasn't received any formal\n> LGTM-style responses yet. I'm not sure what standard of review is required\n> to move forward with a patch on this project, so maybe this is totally\n> fine, but I wanted to make sure to point this out.\n>\n> I also want to note Ævar Arnfjörð Bjarmason's RFC:\n> https://public-inbox.org/git/20171129153436.24471-1-avarab@gmail.com/T/\n>\n> The proposed patch set conflicts with the Perl installation directory\n> changes in this patch set, as avarab@ notes. The proposed Perl installation\n> process would simplify patch 0002 in this patch set. I don't think the\n> landing order is terribly impactful - if this lands first, the patch in the\n> RFC would delete a few more lines, and if this lands later, patch 0002\n> would largely not be necessary.\n\nIn general this whole thing structurally looks good to me with the\ncaveats noted in other review E-Mails.\n\nI haven't done anything but skim the details of the \"where's my\nexecutable\" C code though, just looked at what it's doing structurally.\n\nI think it makes sense for this to land first ahead of my patch. This is\nan actual feature you need, whereas I just hate our use of MakeMaker,\nbut that can wait, unless you're keen to rebase this on my patch. Would\nprobably make your whole diff a bit shorter.\n\nThe whole converting our absolute to relative paths in the make code is\nunavoidably ugly, but after having an initial knee-jerk reaction to it I\ndon't see how it can be avoided. I was hoping most of these paths\ncould/would just be a fixed path away from our libexec path, but alas\ndue to having had these configurable all along that simplicity seems out\nof reach.\n\nMaybe I asked this before, but I don't see any obvious reason for why\nRUNTIME_PREFIX_PERL is a different thing than RUNTIME_PREFIX as opposed\nto us just doing the right thing for the perl scripts.\n"},{"id":"333817","messageId":"20171129223807.91343-1-dnj@google.com","threadId":"47346","inReplyTo":"87h8tcvlew.fsf@evledraar.booking.com","subject":"Re: [PATCH v4 0/4] RUNTIME_PREFIX relocatable Git","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-11-29T22:38:07Z","receivedAt":"2017-11-29T22:38:28Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"> In general this whole thing structurally looks good to me with the\n> caveats noted in other review E-Mails.\n>\n> I haven't done anything but skim the details of the \"where's my\n> executable\" C code though, just looked at what it's doing structurally.\n>\n> I think it makes sense for this to land first ahead of my patch. This is\n> an actual feature you need, whereas I just hate our use of MakeMaker,\n> but that can wait, unless you're keen to rebase this on my patch. Would\n> probably make your whole diff a bit shorter.\n\nI'm not strictly pressed for time here, so we can put this off if that's\nstrategically appropriate. Chromiuum, right now, just manually patches\nupstream Git with a similar patch set, so it's working and function. This\nis just an effort to upstream those changes for everyone else to enjoy!\n\nI think that landing in either order is probably okay, so if your RFC\ngoes through pretty quickly I don't mind rebasing, but if this is otherwise\ngood to go in v5, I wouldn't mind landing it and then removing the\nobsoleted parts during the Makefile update.\n\n> The whole converting our absolute to relative paths in the make code is\n> unavoidably ugly, but after having an initial knee-jerk reaction to it I\n> don't see how it can be avoided. I was hoping most of these paths\n> could/would just be a fixed path away from our libexec path, but alas\n> due to having had these configurable all along that simplicity seems out\n> of reach.\n\nYeah I spent no small amount of time massaging that code hoping some better\nformulation would shake out, and this is what I ended up with.\nUNTIME_PREFIX_PERL is a specialty build with a stronger set of assumptions\nthan the standard installation (RE prefix-relative paths).\n\n> Maybe I asked this before, but I don't see any obvious reason for why\n> RUNTIME_PREFIX_PERL is a different thing than RUNTIME_PREFIX as opposed\n> to us just doing the right thing for the perl scripts.\n\nI did this to isolate Windows builds from the Perl script changes. Git-for-\nWindows uses (invented) RUNTIME_PREFIX, but runs its Perl scripts in a\nMinGW sub-environment which, internally, has the Perl libraries installed\nat a fixed path, so it doesn't need any special resolution logic.\n\nI support that if Git-for-Windows wants to, a trivial future patch can\nmerge the two, so I opted to play it safe and keep these changes isolated.\n\n===\n\n> We could use $ENV{GIT_EXEC_PATH} instead of FindBin here though, I\n> missed that the first time. But that's just a nano-optimization. I just\n> wondered whether git wasn't already passing us this info.\n\nOh good idea - I'll go ahead and do this.\n\n> There is one remaining bug here. Git::I18N isn't doing the right thing,\n> I installed in /tmp/git and moved to /tmp/git2, and it has:\n>\n>     our $TEXTDOMAINDIR = $ENV{GIT_TEXTDOMAINDIR} || '/tmp/git/share/locale';\n>\n> And GIT_TEXTDOMAINDIR is not passed by git (it's only used for the tests\n> IIRC). Would need a similar treatment as this. Easiest to just set the\n> path we find here in $Git::Whatever and pick it up in $Git::I18N later,\n> it's not like anyone uses it outside of git.git.\n\nGood catch! I'm going to see what I can do here.\n\n> But that does raise a more general concern for me. Isn't there some way\n> we can run the test suite against an installed git (don't remember),\n> then build, install, move the dir, and run the tests from the moved dir.\n>\n> That would have caught this bug, and anything else that may be lurking\n> still.\n\nI am not aware of such an option, but I'll take a look again. This sort of\nthing might just require a reformulation of the test suite in general to\nmake it run against a Git installation instead of the intermediate\nartifacts. A positive outcome would be the ability to remove the Perl\npath environment variable hacks ($ENV{...} || ...) and just use production\nresolution logic, increasing the test surface! But I think that's a bit more\nwork than I have time for at the moment.\n\n===\n\n> Noticed after I sent the last E-Mail, this is missing @@INSTLIBDIR@@\n> which per my reading of it being initially introduced should be here in\n> addition to this relative path.\n>\n> My reading of the intial patch that added it, as indicated in my patch,\n> is that it's the dir we're going to be installing our libs to, so I\n> didn't fiddle with it, but I think with your patches we need that dir\n> *and* or own $perllibdir.\n\nINSTLIBDIR is used for the standard fixed-prefix header, but not in this\none. This one uses a combination of GITEXECDIR and PERLLIBDIR. PERLLIBDIR\nis effectively the prefix-relative part of INSTLIBDIR, so it's here in\nspirit!\n\nThanks for taking the time to review! I'll go ahead and see what I can do\nRE your comments.\n\nCheers,\n-Dan\n"},{"id":"333920","messageId":"3c897f4c-0cb5-ca44-f144-598a623c1dc3@kdbg.org","threadId":"47346","inReplyTo":"20171129155637.89075-2-dnj@google.com","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-12-01T16:59:46Z","receivedAt":"2017-12-01T16:59:55Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 29.11.2017 um 16:56 schrieb Dan Jacques:\n> @@ -1989,6 +1986,15 @@ GIT-PERL-DEFINES: FORCE\n>   \t\techo \"$$FLAGS\" >$@; \\\n>   \t    fi\n>   \n> +GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n> +\t$(QUIET_GEN)$(RM) $@ && \\\n> +\tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \\\n> +\tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n> +\tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n> +\tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n\nThis doesn't work, unfortunately. When $(pathsep) is ';', we get an \nincomplete sed expression because ';' is also a command separator in the \nsed language.\n\n> +\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> +\t    $< >$@+ && \\\n> +\tmv $@+ $@\n>   \n>   .PHONY: gitweb\n>   gitweb:\n\n-- Hannes\n"},{"id":"333921","messageId":"alpine.DEB.2.21.1.1712011812250.98586@virtualbox","threadId":"47346","inReplyTo":"3c897f4c-0cb5-ca44-f144-598a623c1dc3@kdbg.org","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2017-12-01T17:13:00Z","receivedAt":"2017-12-01T17:13:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Hannes,\n\nOn Fri, 1 Dec 2017, Johannes Sixt wrote:\n\n> Am 29.11.2017 um 16:56 schrieb Dan Jacques:\n> > @@ -1989,6 +1986,15 @@ GIT-PERL-DEFINES: FORCE\n> >        \techo \"$$FLAGS\" >$@; \\\n> >        fi\n> >   +GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak\n> > Makefile\n> > +\t$(QUIET_GEN)$(RM) $@ && \\\n> > +\tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory\n> > instlibdir` && \\\n> > +\tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n> > +\tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" &&\n> > \\\n> > +\tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n> \n> This doesn't work, unfortunately. When $(pathsep) is ';', we get an incomplete\n> sed expression because ';' is also a command separator in the sed language.\n\nFunny, I tried this also with ';' as pathsep, and it worked in the Git for\nWindows SDK...\n\nCiao,\nDscho\n"},{"id":"333925","messageId":"97acc3d3-5c6a-2e65-a372-24def5b21d54@kdbg.org","threadId":"47346","inReplyTo":"alpine.DEB.2.21.1.1712011812250.98586@virtualbox","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-12-01T17:25:30Z","receivedAt":"2017-12-01T17:25:38Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 01.12.2017 um 18:13 schrieb Johannes Schindelin:\n> Hi Hannes,\n> \n> On Fri, 1 Dec 2017, Johannes Sixt wrote:\n> \n>> Am 29.11.2017 um 16:56 schrieb Dan Jacques:\n>>> @@ -1989,6 +1986,15 @@ GIT-PERL-DEFINES: FORCE\n>>>         \techo \"$$FLAGS\" >$@; \\\n>>>         fi\n>>>    +GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak\n>>> Makefile\n>>> +\t$(QUIET_GEN)$(RM) $@ && \\\n>>> +\tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory\n>>> instlibdir` && \\\n>>> +\tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>>> +\tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" &&\n>>> \\\n>>> +\tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n>>\n>> This doesn't work, unfortunately. When $(pathsep) is ';', we get an incomplete\n>> sed expression because ';' is also a command separator in the sed language.\n> \n> Funny, I tried this also with ';' as pathsep, and it worked in the Git for\n> Windows SDK...\n\nMy ancient sed vs. your modern sed, perhaps? I can check this on Monday.\n\n-- Hannes\n"},{"id":"333928","messageId":"20171201181845.8454-1-dnj@google.com","threadId":"47346","inReplyTo":"97acc3d3-5c6a-2e65-a372-24def5b21d54@kdbg.org","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-12-01T18:18:45Z","receivedAt":"2017-12-01T18:19:16Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"On Fri, 1 Dec 2017, Johannes Sixt wrote:\n\n>>> This doesn't work, unfortunately. When $(pathsep) is ';', we get an\n>>> incomplete sed expression because ';' is also a command separator in the sed language.\n>>\n>> Funny, I tried this also with ';' as pathsep, and it worked in the Git for\n>> Windows SDK...\n>\n> My ancient sed vs. your modern sed, perhaps? I can check this on Monday.\n\nIf you wouldn't mind, that would be much appreciated. Did you actually observe\nthis issue, or is it just coming up in review?\n\nI am not a `sed` wizard, but perhaps the tool is ignoring the semicolon because\nit's in the middle of the \"s\" expression? The shell may similarly be ignoring it\nbecause it's nested in between single-quotes?\n\n-Dan\n"},{"id":"333935","messageId":"87efoe46xe.fsf@linux-m68k.org","threadId":"47346","inReplyTo":"20171201181845.8454-1-dnj@google.com","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2017-12-01T18:52:29Z","receivedAt":"2017-12-01T18:52:41Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Dez 01 2017, Dan Jacques <dnj@google.com> wrote:\n\n> I am not a `sed` wizard, but perhaps the tool is ignoring the semicolon because\n> it's in the middle of the \"s\" expression? The shell may similarly be ignoring it\n> because it's nested in between single-quotes?\n\nAs far as POSIX is concerned, semicolons are not special, but can be\nused to separate commands instead of newlines.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"333956","messageId":"20171202154730.26258-1-dnj@google.com","threadId":"47346","inReplyTo":"87k1y8vlzs.fsf@evledraar.booking.com","subject":"Re: [PATCH v4 3/4] RUNTIME_PREFIX relocatable Git","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-12-02T15:47:30Z","receivedAt":"2017-12-02T15:47:45Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"My initial set of replies are inline here:\nhttps://public-inbox.org/git/20171129223807.91343-1-dnj@google.com/T/#m1ff5cda787eaea4a4015a8f00a8be5966122c73a\n\nI put together this solution for the I18N module. It exports \"localedir\" to\nthe Perl header and injects the correct value into Git::I18N. It also\nsuppresses the emission of the full ++LOCALEDIR++ when in runtime prefix\nmode.\n\nOne downside of this approach is that, since the point of resolution happens\nat the beginning of the script execution, external users of the runtime\nprefix Git::I18N module will not be able to resolve the locale directory.\nI think this is okay, though, since RUNTIME_PREFIX_PERL is decidedly *not*\nintended for system installation and is not trying to offer system module\nimport portability.\n\nAfter looking a bit at your $ENV{GIT_EXEC_PATH} optimization suggestion, I\nended up favoring the current usage of FindBin::Bin for a few reasons:\n\n- Encoding the relative GITEXECDIR into the script is more consistent with\n  how \"exec_cmd.c\" does its own self-resolution.\n- The resolution code is a bit more readable, both in terms of what it's\n  doing and where it starts from.\n- It makes the scripts individually executable, rather than having to go\n  through the Git wrapper. This is, minimally, useful for testing.\n\nI admittedly don't know much about FindBin, so if it has a downside that\ncould outweigh this I'm more than happy to reevaluate.\n\nWith respect to testing, I did find \"GIT_TEST_INSTALLED\". Unfortunately,\nit doesn't seem to work against the full test suite even on master, and\nindividual tests, especially Perl and locale, set their own path\nexpectations. I think including installation-relative testing here would\ntake a fair amount of work.\n\nNote that this is a replacement for [PATCH v4 3/4], so if you're trying to\napply it, you will need to build it on top of the preceding patches.\n\nMany thanks,\n-Dan\n\n---\n Makefile                               | 59 +++++++++++++++++++++++++++++++---\n perl/Git/I18N.pm                       |  2 +-\n perl/Makefile                          | 17 ++++++----\n perl/header_runtime_prefix.pl.template | 31 ++++++++++++++++++\n t/test-lib.sh                          | 13 +++++---\n 5 files changed, 107 insertions(+), 15 deletions(-)\n create mode 100644 perl/header_runtime_prefix.pl.template\n\ndiff --git a/Makefile b/Makefile\nindex 80904f8b0..558bd3ebb 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -425,6 +425,10 @@ all::\n #\n # to say \"export LESS=FRX (and LV=-c) if the environment variable\n # LESS (and LV) is not set, respectively\".\n+#\n+# Define RUNTIME_PREFIX_PERL to configure Git's PERL commands to locate Git\n+# support libraries relative to their filesystem path instead of hard-coding\n+# it.\n \n GIT-VERSION-FILE: FORCE\n \t@$(SHELL_PATH) ./GIT-VERSION-GEN\n@@ -462,6 +466,7 @@ ARFLAGS = rcs\n #   mandir\n #   infodir\n #   htmldir\n+#   localedir\n #   perllibdir\n # This can help installing the suite in a relocatable way.\n \n@@ -483,9 +488,12 @@ lib = lib\n # DESTDIR =\n pathsep = :\n \n+gitexecdir_relative = $(patsubst $(prefix)/%,%,$(gitexecdir))\n mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))\n infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))\n+localedir_relative = $(patsubst $(prefix)/%,%,$(localedir))\n htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))\n+perllibdir_relative = $(patsubst $(prefix)/%,%,$(perllibdir))\n \n export prefix bindir sharedir sysconfdir gitwebdir localedir\n \n@@ -1718,11 +1726,13 @@ bindir_relative_SQ = $(subst ','\\'',$(bindir_relative))\n mandir_relative_SQ = $(subst ','\\'',$(mandir_relative))\n infodir_relative_SQ = $(subst ','\\'',$(infodir_relative))\n localedir_SQ = $(subst ','\\'',$(localedir))\n+localedir_relative_SQ = $(subst ','\\'',$(localedir_relative))\n gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+gitexecdir_relative_SQ = $(subst ','\\'',$(gitexecdir_relative))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n htmldir_relative_SQ = $(subst ','\\'',$(htmldir_relative))\n prefix_SQ = $(subst ','\\'',$(prefix))\n-perllibdir_SQ = $(subst ','\\'',$(perllibdir))\n+perllibdir_relative_SQ = $(subst ','\\'',$(perllibdir_relative))\n gitwebdir_SQ = $(subst ','\\'',$(gitwebdir))\n \n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n@@ -1965,14 +1975,52 @@ perl/PM.stamp: GIT-PERL-DEFINES FORCE\n \t$(RM) $@+\n \n PERL_HEADER_TEMPLATE = perl/header_fixed_prefix.pl.template\n+perl_localedir = $(localedir)\n \n PERL_DEFINES := $(PERL_PATH_SQ) $(PERLLIB_EXTRA_SQ)\n-PERL_DEFINES += $(NO_PERL_MAKEMAKER)\n-PERL_DEFINES += $(perllibdir)\n+PERL_DEFINES += $(NO_PERL_MAKEMAKER) $(RUNTIME_PREFIX_PERL)\n+\n+# Support Perl runtime prefix. In this mode, a different header is installed\n+# into Perl scripts. This header expects both the scripts and their support\n+# library to be installed relative to $(prefix), and resolves the path to\n+# the Perl libraries (perllibdir) from the executable's current path\n+# (gitexecdir).\n+#\n+# This configuration requires both $(perllibdir) and $(gitexecdir) to be\n+# relative paths, and will error if this is not the case.\n+ifdef RUNTIME_PREFIX_PERL\n+\n+PERL_HEADER_TEMPLATE = perl/header_runtime_prefix.pl.template\n+\n+# RUNTIME_PREFIX_PERL requires a $(perllibdir) value.\n+ifeq ($(perllibdir),)\n+perllibdir = $(sharedir)/perl5\n+endif\n+\n+ifneq ($(filter /%,$(firstword $(perllibdir_relative))),)\n+$(error RUNTIME_PREFIX_PERL requires a relative perllibdir, not: $(perllibdir))\n+endif\n+\n+ifneq ($(filter /%,$(firstword $(gitexecdir_relative))),)\n+$(error RUNTIME_PREFIX_PERL requires a relative gitexecdir, not: $(gitexecdir))\n+endif\n+\n+ifneq ($(filter /%,$(firstword $(localedir_relative))),)\n+$(error RUNTIME_PREFIX_PERL requires a prefix-relative localedir, not: $(localedir))\n+endif\n+\n+# Don't need to export a locale directory to Perl scripts, since the runtime\n+# header will resolve it.\n+perl_localedir =\n+\n+endif\n+\n+PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir)\n+export perl_localedir\n \n perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL\n \t$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' \\\n-\t  prefix='$(prefix_SQ)' perllibdir='$(perllibdir_SQ)' $(@F)\n+\t  prefix='$(prefix_SQ)' perllibdir='$(perllibdir_relative_SQ)' $(@F)\n \n $(SCRIPT_PERL_GEN): % : %.perl perl/perl.mak GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n@@ -2001,6 +2049,9 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n \t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n+\t    -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n+\t    -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n+\t    -e 's=@@LOCALEDIR@@=$(localedir_relative_SQ)=g' \\\n \t    $< >$@+ && \\\n \tmv $@+ $@\n \ndiff --git a/perl/Git/I18N.pm b/perl/Git/I18N.pm\nindex 836a5c238..25141d27d 100644\n--- a/perl/Git/I18N.pm\n+++ b/perl/Git/I18N.pm\n@@ -18,7 +18,7 @@ our @EXPORT_OK = @EXPORT;\n \n sub __bootstrap_locale_messages {\n \tour $TEXTDOMAIN = 'git';\n-\tour $TEXTDOMAINDIR = $ENV{GIT_TEXTDOMAINDIR} || '++LOCALEDIR++';\n+\tour $TEXTDOMAINDIR ||= $ENV{GIT_TEXTDOMAINDIR} || '++LOCALEDIR++';\n \n \trequire POSIX;\n \tPOSIX->import(qw(setlocale));\ndiff --git a/perl/Makefile b/perl/Makefile\nindex b2aeeb0d8..14bdda99d 100644\n--- a/perl/Makefile\n+++ b/perl/Makefile\n@@ -8,7 +8,7 @@\n #\n # prefix must be defined as the Git installation prefix.\n #\n-# localedir must be defined as the path to the locale data.\n+# perl_localedir must be defined as the path to the locale data.\n #\n # perllibdir may be optionally defined to override the default Perl module\n # installation directory, which is relative to prefix. If perllibdir is not\n@@ -22,7 +22,7 @@ modules =\n \n PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n prefix_SQ = $(subst ','\\'',$(prefix))\n-localedir_SQ = $(subst ','\\'',$(localedir))\n+localedir_SQ = $(subst ','\\'',$(perl_localedir))\n \n ifndef V\n \tQUIET = @\n@@ -116,11 +116,16 @@ else\n # This may be empty if perllibdir was empty.\n instdir_SQ = $(subst ','\\'',$(perllib_instdir))\n \n+MAKEMAKER_PARAMS = PREFIX='$(prefix_SQ)' INSTALL_BASE=''\n+ifneq ($(instdir_SQ),)\n+MAKEMAKER_PARAMS += LIB='$(instdir_SQ)'\n+endif\n+ifneq ($(localedir_SQ),)\n+MAKEMAKER_PARAMS += --localedir='$(localedir_SQ)'\n+endif\n+\n $(makfile): Makefile.PL ../GIT-CFLAGS ../GIT-PERL-DEFINES\n-\t$(PERL_PATH) $< \\\n-\t  PREFIX='$(prefix_SQ)' INSTALL_BASE='' \\\n-\t  LIB='$(instdir_SQ)' \\\n-\t  --localedir='$(localedir_SQ)'\n+\t$(PERL_PATH) $< $(MAKEMAKER_PARAMS)\n \n endif\n \ndiff --git a/perl/header_runtime_prefix.pl.template b/perl/header_runtime_prefix.pl.template\nnew file mode 100644\nindex 000000000..9cc63cfb6\n--- /dev/null\n+++ b/perl/header_runtime_prefix.pl.template\n@@ -0,0 +1,31 @@\n+# BEGIN RUNTIME_PREFIX_PERL generated code.\n+#\n+# This finds our Git::* libraries relative to the script's runtime path.\n+sub __git_system_path {\n+\tmy ($relpath) = @_;\n+\tmy $gitexecdir_relative = '@@GITEXECDIR@@';\n+\n+\trequire FindBin;\n+\trequire File::Spec;\n+\t($FindBin::Bin =~ m=${gitexecdir_relative}$=) || die('Unrecognized runtime path.');\n+\tmy $prefix = substr($FindBin::Bin, 0, -length($gitexecdir_relative));\n+\treturn File::Spec->catdir($prefix, $relpath);\n+}\n+\n+BEGIN {\n+\tuse lib split /@@PATHSEP@@/,\n+\t(\n+\t\t$ENV{GITPERLLIB} ||\n+\t\tdo {\n+\t\t\tmy $perllibdir = __git_system_path('@@PERLLIBDIR@@');\n+\t\t\t(-e $perllibdir) || die(\"Invalid system path ($relpath): $path\");\n+\t\t\t$perllibdir;\n+\t\t}\n+\t);\n+\n+\t# Export the system locale directory to the I18N module. The locale directory\n+\t# is only installed if NO_GETTEXT is set.\n+\t$Git::I18N::TEXTDOMAINDIR = __git_system_path('@@LOCALEDIR@@');\n+}\n+\n+# END RUNTIME_PREFIX_PERL generated code.\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 116bd6a70..d6ea423af 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -919,11 +919,16 @@ then\n \tfi\n fi\n \n-GITPERLLIB=\"$GIT_BUILD_DIR\"/perl/blib/lib:\"$GIT_BUILD_DIR\"/perl/blib/arch/auto/Git\n+if test -n \"$GIT_TEST_PERLLIB\"\n+then\n+  GITPERLLIB=\"$GIT_TEST_PERLLIB\"\n+else\n+\tGITPERLLIB=\"$GIT_BUILD_DIR\"/perl/blib/lib:\"$GIT_BUILD_DIR\"/perl/blib/arch/auto/Git\n+\ttest -d \"$GIT_BUILD_DIR\"/templates/blt || {\n+\t\terror \"You haven't built things yet, have you?\"\n+\t}\n+fi\n export GITPERLLIB\n-test -d \"$GIT_BUILD_DIR\"/templates/blt || {\n-\terror \"You haven't built things yet, have you?\"\n-}\n \n if ! test -x \"$GIT_BUILD_DIR\"/t/helper/test-chmtime\n then\n-- \n2.15.0.chromium12\n\n"},{"id":"333985","messageId":"xmqqr2scjsb4.fsf@gitster.mtv.corp.google.com","threadId":"47346","inReplyTo":"3c897f4c-0cb5-ca44-f144-598a623c1dc3@kdbg.org","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-03T05:26:07Z","receivedAt":"2017-12-03T05:26:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n>> +\tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n>\n> This doesn't work, unfortunately. When $(pathsep) is ';', we get an\n> incomplete sed expression because ';' is also a command separator in\n> the sed language.\n\nIt is correct that ';' can be and does get used in place of LF when\nwriting a script on a single line, but even then, as part of a\nstring argument to 's' command (and also others), there is no need\nto quote ';' or otherwise treat it any specially, as the commands\nknow what their syntax is (e.g. 's=string=replacement=' after seeing\nthe first '=' knows that it needs to find one unquoted '=' to find\nthe end of the first argument, and another to find the end of the\nreplacement string, and ';' seen during that scanning would not have\nany special meaning).\n\nIf your sed is so broken and does not satisfy the above expectation,\nt6023 would not work for you, I would gess.\n\nt/t6023-merge-file.sh:sed -e \"s/deerit.\\$/deerit;/\" -e \"s/me;\\$/me./\" < new5.txt > new6.txt\nt/t6023-merge-file.sh:sed -e \"s/deerit.\\$/deerit,/\" -e \"s/me;\\$/me,/\" < new5.txt > new7.txt\nt/t6023-merge-file.sh:sed -e 's/deerit./&%%%%/' -e \"s/locavit,/locavit;/\"< new6.txt | tr '%' '\\012' > new8.txt\n\n"},{"id":"333992","messageId":"87a7z0upqq.fsf@evledraar.booking.com","threadId":"47346","inReplyTo":"xmqqr2scjsb4.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-03T09:26:05Z","receivedAt":"2017-12-03T09:36:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sun, Dec 03 2017, Junio C. Hamano jotted:\n\n> Johannes Sixt <j6t@kdbg.org> writes:\n>\n>>> +\tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n>>\n>> This doesn't work, unfortunately. When $(pathsep) is ';', we get an\n>> incomplete sed expression because ';' is also a command separator in\n>> the sed language.\n>\n> It is correct that ';' can be and does get used in place of LF when\n> writing a script on a single line, but even then, as part of a\n> string argument to 's' command (and also others), there is no need\n> to quote ';' or otherwise treat it any specially, as the commands\n> know what their syntax is (e.g. 's=string=replacement=' after seeing\n> the first '=' knows that it needs to find one unquoted '=' to find\n> the end of the first argument, and another to find the end of the\n> replacement string, and ';' seen during that scanning would not have\n> any special meaning).\n>\n> If your sed is so broken and does not satisfy the above expectation,\n> t6023 would not work for you, I would gess.\n>\n> t/t6023-merge-file.sh:sed -e \"s/deerit.\\$/deerit;/\" -e \"s/me;\\$/me./\" < new5.txt > new6.txt\n> t/t6023-merge-file.sh:sed -e \"s/deerit.\\$/deerit,/\" -e \"s/me;\\$/me,/\" < new5.txt > new7.txt\n> t/t6023-merge-file.sh:sed -e 's/deerit./&%%%%/' -e \"s/locavit,/locavit;/\"< new6.txt | tr '%' '\\012' > new8.txt\n\nSince this whole thing is guarded by \"ifndef NO_PERL\" Dan could just be\nusing \"perl -pe\" here instead of fiddling around with the portability\nedge cases of sed, e.g.:\n\n    perl -pe 's[foo][bar[g' <in >out\n"},{"id":"334218","messageId":"f0ad1ad4-67d8-21e2-fdd0-0a08328c1eaa@kdbg.org","threadId":"47346","inReplyTo":"97acc3d3-5c6a-2e65-a372-24def5b21d54@kdbg.org","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-12-05T20:54:11Z","receivedAt":"2017-12-05T20:54:19Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 01.12.2017 um 18:25 schrieb Johannes Sixt:\n> Am 01.12.2017 um 18:13 schrieb Johannes Schindelin:\n>> Hi Hannes,\n>>\n>> On Fri, 1 Dec 2017, Johannes Sixt wrote:\n>>\n>>> Am 29.11.2017 um 16:56 schrieb Dan Jacques:\n>>>> @@ -1989,6 +1986,15 @@ GIT-PERL-DEFINES: FORCE\n>>>>             echo \"$$FLAGS\" >$@; \\\n>>>>         fi\n>>>>    +GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES \n>>>> perl/perl.mak\n>>>> Makefile\n>>>> +    $(QUIET_GEN)$(RM) $@ && \\\n>>>> +    INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory\n>>>> instlibdir` && \\\n>>>> +    INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>>>> +    \n>>>> INSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" &&\n>>>> \\\n>>>> +    sed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n>>>\n>>> This doesn't work, unfortunately. When $(pathsep) is ';', we get an \n>>> incomplete\n>>> sed expression because ';' is also a command separator in the sed \n>>> language.\n>>\n>> Funny, I tried this also with ';' as pathsep, and it worked in the Git \n>> for\n>> Windows SDK...\n> \n> My ancient sed vs. your modern sed, perhaps? I can check this on Monday.\n\nI don't know what I tested last week; most likely not the version of the\npatch I quoted above.\n\nToday's version, with the tip at 5d7f59c391ce, is definitely bogus\nwith its quoting. It needs the patch below, otherwise an unquoted\nsemicolon may be expanded from $(pathsep). This would terminate the sed\ncommand, of course.\n\n\ndiff --git a/Makefile b/Makefile\nindex 484dc44ade..a658c8169a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2071,10 +2071,10 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak\n \tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \\\n \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n-\tsed -e 's=@@PATHSEP@@='$(pathsep)'=g' \\\n-\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n-\t    -e 's=@@GITEXECDIR@@='$(gitexecdir_relative_SQ)'=g' \\\n-\t    -e 's=@@PERLLIBDIR@@='$(perllibdir_relative_SQ)'=g' \\\n+\tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n+\t    -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n+\t    -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n+\t    -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n \t    $< >$@\n \n .PHONY: gitweb\n-- \n2.14.2.808.g3bc32f2729\n"},{"id":"334221","messageId":"xmqqbmjcj2mr.fsf@gitster.mtv.corp.google.com","threadId":"47346","inReplyTo":"f0ad1ad4-67d8-21e2-fdd0-0a08328c1eaa@kdbg.org","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-05T21:17:32Z","receivedAt":"2017-12-05T21:17:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> Today's version, with the tip at 5d7f59c391ce, is definitely bogus\n> with its quoting. It needs the patch below, otherwise an unquoted\n> semicolon may be expanded from $(pathsep). This would terminate the sed\n> command, of course.\n\nOf course ;-)\n\nSomehow I was lucky that the topic as been de-queued from 'pu' for\nthe past few days.\n\n> diff --git a/Makefile b/Makefile\n> index 484dc44ade..a658c8169a 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2071,10 +2071,10 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak\n>  \tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \\\n>  \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>  \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n> -\tsed -e 's=@@PATHSEP@@='$(pathsep)'=g' \\\n> -\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> -\t    -e 's=@@GITEXECDIR@@='$(gitexecdir_relative_SQ)'=g' \\\n> -\t    -e 's=@@PERLLIBDIR@@='$(perllibdir_relative_SQ)'=g' \\\n> +\tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n> +\t    -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n> +\t    -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n> +\t    -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n>  \t    $< >$@\n>  \n>  .PHONY: gitweb\n"},{"id":"334222","messageId":"20171205212625.6616-1-dnj@google.com","threadId":"47346","inReplyTo":"f0ad1ad4-67d8-21e2-fdd0-0a08328c1eaa@kdbg.org","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Dan Jacques","fromEmail":"dnj@google.com","sentAt":"2017-12-05T21:26:25Z","receivedAt":"2017-12-05T21:26:34Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Johannes Sixt wrote:\n\n> I don't know what I tested last week; most likely not the version of the\n> patch I quoted above.\n>\n> Today's version, with the tip at 5d7f59c391ce, is definitely bogus\n> with its quoting. It needs the patch below, otherwise an unquoted\n> semicolon may be expanded from $(pathsep). This would terminate the sed\n> command, of course.\n\nThanks for checking! The patch that you quoted above looks like it's from\nthis \"v4\" thread; however, the patch that you are diffing against in your\nlatest reply seems like it is from an earlier version.\n\nI believe that the $(pathsep) changes in your proposed patch are already\npresent in v4, having been caught by Johannes, so perhaps you were using\nan older version of the patch as the diffbase? That change only appeared in\nv4, so any older version would have had the previous incorrect quoting.\n\nI think the reason that is necessary to remove the single quotes is not\nbecause the \";\" is terminating the `sed` expression, but because it's\nterminating the entire shell stanza, causing the shell to execute two\ncommands:\n\n1) {\"sed\" \"-e\" \"s=@@PATHSEP@@=\"}\n2) {\"=g\" \"-e\" \"s=@@INSTLIBDIR@@=...\" ...}\n\nBy including the \";\" within the single-tick-protected `sed` argument, the\nshell receives the entire block, \"s=@@PATHSEP@@=;=\", as a single string.\n\nAlso see Johannes' explanation here:\nhttps://github.com/danjacques/git/pull/1/commits/57dc265478692ea2a395fc61fa122cb73ce58dc3\n\nCould you apply this v4 patch series and confirm that it is working for\nyou? Or, if I am mistaken and your patch is correctly against this \"v4\"\npatch series, let me know and I'll try and figure out what I'm missing.\n\nThanks again!\n-Dan\n"},{"id":"334223","messageId":"xmqq7eu0j1th.fsf@gitster.mtv.corp.google.com","threadId":"47346","inReplyTo":"20171205212625.6616-1-dnj@google.com","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-05T21:35:06Z","receivedAt":"2017-12-05T21:35:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dan Jacques <dnj@google.com> writes:\n\n> Thanks for checking! The patch that you quoted above looks like it's from\n> this \"v4\" thread; however, the patch that you are diffing against in your\n> latest reply seems like it is from an earlier version.\n>\n> I believe that the $(pathsep) changes in your proposed patch are already\n> present in v4,...\n\nYou're of course right.  The patches I had in my tree are outdated.\n\nWill replace, even though I won't be merging them to 'pu' while we\nwait for Ævar's perl build procedure update to stabilize.\n\nThanks.\n"},{"id":"334264","messageId":"e0a22ee4-9503-760f-293c-be56fa46fa04@kdbg.org","threadId":"47346","inReplyTo":"xmqq7eu0j1th.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-12-06T18:25:25Z","receivedAt":"2017-12-06T18:25:49Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 05.12.2017 um 22:35 schrieb Junio C Hamano:\n> Dan Jacques <dnj@google.com> writes:\n> \n>> Thanks for checking! The patch that you quoted above looks like it's from\n>> this \"v4\" thread; however, the patch that you are diffing against in your\n>> latest reply seems like it is from an earlier version.\n>>\n>> I believe that the $(pathsep) changes in your proposed patch are already\n>> present in v4,...\n> \n> You're of course right.  The patches I had in my tree are outdated.\n> \n> Will replace, even though I won't be merging them to 'pu' while we\n> wait for Ævar's perl build procedure update to stabilize.\n\nThe updated series works for me now. Nevertheless, I suggest to squash\nin the following change to protect against IFS and globbing characters in\n$INSTLIBDIR.\n\ndiff --git a/Makefile b/Makefile\nindex 7ac4458f11..08c78a1a63 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2072,7 +2072,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n-\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n+\t    -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n \t    -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n \t    -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n \t    $< >$@+ && \\\n"},{"id":"334267","messageId":"xmqqd13rhewu.fsf@gitster.mtv.corp.google.com","threadId":"47346","inReplyTo":"e0a22ee4-9503-760f-293c-be56fa46fa04@kdbg.org","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-06T18:47:29Z","receivedAt":"2017-12-06T18:47:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> The updated series works for me now. Nevertheless, I suggest to squash\n> in the following change to protect against IFS and globbing characters in\n> $INSTLIBDIR.\n\nYeah, that is very sensible.\n\n> diff --git a/Makefile b/Makefile\n> index 7ac4458f11..08c78a1a63 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2072,7 +2072,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n>  \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>  \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n>  \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n> -\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> +\t    -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n>  \t    -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n>  \t    -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n>  \t    $< >$@+ && \\\n"},{"id":"334268","messageId":"CAD1RUU8BO7J=rV6XgLZ0xN-ikLsanwqHVBnRE9468xVE5EEMvA@mail.gmail.com","threadId":"47346","inReplyTo":"xmqqd13rhewu.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Daniel Jacques","fromEmail":"dnj@google.com","sentAt":"2017-12-06T18:56:27Z","receivedAt":"2017-12-06T18:57:06Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"On Wed, Dec 6, 2017 at 1:47 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Johannes Sixt <j6t@kdbg.org> writes:\n>\n> > The updated series works for me now. Nevertheless, I suggest to squash\n> > in the following change to protect against IFS and globbing characters in\n> > $INSTLIBDIR.\n>\n> Yeah, that is very sensible.\n>\n> > diff --git a/Makefile b/Makefile\n> > index 7ac4458f11..08c78a1a63 100644\n> > --- a/Makefile\n> > +++ b/Makefile\n> > @@ -2072,7 +2072,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n> >       INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n> >       INSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n> >       sed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n> > -         -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> > +         -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n> >           -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n> >           -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n> >           $< >$@+ && \\\n\nSounds good; I'll apply that to my working patch and include it in my\nnext (\"v5\") submission, which is currently blocked pending avarab@'s Perl\nMakefile changes:\nhttps://public-inbox.org/git/20171129195430.10069-1-avarab@gmail.com/T/#t\n"},{"id":"334269","messageId":"CACBZZX4JKhprF-3L3===XOBJ3Gp7W2xbeJshZFAmnjwevs0JoQ@mail.gmail.com","threadId":"47346","inReplyTo":"CAD1RUU8BO7J=rV6XgLZ0xN-ikLsanwqHVBnRE9468xVE5EEMvA@mail.gmail.com","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-06T19:01:14Z","receivedAt":"2017-12-06T19:02:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Wed, Dec 6, 2017 at 7:56 PM, Daniel Jacques <dnj@google.com> wrote:\n> On Wed, Dec 6, 2017 at 1:47 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> Johannes Sixt <j6t@kdbg.org> writes:\n>>\n>> > The updated series works for me now. Nevertheless, I suggest to squash\n>> > in the following change to protect against IFS and globbing characters in\n>> > $INSTLIBDIR.\n>>\n>> Yeah, that is very sensible.\n>>\n>> > diff --git a/Makefile b/Makefile\n>> > index 7ac4458f11..08c78a1a63 100644\n>> > --- a/Makefile\n>> > +++ b/Makefile\n>> > @@ -2072,7 +2072,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n>> >       INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>> >       INSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n>> >       sed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n>> > -         -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n>> > +         -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n>> >           -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n>> >           -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n>> >           $< >$@+ && \\\n>\n> Sounds good; I'll apply that to my working patch and include it in my\n> next (\"v5\") submission, which is currently blocked pending avarab@'s Perl\n> Makefile changes:\n> https://public-inbox.org/git/20171129195430.10069-1-avarab@gmail.com/T/#t\n\nThanks, FWIW I'll send another version of that at the end of the week\nor so, I'm waiting to see if there's any more comments on it to reduce\nlist churn.\n"},{"id":"334502","messageId":"87fu8kex9s.fsf@evledraar.gmail.com","threadId":"47346","inReplyTo":"CACBZZX4JKhprF-3L3===XOBJ3Gp7W2xbeJshZFAmnjwevs0JoQ@mail.gmail.com","subject":"Re: [PATCH v4 1/4] Makefile: generate Perl header from template file","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-08T21:15:59Z","receivedAt":"2017-12-08T21:16:11Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Dec 06 2017, Ævar Arnfjörð Bjarmason jotted:\n\n> On Wed, Dec 6, 2017 at 7:56 PM, Daniel Jacques <dnj@google.com> wrote:\n>> On Wed, Dec 6, 2017 at 1:47 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>>>\n>>> Johannes Sixt <j6t@kdbg.org> writes:\n>>>\n>>> > The updated series works for me now. Nevertheless, I suggest to squash\n>>> > in the following change to protect against IFS and globbing characters in\n>>> > $INSTLIBDIR.\n>>>\n>>> Yeah, that is very sensible.\n>>>\n>>> > diff --git a/Makefile b/Makefile\n>>> > index 7ac4458f11..08c78a1a63 100644\n>>> > --- a/Makefile\n>>> > +++ b/Makefile\n>>> > @@ -2072,7 +2072,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n>>> >       INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>>> >       INSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n>>> >       sed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n>>> > -         -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n>>> > +         -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n>>> >           -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n>>> >           -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n>>> >           $< >$@+ && \\\n>>\n>> Sounds good; I'll apply that to my working patch and include it in my\n>> next (\"v5\") submission, which is currently blocked pending avarab@'s Perl\n>> Makefile changes:\n>> https://public-inbox.org/git/20171129195430.10069-1-avarab@gmail.com/T/#t\n>\n> Thanks, FWIW I'll send another version of that at the end of the week\n> or so, I'm waiting to see if there's any more comments on it to reduce\n> list churn.\n\nSorry, I got this conflated with my sha1collisiondetection series, I\nhave nothing new to send out.\n\nIt seems everyone's happy with the version of my v2 (with Junio's\n<xmqqzi6ympi9.fsf@gitster.mtv.corp.google.com> on top) from this series,\nso it's just a matter of waiting.\n"},{"id":"345520","messageId":"20180423232326.GB25128@aiede.svl.corp.google.com","threadId":"47346","inReplyTo":"e0a22ee4-9503-760f-293c-be56fa46fa04@kdbg.org","subject":"[PATCH dj/runtime-prefix 0/2] Handle $IFS in $INSTLIBDIR","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-04-23T23:23:26Z","receivedAt":"2018-04-23T23:23:32Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nJohannes Sixt wrote:\n> Am 05.12.2017 um 22:35 schrieb Junio C Hamano:\n> > Dan Jacques <dnj@google.com> writes:\n\n>>> Thanks for checking! The patch that you quoted above looks like it's from\n>>> this \"v4\" thread; however, the patch that you are diffing against in your\n>>> latest reply seems like it is from an earlier version.\n>>>\n>>> I believe that the $(pathsep) changes in your proposed patch are already\n>>> present in v4,...\n>>\n>> You're of course right.  The patches I had in my tree are outdated.\n>>\n>> Will replace, even though I won't be merging them to 'pu' while we\n>> wait for Ævar's perl build procedure update to stabilize.\n>\n> The updated series works for me now. Nevertheless, I suggest to squash\n> in the following change to protect against IFS and globbing characters in\n> $INSTLIBDIR.\n>\n> diff --git a/Makefile b/Makefile\n> index 7ac4458f11..08c78a1a63 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2072,7 +2072,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES perl/perl.mak Makefile\n>  \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>  \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n>  \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n> -\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> +\t    -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n>  \t    -e 's=@@GITEXECDIR@@=$(gitexecdir_relative_SQ)=g' \\\n>  \t    -e 's=@@PERLLIBDIR@@=$(perllibdir_relative_SQ)=g' \\\n\nI just ran into this.  Here's a pair of patches to fix it.\n\nThanks,\nJonathan Nieder (2):\n  Makefile: remove unused substitution variable @@PERLLIBDIR@@\n  Makefile: quote $INSTLIBDIR when passing it to sed\n\n Makefile | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\n-- \n2.17.0.441.gb46fe60e1d\n\n"},{"id":"345522","messageId":"20180423232422.GC25128@aiede.svl.corp.google.com","threadId":"47346","inReplyTo":"20180423232326.GB25128@aiede.svl.corp.google.com","subject":"[PATCH 1/2] Makefile: remove unused @@PERLLIBDIR@@ substitution variable","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-04-23T23:24:22Z","receivedAt":"2018-04-23T23:24:28Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio noticed that this variable is not quoted correctly when it is\npassed to sed.  As a shell-quoted string, it should be inside\nsingle-quotes like $(perllibdir_relative_SQ), not outside them like\n$INSTLIBDIR.\n\nIn fact, this substitution variable is not used.  Simplify by removing\nit.\n\nReported-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nAn unrelated cleanup noticed while looking over this code.\n\n Makefile | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 154929f1c8..8f4cb506ff 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2109,7 +2109,6 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile\n \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n \t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n-\t    -e 's=@@PERLLIBDIR@@='$(perllibdir_SQ)'=g' \\\n \t    -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \\\n \t    -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \\\n \t    -e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \\\n-- \n2.17.0.441.gb46fe60e1d\n\n"},{"id":"345524","messageId":"20180423232535.GD25128@aiede.svl.corp.google.com","threadId":"47346","inReplyTo":"20180423232326.GB25128@aiede.svl.corp.google.com","subject":"[PATCH 2/2] Makefile: quote $INSTLIBDIR when passing it to sed","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-04-23T23:25:35Z","receivedAt":"2018-04-23T23:25:40Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"f6a0ad4b (Makefile: generate Perl header from template file,\n2018-04-10) moved code for generating the 'use lib' lines at the top\nof perl scripts from the $(SCRIPT_PERL_GEN) rule to a separate\nGIT-PERL-HEADER rule.\n\nThis rule first populates INSTLIBDIR and then substitutes it into the\nGIT-PERL-HEADER using sed:\n\n\tINSTLIBDIR=... something ...\n\tsed -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' $< > $@\n\nBecause $INSTLIBDIR is not surrounded by double quotes, the shell\nsplits it at each space, causing errors if INSTLIBDIR contains an $IFS\ncharacter:\n\n sed: 1: \"s=@@INSTLIBDIR@@=/usr/l ...\": unescaped newline inside substitute pattern\n\nAdd back the missing double-quotes to make it work again.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nThanks for reading.\n\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 8f4cb506ff..727eca5d0a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2108,7 +2108,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile\n \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n-\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n+\t    -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n \t    -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \\\n \t    -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \\\n \t    -e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \\\n-- \n2.17.0.441.gb46fe60e1d\n\n"},{"id":"345588","messageId":"xmqqin8h8lx7.fsf@gitster-ct.c.googlers.com","threadId":"47346","inReplyTo":"20180423232535.GD25128@aiede.svl.corp.google.com","subject":"Re: [PATCH 2/2] Makefile: quote $INSTLIBDIR when passing it to sed","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-04-24T00:53:24Z","receivedAt":"2018-04-24T00:53:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> diff --git a/Makefile b/Makefile\n> index 8f4cb506ff..727eca5d0a 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2108,7 +2108,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile\n>  \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>  \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n>  \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n> -\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> +\t    -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n\nGood find.  FWIW, I'd find it a lot easier to read if the whole\nthing were enclosed inside a single pair of dq.\n\n"},{"id":"345597","messageId":"xmqqin8h73qb.fsf@gitster-ct.c.googlers.com","threadId":"47346","inReplyTo":"20180423232422.GC25128@aiede.svl.corp.google.com","subject":"Re: [PATCH 1/2] Makefile: remove unused @@PERLLIBDIR@@ substitution variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-04-24T02:11:40Z","receivedAt":"2018-04-24T02:11:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Junio noticed that this variable is not quoted correctly when it is\n> passed to sed.  As a shell-quoted string, it should be inside\n> single-quotes like $(perllibdir_relative_SQ), not outside them like\n> $INSTLIBDIR.\n\nSpreading credit is very much appreciated, but in this case the\nabove belongs below the three-dash fold, I would think, as the\nincorrect quoting become irrelevant.\n\nWill queue.  Thanks.\n\n> In fact, this substitution variable is not used.  Simplify by removing\n> it.\n>\n> Reported-by: Junio C Hamano <gitster@pobox.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n> An unrelated cleanup noticed while looking over this code.\n>\n>  Makefile | 1 -\n>  1 file changed, 1 deletion(-)\n>\n> diff --git a/Makefile b/Makefile\n> index 154929f1c8..8f4cb506ff 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2109,7 +2109,6 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile\n>  \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n>  \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n>  \t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> -\t    -e 's=@@PERLLIBDIR@@='$(perllibdir_SQ)'=g' \\\n>  \t    -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \\\n>  \t    -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \\\n>  \t    -e 's=@@LOCALEDIR_REL@@=$(localedir_relative_SQ)=g' \\\n"},{"id":"345598","messageId":"20180424021834.GE25128@aiede.svl.corp.google.com","threadId":"47346","inReplyTo":"xmqqin8h8lx7.fsf@gitster-ct.c.googlers.com","subject":"[PATCH 2/2 v2] Makefile: quote $INSTLIBDIR when passing it to sed","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-04-24T02:18:34Z","receivedAt":"2018-04-24T02:18:40Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"f6a0ad4b (Makefile: generate Perl header from template file,\n2018-04-10) moved some code for generating the 'use lib' lines at the\ntop of perl scripts from the $(SCRIPT_PERL_GEN) rule to a separate\nGIT-PERL-HEADER rule.\n\nThis rule first populates INSTLIBDIR and then substitutes it into the\nGIT-PERL-HEADER using sed:\n\n\tINSTLIBDIR=... something ...\n\tsed -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' $< > $@\n\nBecause $INSTLIBDIR is not surrounded by double quotes, the shell\nsplits it at each space, causing errors if INSTLIBDIR contains a\nspace:\n\n sed: 1: \"s=@@INSTLIBDIR@@=/usr/l ...\": unescaped newline inside substitute pattern\n\nAdd back the missing double-quotes to make it work again.\n\nImproved-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nHi,\n\nJunio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n\n>> +++ b/Makefile\n>> @@ -2108,7 +2108,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile\n>>  \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n>>  \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n>>  \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n>> -\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n>> +\t    -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n>\n> Good find.  FWIW, I'd find it a lot easier to read if the whole\n> thing were enclosed inside a single pair of dq.\n\nThanks. I agree, so here's an updated version doing that.\n\n Makefile | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Makefile b/Makefile\nindex 2327ccb906..5e25441861 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2116,7 +2116,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile\n \tINSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n \tINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n \tsed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n-\t    -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n+\t    -e \"s=@@INSTLIBDIR@@=$$INSTLIBDIR=g\" \\\n \t    -e 's=@@PERLLIBDIR@@='$(perllibdir_SQ)'=g' \\\n \t    -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \\\n \t    -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \\\n-- \n2.17.0.441.gb46fe60e1d\n\n"},{"id":"345601","messageId":"CAD1RUU_W_Caa7pbM6Nvxe4yAYeXZB3vvRYEURvvmAgHzxM=sPQ@mail.gmail.com","threadId":"47346","inReplyTo":"20180424021834.GE25128@aiede.svl.corp.google.com","subject":"Re: [PATCH 2/2 v2] Makefile: quote $INSTLIBDIR when passing it to sed","fromName":"Daniel Jacques","fromEmail":"dnj@google.com","sentAt":"2018-04-24T02:56:43Z","receivedAt":"2018-04-24T02:57:06Z","isPatch":true,"sender":{"key":"dnj@google.com","avatar":"https://avatars.githubusercontent.com/u/9965104?v=4"},"body":"Good catch, thanks for doing this!\n-Dan\nOn Mon, Apr 23, 2018 at 10:18 PM Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n> f6a0ad4b (Makefile: generate Perl header from template file,\n> 2018-04-10) moved some code for generating the 'use lib' lines at the\n> top of perl scripts from the $(SCRIPT_PERL_GEN) rule to a separate\n> GIT-PERL-HEADER rule.\n\n> This rule first populates INSTLIBDIR and then substitutes it into the\n> GIT-PERL-HEADER using sed:\n\n>          INSTLIBDIR=... something ...\n>          sed -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' $< > $@\n\n> Because $INSTLIBDIR is not surrounded by double quotes, the shell\n> splits it at each space, causing errors if INSTLIBDIR contains a\n> space:\n\n>   sed: 1: \"s=@@INSTLIBDIR@@=/usr/l ...\": unescaped newline inside\nsubstitute pattern\n\n> Add back the missing double-quotes to make it work again.\n\n> Improved-by: Junio C Hamano <gitster@pobox.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n> Hi,\n\n> Junio C Hamano wrote:\n> > Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> >> +++ b/Makefile\n> >> @@ -2108,7 +2108,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE)\nGIT-PERL-DEFINES Makefile\n> >>      INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n> >>\n  INSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n> >>      sed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n> >> -        -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> >> +        -e 's=@@INSTLIBDIR@@='\"$$INSTLIBDIR\"'=g' \\\n> >\n> > Good find.  FWIW, I'd find it a lot easier to read if the whole\n> > thing were enclosed inside a single pair of dq.\n\n> Thanks. I agree, so here's an updated version doing that.\n\n>   Makefile | 2 +-\n>   1 file changed, 1 insertion(+), 1 deletion(-)\n\n> diff --git a/Makefile b/Makefile\n> index 2327ccb906..5e25441861 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -2116,7 +2116,7 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE)\nGIT-PERL-DEFINES Makefile\n>          INSTLIBDIR_EXTRA='$(PERLLIB_EXTRA_SQ)' && \\\n\nINSTLIBDIR=\"$$INSTLIBDIR$${INSTLIBDIR_EXTRA:+:$$INSTLIBDIR_EXTRA}\" && \\\n>          sed -e 's=@@PATHSEP@@=$(pathsep)=g' \\\n> -           -e 's=@@INSTLIBDIR@@='$$INSTLIBDIR'=g' \\\n> +           -e \"s=@@INSTLIBDIR@@=$$INSTLIBDIR=g\" \\\n>              -e 's=@@PERLLIBDIR@@='$(perllibdir_SQ)'=g' \\\n>              -e 's=@@PERLLIBDIR_REL@@=$(perllibdir_relative_SQ)=g' \\\n>              -e 's=@@GITEXECDIR_REL@@=$(gitexecdir_relative_SQ)=g' \\\n> --\n> 2.17.0.441.gb46fe60e1d\n"}]}