{"thread":{"id":"51584","subject":"[PATCH 0/6] Port git to Plan 9","startedAt":"2019-08-03T23:52:13Z","lastAt":"2019-08-27T13:46:23Z","messageCount":17,"participants":["KADOTA, Kyohei via GitGitGadget","lufia via GitGitGadget","brian m. carlson","Kyohei Kadota","Jonathan Nieder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"379896","messageId":"pull.305.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":null,"subject":"[PATCH 0/6] Port git to Plan 9","fromName":"KADOTA, Kyohei via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-03T23:52:08Z","receivedAt":"2019-08-03T23:52:13Z","isPatch":true,"sender":{"key":"name:KADOTA, Kyohei","avatar":null},"body":"I ported git, and git subcommands only written in C to Plan 9. This pull\nrequest contains patches for existing codes, and new files to build git in\nPlan 9.\n\nAll build options such as NO_PERL are not supported yet, and also some git\nsubcommands written not in C is not available yet. But git can synchronize\nto remote repository with git pull and git push via HTTPS.\n\nThis pull request don't contain a part of Git toolchain for example\ngit-credential-store, etc. So I'm going to port other parts of Git toolchain\ntoo in the future.\n\nWhole installing process is published at \nhttps://medium.com/@lufia/14fee2ad7493\n\nlufia (6):\n  Change HOME, PATH, and .gitconfig paths to be customizable\n  Fix C syntactic errors for the Plan 9 C compiler\n  GIT-VERSION-GEN: Use sed instead of expr\n  Port generate-cmdline.sh to rc\n  Add plan9/wrap.c\n  Add mkfile to build git and subcommands for Plan 9\n\n GIT-VERSION-GEN               |   2 +-\n Makefile                      |  26 ++++-\n builtin/config.c              |   2 +-\n compat/plan9/openssl/crypto.h |   5 +\n compat/regex/regex_internal.h |   3 +\n config.c                      |   5 +-\n credential-cache.c            |   2 +-\n credential-store.c            |   2 +-\n exec-cmd.c                    |   4 +-\n generate-cmdlist.rc           | 102 ++++++++++++++++++\n git-compat-util.h             |  17 ++-\n help.c                        |   2 +-\n mkfile                        | 195 ++++++++++++++++++++++++++++++++++\n parse-options.h               |  18 ++--\n path.c                        |   6 +-\n plan9/wrap.c                  |  16 +++\n remove-bitfields.rc           |  14 +++\n run-command.c                 |   4 +-\n sequencer.c                   |   2 +-\n shell.c                       |   2 +-\n 20 files changed, 402 insertions(+), 27 deletions(-)\n create mode 100644 compat/plan9/openssl/crypto.h\n create mode 100755 generate-cmdlist.rc\n create mode 100644 mkfile\n create mode 100644 plan9/wrap.c\n create mode 100644 remove-bitfields.rc\n\n\nbase-commit: f36d08d72e7f68f880f8c1d7646cb3809c820485\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-305%2Flufia%2Fplan9-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-305/lufia/plan9-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/305\n-- \ngitgitgadget\n"},{"id":"379897","messageId":"301a796de9e853f9b0e398bc0d0c54a737a2f2c0.1564876327.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.git.gitgitgadget@gmail.com","subject":"[PATCH 2/6] Fix C syntactic errors for the Plan 9 C compiler","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-03T23:52:10Z","receivedAt":"2019-08-03T23:52:15Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n compat/plan9/openssl/crypto.h |  5 +++++\n compat/regex/regex_internal.h |  3 +++\n config.c                      |  3 ++-\n git-compat-util.h             |  9 ++++++++-\n parse-options.h               | 18 +++++++++---------\n remove-bitfields.rc           | 14 ++++++++++++++\n 6 files changed, 41 insertions(+), 11 deletions(-)\n create mode 100644 compat/plan9/openssl/crypto.h\n create mode 100644 remove-bitfields.rc\n\ndiff --git a/compat/plan9/openssl/crypto.h b/compat/plan9/openssl/crypto.h\nnew file mode 100644\nindex 0000000000..9d1ef43422\n--- /dev/null\n+++ b/compat/plan9/openssl/crypto.h\n@@ -0,0 +1,5 @@\n+#ifndef __attribute__\n+#define __attribute__(x)\n+#endif\n+\n+#include_next <openssl/crypto.h>\ndiff --git a/compat/regex/regex_internal.h b/compat/regex/regex_internal.h\nindex 3ee8aae59d..7313c747a6 100644\n--- a/compat/regex/regex_internal.h\n+++ b/compat/regex/regex_internal.h\n@@ -26,6 +26,9 @@\n #include <stdlib.h>\n #include <string.h>\n \n+#ifdef NEEDS_SYS_PARAM_H\n+#include <sys/param.h>\n+#endif\n #if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC\n # include <langinfo.h>\n #endif\ndiff --git a/config.c b/config.c\nindex f67cef5cf8..993f9f57be 100644\n--- a/config.c\n+++ b/config.c\n@@ -2461,7 +2461,8 @@ static int store_aux_event(enum config_event_t type,\n \t\t\treturn error(_(\"invalid section name '%s'\"), cf->var.buf);\n \n \t\tif (cf->subsection_case_sensitive)\n-\t\t\tcmpfn = strncasecmp;\n+\t\t\t/* Plan 9's strncasecmp is typed (char*, char*, int) */\n+\t\t\tcmpfn = (int (*)(const char*, const char*, size_t))strncasecmp;\n \t\telse\n \t\t\tcmpfn = strncmp;\n \ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex f8fdd79591..1aa7877af4 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -164,7 +164,11 @@\n #define GIT_WINDOWS_NATIVE\n #endif\n \n+#include <sys/types.h>\n #include <unistd.h>\n+#ifdef __PLAN9__\n+#include <libv.h>\n+#endif\n #include <stdio.h>\n #include <sys/stat.h>\n #include <fcntl.h>\n@@ -180,7 +184,6 @@\n #ifdef NEEDS_SYS_PARAM_H\n #include <sys/param.h>\n #endif\n-#include <sys/types.h>\n #include <dirent.h>\n #include <sys/time.h>\n #include <time.h>\n@@ -282,6 +285,10 @@ char *gitbasename(char *);\n char *gitdirname(char *);\n #endif\n \n+#ifdef __PLAN9__\n+#include <machine/endian.h>\n+#endif\n+\n #ifndef NO_ICONV\n #include <iconv.h>\n #endif\ndiff --git a/parse-options.h b/parse-options.h\nindex a4bd40bb6a..38a33a087e 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -46,6 +46,15 @@ enum parse_opt_option_flags {\n \tPARSE_OPT_COMP_ARG = 1024\n };\n \n+enum parse_opt_result {\n+\tPARSE_OPT_COMPLETE = -3,\n+\tPARSE_OPT_HELP = -2,\n+\tPARSE_OPT_ERROR = -1,\t/* must be the same as error() */\n+\tPARSE_OPT_DONE = 0,\t/* fixed so that \"return 0\" works */\n+\tPARSE_OPT_NON_OPTION,\n+\tPARSE_OPT_UNKNOWN\n+};\n+\n struct option;\n typedef int parse_opt_cb(const struct option *, const char *arg, int unset);\n \n@@ -241,15 +250,6 @@ const char *optname(const struct option *opt, int flags);\n \n /*----- incremental advanced APIs -----*/\n \n-enum parse_opt_result {\n-\tPARSE_OPT_COMPLETE = -3,\n-\tPARSE_OPT_HELP = -2,\n-\tPARSE_OPT_ERROR = -1,\t/* must be the same as error() */\n-\tPARSE_OPT_DONE = 0,\t/* fixed so that \"return 0\" works */\n-\tPARSE_OPT_NON_OPTION,\n-\tPARSE_OPT_UNKNOWN\n-};\n-\n /*\n  * It's okay for the caller to consume argv/argc in the usual way.\n  * Other fields of that structure are private to parse-options and should not\ndiff --git a/remove-bitfields.rc b/remove-bitfields.rc\nnew file mode 100644\nindex 0000000000..897f98da10\n--- /dev/null\n+++ b/remove-bitfields.rc\n@@ -0,0 +1,14 @@\n+#!/bin/rc\n+# Plan 9 C compiler rejects initialization a structure including bit field.\n+# usage: remove-bitfields.rc [dir ...]\n+\n+fn sigexit sighup sigint sigquit sigterm {\n+\trm -f /tmp/remove-bitfields.$pid\n+\texit\n+}\n+\n+files=`{du -a $* | awk '/\\.[ch]$/ { print $2 }'}\n+for(i in $files){\n+\tsed '/(^[ \t]*\\*|\\?)/!s/([a-z]+[a-z0-9]*) *: *[0-9]+([,;])/\\1\\2/g' $i >/tmp/remove-bitfields.$pid\n+\tcp /tmp/remove-bitfields.$pid $i\n+}\n-- \ngitgitgadget\n\n"},{"id":"379898","messageId":"d25bcb43e1d8fe68717c6df57063427ab5a142f4.1564876327.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.git.gitgitgadget@gmail.com","subject":"[PATCH 4/6] Port generate-cmdline.sh to rc","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-03T23:52:12Z","receivedAt":"2019-08-03T23:52:15Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n generate-cmdlist.rc | 102 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 102 insertions(+)\n create mode 100755 generate-cmdlist.rc\n\ndiff --git a/generate-cmdlist.rc b/generate-cmdlist.rc\nnew file mode 100755\nindex 0000000000..18699ea9c4\n--- /dev/null\n+++ b/generate-cmdlist.rc\n@@ -0,0 +1,102 @@\n+#!/bin/rc\n+\n+rfork e\n+\n+fn die {\n+\techo $* >[1=2]\n+\texit die\n+}\n+\n+fn command_list {\n+\tgrep -v '^#' $1\n+}\n+\n+fn get_categories {\n+\ttr ' ' '\\x0a'|\n+\tgrep -v '^$' |\n+\tsort |\n+\tuniq\n+}\n+\n+fn category_list {\n+\tcommand_list $1 |\n+\tawk '{ print substr($0, 40) }' |\n+\tget_categories\n+}\n+\n+fn get_synopsis {\n+\tsed -n '\n+\t\t/^NAME/,/'$1'/h\n+\t\t${\n+\t\t\tx\n+\t\t\ts/.*'$1' - (.*)/N_\\(\"\\1\"\\)/\n+\t\t\tp\n+\t\t}' Documentation/$1.txt\n+}\n+\n+fn define_categories {\n+\techo\n+\techo '/* Command categories */'\n+\tbit=0\n+\tcategory_list $1 |\n+\twhile(cat=`{read}){\n+\t\techo '#define CAT_'$\"cat' (1UL << '$bit')'\n+\t\tbit=`{hoc -e $bit' + 1'}\n+\t}\n+\ttest $bit -gt 32 && die 'Urgh.. too many categories?'\n+}\n+\n+fn define_category_names {\n+\techo\n+\techo '/* Category names */'\n+\techo 'static const char *category_names[] = {'\n+\tbit=0\n+\tcategory_list $1 |\n+\twhile(cat=`{read}){\n+\t\techo '\t\"'$\"cat'\", /* (1UL << '$bit') */'\n+\t\tbit=`{hoc -e $bit' + 1'}\n+\t}\n+\techo '\tNULL,'\n+\techo '};'\n+}\n+\n+fn print_command_list {\n+\techo 'static struct cmdname_help command_list[] = {'\n+\n+\tcommand_list $1 |\n+\twhile(a=`{read}){\n+\t\ts=`{get_synopsis $a(1)}\n+\t\tq=`{seq 2 $#a}\n+\t\techo -n '\t{ \"'^$a(1)^'\", '$\"s', 0'\n+\t\tfor(cat in `{echo $a($q) | get_categories})\n+\t\t\techo -n ' | CAT_'^$cat\n+\t\techo ' },'\n+\t}\n+\techo '};'\n+}\n+\n+fn print_config_list {\n+\techo 'static const char *config_name_list[] = {'\n+\tgrep -h '^[a-zA-Z].*\\..*::$' Documentation/*config.txt Documentation/config/*.txt |\n+\tsed '/deprecated/d; s/::$//; s/,  */\\n/g' |\n+\tsort |\n+\twhile(line=`{read})\n+\t\techo '\t\"'$\"line'\",'\n+\techo '\tNULL'\n+\techo '};'\n+}\n+\n+echo '/* Automatically generated by generate-cmdlist.sh */\n+struct cmdname_help {\n+\tconst char *name;\n+\tconst char *help;\n+\tuint32_t category;\n+};\n+'\n+define_categories $1\n+echo\n+define_category_names $1\n+echo\n+print_command_list $1\n+echo\n+print_config_list\n-- \ngitgitgadget\n\n"},{"id":"379899","messageId":"fa539c75b29f0ba5433a52bec5c7679476e15e8b.1564876327.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.git.gitgitgadget@gmail.com","subject":"[PATCH 1/6] Change HOME, PATH, and .gitconfig paths to be customizable","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-03T23:52:09Z","receivedAt":"2019-08-03T23:52:17Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nIn Plan 9, almost environment variables are not capitalized.\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n Makefile           | 26 +++++++++++++++++++++++++-\n builtin/config.c   |  2 +-\n config.c           |  2 +-\n credential-cache.c |  2 +-\n credential-store.c |  2 +-\n exec-cmd.c         |  4 ++--\n git-compat-util.h  |  8 ++++++++\n help.c             |  2 +-\n path.c             |  6 +++---\n run-command.c      |  4 ++--\n sequencer.c        |  2 +-\n shell.c            |  2 +-\n 12 files changed, 47 insertions(+), 15 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex bd246f2989..721364efba 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -541,6 +541,9 @@ template_dir = share/git-core/templates\n htmldir = $(prefix)/share/doc/git-doc\n ETC_GITCONFIG = $(sysconfdir)/gitconfig\n ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes\n+USER_GITCONFIG = ~/.gitconfig\n+USER_GITCREDENTIALS = ~/.git-credentials\n+USER_GITCREDENTIAL_CACHE = ~/.git-credential-cache\n lib = lib\n # DESTDIR =\n pathsep = :\n@@ -1910,6 +1913,9 @@ endif\n \n ETC_GITCONFIG_SQ = $(subst ','\\'',$(ETC_GITCONFIG))\n ETC_GITATTRIBUTES_SQ = $(subst ','\\'',$(ETC_GITATTRIBUTES))\n+USER_GITCONFIG_SQ = $(subst ','\\'',$(USER_GITCONFIG))\n+USER_GITCREDENTIALS_SQ = $(subst ','\\'',$(USER_GITCREDENTIALS))\n+USER_GITCREDENTIAL_CACHE_SQ = $(subst ','\\'',$(USER_GITCREDENTIAL_CACHE))\n \n DESTDIR_SQ = $(subst ','\\'',$(DESTDIR))\n bindir_SQ = $(subst ','\\'',$(bindir))\n@@ -2400,12 +2406,30 @@ builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n \n config.sp config.s config.o: GIT-PREFIX\n config.sp config.s config.o: EXTRA_CPPFLAGS = \\\n-\t-DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n+\t-DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"' \\\n+\t-DUSER_GITCONFIG='\"$(USER_GITCONFIG_SQ)\"'\n+\n+builtin/config.sp builtin/config.s builtin/config.o: GIT-PREFIX\n+builtin/config.sp builtin/config.s builtin/config.o: EXTRA_CPPFLAGS = \\\n+\t-DUSER_GITCONFIG='\"$(USER_GITCONFIG_SQ)\"'\n+\n+sequencer.sp sequencer.s sequencer.o: GIT-PREFIX\n+sequencer.sp sequencer.s sequencer.o: EXTRA_CPPFLAGS = \\\n+\t-DUSER_GITCONFIG='\"$(USER_GITCONFIG_SQ)\"'\n \n attr.sp attr.s attr.o: GIT-PREFIX\n attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \\\n \t-DETC_GITATTRIBUTES='\"$(ETC_GITATTRIBUTES_SQ)\"'\n \n+credential-cache.sp credential-cache.s credential-cache.o: GIT-PREFIX\n+credential-cache.sp credential-cache.s credential-cache.o: EXTRA_CPPFLAGS = \\\n+\t-DUSER_GITCONFIG='\"$(USER_GITCONFIG_SQ)\"' \\\n+\t-DUSER_GITCREDENTIAL_CACHE='\"$(USER_GITCREDENTIAL_CACHE_SQ)\"'\n+\n+credential-store.sp credential-store.s credential-store.o: GIT-PREFIX\n+credential-store.sp credential-store.s credential-store.o: EXTRA_CPPFLAGS = \\\n+\t-DUSER_GITCREDENTIALS='\"$(USER_GITCREDENTIALS_SQ)\"'\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_relative_SQ)\"'\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 98d65bc0ad..22c4f0ab71 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -625,7 +625,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (use_global_config) {\n-\t\tchar *user_config = expand_user_path(\"~/.gitconfig\", 0);\n+\t\tchar *user_config = expand_user_path(USER_GITCONFIG, 0);\n \t\tchar *xdg_config = xdg_config_home(\"config\");\n \n \t\tif (!user_config)\ndiff --git a/config.c b/config.c\nindex ed7f58e0fc..f67cef5cf8 100644\n--- a/config.c\n+++ b/config.c\n@@ -1699,7 +1699,7 @@ static int do_git_config_sequence(const struct config_options *opts,\n {\n \tint ret = 0;\n \tchar *xdg_config = xdg_config_home(\"config\");\n-\tchar *user_config = expand_user_path(\"~/.gitconfig\", 0);\n+\tchar *user_config = expand_user_path(USER_GITCONFIG, 0);\n \tchar *repo_config;\n \n \tif (opts->commondir)\ndiff --git a/credential-cache.c b/credential-cache.c\nindex 1cccc3a0b9..3e2ed6c0be 100644\n--- a/credential-cache.c\n+++ b/credential-cache.c\n@@ -87,7 +87,7 @@ static char *get_socket_path(void)\n {\n \tstruct stat sb;\n \tchar *old_dir, *socket;\n-\told_dir = expand_user_path(\"~/.git-credential-cache\", 0);\n+\told_dir = expand_user_path(USER_GITCREDENTIAL_CACHE, 0);\n \tif (old_dir && !stat(old_dir, &sb) && S_ISDIR(sb.st_mode))\n \t\tsocket = xstrfmt(\"%s/socket\", old_dir);\n \telse\ndiff --git a/credential-store.c b/credential-store.c\nindex ac295420dd..37256ee942 100644\n--- a/credential-store.c\n+++ b/credential-store.c\n@@ -168,7 +168,7 @@ int cmd_main(int argc, const char **argv)\n \tif (file) {\n \t\tstring_list_append(&fns, file);\n \t} else {\n-\t\tif ((file = expand_user_path(\"~/.git-credentials\", 0)))\n+\t\tif ((file = expand_user_path(USER_GITCREDENTIALS, 0)))\n \t\t\tstring_list_append_nodup(&fns, file);\n \t\tfile = xdg_config_home(\"credentials\");\n \t\tif (file)\ndiff --git a/exec-cmd.c b/exec-cmd.c\nindex 7deeab3039..c95fc8dbdd 100644\n--- a/exec-cmd.c\n+++ b/exec-cmd.c\n@@ -304,7 +304,7 @@ static void add_path(struct strbuf *out, const char *path)\n void setup_path(void)\n {\n \tconst char *exec_path = git_exec_path();\n-\tconst char *old_path = getenv(\"PATH\");\n+\tconst char *old_path = getenv(PATH_ENVIRONMENT);\n \tstruct strbuf new_path = STRBUF_INIT;\n \n \tgit_set_exec_path(exec_path);\n@@ -315,7 +315,7 @@ void setup_path(void)\n \telse\n \t\tstrbuf_addstr(&new_path, _PATH_DEFPATH);\n \n-\tsetenv(\"PATH\", new_path.buf, 1);\n+\tsetenv(PATH_ENVIRONMENT, new_path.buf, 1);\n \n \tstrbuf_release(&new_path);\n }\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 83be89de0a..f8fdd79591 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1238,6 +1238,14 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);\n # define SHELL_PATH \"/bin/sh\"\n #endif\n \n+#ifndef HOME_ENVIRONMENT\n+# define HOME_ENVIRONMENT \"HOME\"\n+#endif\n+\n+#ifndef PATH_ENVIRONMENT\n+# define PATH_ENVIRONMENT \"PATH\"\n+#endif\n+\n #ifndef _POSIX_THREAD_SAFE_FUNCTIONS\n #define flockfile(fh)\n #define funlockfile(fh)\ndiff --git a/help.c b/help.c\nindex 5261d83ecf..6094bfae7d 100644\n--- a/help.c\n+++ b/help.c\n@@ -260,7 +260,7 @@ void load_command_list(const char *prefix,\n \t\tstruct cmdnames *main_cmds,\n \t\tstruct cmdnames *other_cmds)\n {\n-\tconst char *env_path = getenv(\"PATH\");\n+\tconst char *env_path = getenv(PATH_ENVIRONMENT);\n \tconst char *exec_path = git_exec_path();\n \n \tif (exec_path) {\ndiff --git a/path.c b/path.c\nindex 25e97b8c3f..45bde04d37 100644\n--- a/path.c\n+++ b/path.c\n@@ -719,7 +719,7 @@ char *expand_user_path(const char *path, int real_home)\n \t\tconst char *username = path + 1;\n \t\tsize_t username_len = first_slash - username;\n \t\tif (username_len == 0) {\n-\t\t\tconst char *home = getenv(\"HOME\");\n+\t\t\tconst char *home = getenv(HOME_ENVIRONMENT);\n \t\t\tif (!home)\n \t\t\t\tgoto return_null;\n \t\t\tif (real_home)\n@@ -1426,7 +1426,7 @@ char *xdg_config_home(const char *filename)\n \tif (config_home && *config_home)\n \t\treturn mkpathdup(\"%s/git/%s\", config_home, filename);\n \n-\thome = getenv(\"HOME\");\n+\thome = getenv(HOME_ENVIRONMENT);\n \tif (home)\n \t\treturn mkpathdup(\"%s/.config/git/%s\", home, filename);\n \treturn NULL;\n@@ -1441,7 +1441,7 @@ char *xdg_cache_home(const char *filename)\n \tif (cache_home && *cache_home)\n \t\treturn mkpathdup(\"%s/git/%s\", cache_home, filename);\n \n-\thome = getenv(\"HOME\");\n+\thome = getenv(HOME_ENVIRONMENT);\n \tif (home)\n \t\treturn mkpathdup(\"%s/.cache/git/%s\", home, filename);\n \treturn NULL;\ndiff --git a/run-command.c b/run-command.c\nindex 3449db319b..85d7a8c342 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -180,14 +180,14 @@ int is_executable(const char *name)\n  */\n static char *locate_in_PATH(const char *file)\n {\n-\tconst char *p = getenv(\"PATH\");\n+\tconst char *p = getenv(PATH_ENVIRONMENT);\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tif (!p || !*p)\n \t\treturn NULL;\n \n \twhile (1) {\n-\t\tconst char *end = strchrnul(p, ':');\n+\t\tconst char *end = strchrnul(p, PATH_SEP);\n \n \t\tstrbuf_reset(&buf);\n \ndiff --git a/sequencer.c b/sequencer.c\nindex 34ebf8ed94..044b0fabea 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1246,7 +1246,7 @@ N_(\"Your name and email address were configured automatically based\\n\"\n \n static const char *implicit_ident_advice(void)\n {\n-\tchar *user_config = expand_user_path(\"~/.gitconfig\", 0);\n+\tchar *user_config = expand_user_path(USER_GITCONFIG, 0);\n \tchar *xdg_config = xdg_config_home(\"config\");\n \tint config_exists = file_exists(user_config) || file_exists(xdg_config);\n \ndiff --git a/shell.c b/shell.c\nindex 40084a3013..fa844425b9 100644\n--- a/shell.c\n+++ b/shell.c\n@@ -39,7 +39,7 @@ static char *make_cmd(const char *prog)\n \n static void cd_to_homedir(void)\n {\n-\tconst char *home = getenv(\"HOME\");\n+\tconst char *home = getenv(HOME_ENVIRONMENT);\n \tif (!home)\n \t\tdie(\"could not determine user's home directory; HOME is unset\");\n \tif (chdir(home) == -1)\n-- \ngitgitgadget\n\n"},{"id":"379900","messageId":"df67a7e1d307d6a7a91ae1bba085959154006ed1.1564876327.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.git.gitgitgadget@gmail.com","subject":"[PATCH 3/6] GIT-VERSION-GEN: Use sed instead of expr","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-03T23:52:11Z","receivedAt":"2019-08-03T23:52:17Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nPlan 9 don't have expr(1).\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n GIT-VERSION-GEN | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex a0766f64ed..754d4486f5 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -26,7 +26,7 @@ else\n \tVN=\"$DEF_VER\"\n fi\n \n-VN=$(expr \"$VN\" : v*'\\(.*\\)')\n+VN=$(echo \"$VN\" | sed 's/^v*//')\n \n if test -r $GVF\n then\n-- \ngitgitgadget\n\n"},{"id":"379901","messageId":"d00bbdce0d5104f1793b7fa0dce14f678e9fb331.1564876327.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.git.gitgitgadget@gmail.com","subject":"[PATCH 5/6] Add plan9/wrap.c","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-03T23:52:12Z","receivedAt":"2019-08-03T23:52:17Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nPlan 9 has bind(1) instead of ln(1), but bind isn't persisted to the disk.\nHowever it isn't efficient to copy git to git- subcommands such as git-add.\nTherefore Plan 9 needs wrap.c to switch behavior by executable name.\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n plan9/wrap.c | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n create mode 100644 plan9/wrap.c\n\ndiff --git a/plan9/wrap.c b/plan9/wrap.c\nnew file mode 100644\nindex 0000000000..589d13bf5d\n--- /dev/null\n+++ b/plan9/wrap.c\n@@ -0,0 +1,16 @@\n+#include <stdio.h>\n+#include <errno.h>\n+#include <string.h>\n+#define _POSIX_SOURCE\n+#include <unistd.h>\n+\n+int\n+main(int argc, char *argv[])\n+{\n+\tUSED(argc);\n+\tif(execv(\"/bin/git\", argv) < 0){\n+\t\tfprintf(stderr, \"%s: %s\\n\", argv[0], strerror(errno));\n+\t\treturn 1;\n+\t}\n+\treturn 0; /* can't happen */\n+}\n-- \ngitgitgadget\n\n"},{"id":"379902","messageId":"04949713061ba95784b5523c6ce57542a8e87abe.1564876327.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.git.gitgitgadget@gmail.com","subject":"[PATCH 6/6] Add mkfile to build git and subcommands for Plan 9","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-03T23:52:13Z","receivedAt":"2019-08-03T23:52:18Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n mkfile | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 195 insertions(+)\n create mode 100644 mkfile\n\ndiff --git a/mkfile b/mkfile\nnew file mode 100644\nindex 0000000000..f0b06437ed\n--- /dev/null\n+++ b/mkfile\n@@ -0,0 +1,195 @@\n+</sys/src/ape/config\n+\n+CFILES=`{sed -n '/^BUILTIN_OBJS *\\+= *(.*)\\.o$/s//\\1.c/p' Makefile}\n+OFILES=\\\n+\t${CFILES:%.c=%.$O}\\\n+\tcommon-main.$O\\\n+\n+X_CFILES=`{sed -n '/^BUILT_INS *\\+= *git-(.*)\\$X$/s//\\1/p' Makefile}\n+\n+#APP_CFILES=`{sed -n '/^PROGRAM_OBJS *\\+= *(.*)\\.o$/s//\\1.c/p' Makefile}\n+APP_CFILES=\\\n+\tcredential-store.c\\\n+\thttp-fetch.c\\\n+\thttp-push.c\\\n+\n+TARG=\\\n+\tgit\\\n+\t${CFILES:builtin/%.c=git-%}\\\n+\t${X_CFILES:%=git-%}\\\n+\t${APP_CFILES:%.c=git-%}\\\n+\tgit-remote-http\\\n+\tgit-remote-https\\\n+\tgit-remote-ftp\\\n+\tgit-remote-ftps\\\n+\n+# NO_UNIXSOCK\n+#\tgit-credential-cache\\\n+#\tgit-credential-cache--daemon\\\n+\n+#GIT_HOST_CPU=i386|i686|x86_64\n+\n+ROOT=`{pwd}\n+<GIT-VERSION-FILE\n+COMMIT_HASH=`{git rev-parse -q --verify HEAD}\n+\n+# -w flag isn't intentionally set because it is noisy.\n+# -T flag isn't intentionally set.\n+CFLAGS=-FVB+ -c\\\n+\t-I$ROOT\\\n+\t-I$ROOT/compat/plan9\\\n+\t-I$ROOT/compat/regex\\\n+\t-D__PLAN9__\\\n+\t-D_POSIX_SOURCE\\\n+\t-D_BSD_EXTENSION\\\n+\t-D_SUSV2_SOURCE\\\n+\t-D_PLAN9_SOURCE\\\n+\t-D_RESEARCH_SOURCE\\\n+\t-D_REENTRANT_SOURCE\\\n+\t-DHAVE_SOCK_OPTS\\\n+\t-DNO_NSEC\\\n+\t-DNO_SYMLINK_HEAD\\\n+\t-DNO_GECOS_IN_PWENT\\\n+\t-DNO_GETTEXT\\\n+\t-DNO_STRCASESTR\\\n+\t-DNO_STRLCPY\\\n+\t-DNO_STRTOUMAX\\\n+\t-DNO_MBSUPPORT\\\n+\t-DNO_MKDTEMP\\\n+\t-DNO_UNSETENV\\\n+\t-DNEEDS_SYS_PARAM_H\\\n+\t-DNO_INITGROUPS\\\n+\t-DNO_MMAP\\\n+\t-DNO_ST_BLOCKS_IN_STRUCT_STAT\\\n+\t-DNO_STRUCT_ITIMERVAL\\\n+\t-DNO_SETITIMER\\\n+\t-Dsockaddr_storage=sockaddr_in6\\\n+\t-DNO_UNIX_SOCKETS\\\n+\t-DNO_ICONV\\\n+\t-DSHA1_OPENSSL\\\n+\t-DSHA256_OPENSSL\\\n+\t-DNO_MEMMEM\\\n+\t-DHAVE_STDBOOL_H\\\n+\t-DHAVE_STDINT_H\\\n+\t-DHAVE_LOCALE_H\\\n+\t-DHAVE_CLOCK_GETTIME\\\n+\t-DGIT_VERSION=\"$GIT_VERSION\"\\\n+\t-DGIT_BUILT_FROM_COMMIT=\"$COMMIT_HASH\"\\\n+\t-DGIT_USER_AGENT=\"git/$GIT_VERSION\"\\\n+\t-DETC_GITCONFIG=\"/sys/lib/git/config\"\\\n+\t-DETC_GITATTRIBUTES=\"/sys/lib/git/attributes\"\\\n+\t-DUSER_GITCONFIG=\"~/lib/git/config\"\\\n+\t-DUSER_GITCREDENTIALS=\"~/lib/git/credentials\"\\\n+\t-DUSER_GITCREDENTIAL_CACHE=\"~/lib/git/credential-cache\"\\\n+\t-DDEFAULT_GIT_TEMPLATE_DIR=\"/sys/lib/git/templates\"\\\n+\t-DGIT_HOST_CPU=\"i386\"\\\n+\t-DGIT_EXEC_PATH=\"/bin/git-core\"\\\n+\t-DGIT_MAN_PATH=\"/sys/man\"\\\n+\t-DGIT_INFO_PATH=\"\"\\\n+\t-DGIT_HTML_PATH=\"\"\\\n+\t-DFALLBACK_RUNTIME_PREFIX=\"/bin/git-core\"\\\n+\t-DDEFAULT_PAGER=\"/bin/p\"\\\n+\t-DPAGER_ENV=\"terminal=\"\\\n+\t-DHOME_ENVIRONMENT=\"home\"\\\n+\t-DPATH_ENVIRONMENT=\"path\"\\\n+\t-D_PATH_SEP=1\\\n+\t-D_PATH_DEFPATH=\"/bin\"\\\n+\t-DSHELL_PATH=\"/bin/rc\"\\\n+\n+LIB_CFILES=`{sed -n '/^LIB_OBJS *\\+= *(.*)\\.o$/s//\\1.c/p' Makefile}\n+LIB_OFILES=\\\n+\t${LIB_CFILES:%.c=%.$O}\\\n+\tcompat/qsort_s.$O\\\n+\tcompat/strcasestr.$O\\\n+\tcompat/strlcpy.$O\\\n+\tcompat/strtoumax.$O\\\n+\tcompat/strtoimax.$O\\\n+\tcompat/setenv.$O\\\n+\tcompat/mkdtemp.$O\\\n+\tcompat/unsetenv.$O\\\n+\tcompat/mmap.$O\\\n+\tcompat/memmem.$O\\\n+\tcompat/regex/regex.$O\\\n+\n+XDIFF_CFILES=`{sed -n '/^XDIFF_OBJS *\\+= *(.*)\\.o$/s//\\1.c/p' Makefile}\n+XDIFF_OFILES=${XDIFF_CFILES:%.c=%.$O}\n+\n+HFILES=\\\n+\t`{ls *.h}\\\n+\t`{ls */*.h}\\\n+\t`{ls */*/*.h}\\\n+\t`{ls */*/*/*.h}\\\n+\tcommand-list.h\\\n+\n+BIN=/$objtype/bin/git-core\n+OBJBIN=/$objtype/bin\n+\n+LIB=\\\n+\tlibgit.a$O\\\n+\txdiff/lib.a$O\\\n+\t/$objtype/lib/ape/libcurl.a\\\n+\t/$objtype/lib/ape/libssl.a\\\n+\t/$objtype/lib/ape/libcrypto.a\\\n+\t/$objtype/lib/ape/libexpat.a\\\n+\t/$objtype/lib/ape/libz.a\\\n+\n+CLEANFILES=command-list.h\n+\n+</sys/src/cmd/mkmany\n+\n+LIBGIT=libgit.a$O\n+LIBGITOBJ=${LIB_OFILES:%=$LIBGIT(%)}\n+LIBXDIFF=xdiff/lib.a$O\n+LIBXDIFFOBJ=${XDIFF_OFILES:%=$LIBXDIFF(%)}\n+\n+command-list.h:D:\tcommand-list.txt\n+\trc ./generate-cmdlist.rc $prereq >$target\n+\n+${CFILES:builtin/%.c=$O.git-%} ${X_CFILES:%=$O.git-%}:D:\tplan9/wrap.c\n+\tfor(i in $target)\n+\t\t$CC -FTVw -o $i $prereq\n+\n+$O.git-credential-store:\tcredential-store.$O common-main.$O $LIB\n+\t$LD $LDFLAGS -o $target $prereq\n+\n+$O.git-http-fetch:\thttp-fetch.$O http.$O http-walker.$O common-main.$O $LIB\n+\t$LD $LDFLAGS -o $target $prereq\n+\n+$O.git-http-push:\thttp-push.$O http.$O common-main.$O $LIB\n+\t$LD $LDFLAGS -o $target $prereq\n+\n+git-http-%.$O:\thttp-%.c\n+\t$CC $CFLAGS -o $target $prereq\n+\n+$O.git-remote-http:\tremote-curl.$O http.$O http-walker.$O common-main.$O $LIB\n+\t$LD $LDFLAGS -o $target $prereq\n+\n+$O.git-remote-https:\tremote-curl.$O http.$O http-walker.$O common-main.$O $LIB\n+\t$LD $LDFLAGS -o $target $prereq\n+\n+$O.git-remote-ftp:\tremote-curl.$O http.$O http-walker.$O common-main.$O $LIB\n+\t$LD $LDFLAGS -o $target $prereq\n+\n+$O.git-remote-ftps:\tremote-curl.$O http.$O http-walker.$O common-main.$O $LIB\n+\t$LD $LDFLAGS -o $target $prereq\n+\n+# git should be copied into both $BIN and $OBJBIN\n+git.install:V:\t$O.git\n+\tcp $O.git $OBJBIN/git\n+\n+$LIBGIT:\t$LIBGITOBJ\n+\tar vu $target $newmember\n+\n+$LIBXDIFF:\t$LIBXDIFFOBJ\n+\tar vu $target $newmember\n+\n+%.$O:\t%.c\n+\t$CC $CFLAGS -o $target $stem.c\n+\n+$LIBGIT(%.$O):N:\t%.$O\n+\n+$LIBXDIFF(%.$O):N:\t%.$O\n+\n+clean:V:\n+\trm -f *.[$OS] [$OS].out y.tab.? lex.yy.c y.debug y.output $CLEANFILES\n+\trm -f */*.[$OS] */*/*.[$OS]\n-- \ngitgitgadget\n"},{"id":"379904","messageId":"20190804000310.GD118825@genre.crustytoothpaste.net","threadId":"51584","inReplyTo":"d00bbdce0d5104f1793b7fa0dce14f678e9fb331.1564876327.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 5/6] Add plan9/wrap.c","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-08-04T00:03:10Z","receivedAt":"2019-08-04T00:04:33Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-08-03 at 23:52:12, lufia via GitGitGadget wrote:\n> From: lufia <lufia@lufia.org>\n> \n> Plan 9 has bind(1) instead of ln(1), but bind isn't persisted to the disk.\n> However it isn't efficient to copy git to git- subcommands such as git-add.\n> Therefore Plan 9 needs wrap.c to switch behavior by executable name.\n\nDoes Plan 9 have symbolic links? The INSTALL_SYMLINKS option uses\nsymlinks instead, which should avoid the need for hard links.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"379906","messageId":"20190804003816.GE118825@genre.crustytoothpaste.net","threadId":"51584","inReplyTo":"pull.305.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/6] Port git to Plan 9","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-08-04T00:38:16Z","receivedAt":"2019-08-04T00:38:26Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-08-03 at 23:52:08, KADOTA, Kyohei via GitGitGadget wrote:\n> I ported git, and git subcommands only written in C to Plan 9. This pull\n> request contains patches for existing codes, and new files to build git in\n> Plan 9.\n> \n> All build options such as NO_PERL are not supported yet, and also some git\n> subcommands written not in C is not available yet. But git can synchronize\n> to remote repository with git pull and git push via HTTPS.\n> \n> This pull request don't contain a part of Git toolchain for example\n> git-credential-store, etc. So I'm going to port other parts of Git toolchain\n> too in the future.\n\nThis series seems to build a whole new build system that uses Plan 9\ntools. Typically the way ports to non-POSIX platforms (such as Windows)\nhave been handled is that the Unix tools, including GNU make, have been\nported to those platforms, and the POSIX (or POSIX-ish) environment used\nthere.\n\nI'm concerned that by introducing a whole bunch of new, Plan 9-specific\nbuild code, we're going to have it fall behind with features or bug\nfixes, because none of the main developers test on Plan 9, and most\ncontributors will not have the Plan 9 skills or systems to maintain the\ncode.\n\nIn addition, the editor used by git commit and other commands invokes\n\"sh\", but you've set this to \"rc\". That's completely different from the\nway that all other environments work, and it means that Git on Plan 9\noperates in a totally different, incompatible way there. We also use a\nPOSIX shell for the testsuite, and we rely on it quite heavily. rc is\nnot going to cut it there.\n\nPlan 9 has a POSIX environment, and I think it might be a better idea to\nrequire that as a condition for building and running Git. It will likely\nbe a lot easier, at least.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"379907","messageId":"CAFMepck4QDxBqBZ_jbwshrMC7W++a_BG4RzC_ct1-2sb2ReeyQ@mail.gmail.com","threadId":"51584","inReplyTo":"20190804000310.GD118825@genre.crustytoothpaste.net","subject":"Re: [PATCH 5/6] Add plan9/wrap.c","fromName":"Kyohei Kadota","fromEmail":"lufia@lufia.org","sentAt":"2019-08-04T01:26:04Z","receivedAt":"2019-08-04T01:26:19Z","isPatch":true,"sender":{"key":"lufia@lufia.org","avatar":"https://avatars.githubusercontent.com/u/1784379?v=4"},"body":"2019-08-04(Sun) 9:03 brian m. carlson <sandals@crustytoothpaste.net>:\n>\n> On 2019-08-03 at 23:52:12, lufia via GitGitGadget wrote:\n> > From: lufia <lufia@lufia.org>\n> >\n> > Plan 9 has bind(1) instead of ln(1), but bind isn't persisted to the disk.\n> > However it isn't efficient to copy git to git- subcommands such as git-add.\n> > Therefore Plan 9 needs wrap.c to switch behavior by executable name.\n>\n> Does Plan 9 have symbolic links? The INSTALL_SYMLINKS option uses\n> symlinks instead, which should avoid the need for hard links.\n> --\n> brian m. carlson: Houston, Texas, US\n> OpenPGP: https://keybase.io/bk2204\n\nNo, Plan 9 don't have a feature to create symbolic link.\nI think Plan 9 will not be going to have hard- and symbolic- links.\nhttp://doc.cat-v.org/plan_9/4th_edition/papers/lexnames\n"},{"id":"379908","messageId":"CAFMepcm6QVH+5H6on2hoWiMXd=Zoyi5MYP1GAt0WwixZN9oE_Q@mail.gmail.com","threadId":"51584","inReplyTo":"20190804003816.GE118825@genre.crustytoothpaste.net","subject":"Re: [PATCH 0/6] Port git to Plan 9","fromName":"Kyohei Kadota","fromEmail":"lufia@lufia.org","sentAt":"2019-08-04T02:22:58Z","receivedAt":"2019-08-04T02:42:09Z","isPatch":true,"sender":{"key":"lufia@lufia.org","avatar":"https://avatars.githubusercontent.com/u/1784379?v=4"},"body":"2019-08-04(Sun) 9:38 brian m. carlson <sandals@crustytoothpaste.net>:\n>\n> On 2019-08-03 at 23:52:08, KADOTA, Kyohei via GitGitGadget wrote:\n> > I ported git, and git subcommands only written in C to Plan 9. This pull\n> > request contains patches for existing codes, and new files to build git in\n> > Plan 9.\n> >\n> > All build options such as NO_PERL are not supported yet, and also some git\n> > subcommands written not in C is not available yet. But git can synchronize\n> > to remote repository with git pull and git push via HTTPS.\n> >\n> > This pull request don't contain a part of Git toolchain for example\n> > git-credential-store, etc. So I'm going to port other parts of Git toolchain\n> > too in the future.\n>\n> This series seems to build a whole new build system that uses Plan 9\n> tools. Typically the way ports to non-POSIX platforms (such as Windows)\n> have been handled is that the Unix tools, including GNU make, have been\n> ported to those platforms, and the POSIX (or POSIX-ish) environment used\n> there.\n>\n> I'm concerned that by introducing a whole bunch of new, Plan 9-specific\n> build code, we're going to have it fall behind with features or bug\n> fixes, because none of the main developers test on Plan 9, and most\n> contributors will not have the Plan 9 skills or systems to maintain the\n> code.\n>\n> In addition, the editor used by git commit and other commands invokes\n> \"sh\", but you've set this to \"rc\". That's completely different from the\n> way that all other environments work, and it means that Git on Plan 9\n> operates in a totally different, incompatible way there. We also use a\n> POSIX shell for the testsuite, and we rely on it quite heavily. rc is\n> not going to cut it there.\n>\n> Plan 9 has a POSIX environment, and I think it might be a better idea to\n> require that as a condition for building and running Git. It will likely\n> be a lot easier, at least.\n> --\n> brian m. carlson: Houston, Texas, US\n> OpenPGP: https://keybase.io/bk2204\n\nI think it is possible to replace rc with ape/sh, ape/sh is POSIX\nshell in Plan 9.\n\nHowever Plan 9 don't have recent versions of Unix tools,\nsuch as gcc, g++, autotools, gmake or perl,\nso it is VERY hard to use Makefile instead of mkfile.\n"},{"id":"379921","messageId":"20190804202233.GB258325@google.com","threadId":"51584","inReplyTo":"CAFMepcm6QVH+5H6on2hoWiMXd=Zoyi5MYP1GAt0WwixZN9oE_Q@mail.gmail.com","subject":"Re: [PATCH 0/6] Port git to Plan 9","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2019-08-04T20:22:33Z","receivedAt":"2019-08-04T20:22:37Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nKyohei Kadota wrote:\n\n> I think it is possible to replace rc with ape/sh, ape/sh is POSIX\n> shell in Plan 9.\n>\n> However Plan 9 don't have recent versions of Unix tools,\n> such as gcc, g++, autotools, gmake or perl,\n> so it is VERY hard to use Makefile instead of mkfile.\n\nThe default Git build doesn't use autotools.  See INSTALL for more\ndetails.\n\nWhat version of gmake is available for Plan 9?  I wouldn't expect\nGit's build system to be super demanding as far as recent \"make\"\nfeatures go.\n\nSo I wonder whether it would make sense to do something like the\nfollowing:\n\n- add entries to config.mak.uname to set the compiler e.g. to 6c\n  when appropriate\n\n- make appropriate compatibility fixes in git-compat-util.h\n\n- add any necessary helpers to the compat/ directory\n\n- use gmake to build\n\nWould that work?\n\nThanks,\nJonathan\n"},{"id":"379961","messageId":"xmqqy307kzn3.fsf@gitster-ct.c.googlers.com","threadId":"51584","inReplyTo":"df67a7e1d307d6a7a91ae1bba085959154006ed1.1564876327.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 3/6] GIT-VERSION-GEN: Use sed instead of expr","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-08-05T22:37:04Z","receivedAt":"2019-08-05T22:37:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"lufia via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: lufia <lufia@lufia.org>\n>\n> Plan 9 don't have expr(1).\n>\n> Signed-off-by: lufia <lufia@lufia.org>\n> ---\n>  GIT-VERSION-GEN | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\n> index a0766f64ed..754d4486f5 100755\n> --- a/GIT-VERSION-GEN\n> +++ b/GIT-VERSION-GEN\n> @@ -26,7 +26,7 @@ else\n>  \tVN=\"$DEF_VER\"\n>  fi\n>  \n> -VN=$(expr \"$VN\" : v*'\\(.*\\)')\n> +VN=$(echo \"$VN\" | sed 's/^v*//')\n\nThe expr utility is often a shell built-in, but sed is almost never\n(as it is a lot more heavy-weight command).  It may not be a bad\nidea to get rid of expr with a simple shell parameter expansion,\ne.g.\n\n\tVN=${VN#v}\n\ninstead.\n\nThe original explicitly is prepared to see no 'v' at the beginning\n(in which case it just passes VN intact), or more than one 'v's (in\nwhich case all leading 'v's are stripped), while the shell parameter\nexpansion strips zero or one 'v' at the beginning.  So there is a\nslight \"regression\" there, but I do not think it matters (certainly,\nit was *NOT* my intention while writing the original to strip two or\nmore 'v's).  181129d2 (\"For release tarballs, include the proper\nversion\", 2006-01-09) snuck in the \"all leading 'v's are stripped\"\nwithout sufficient explanation, but I do not think it was an attempt\nto allow two or more 'v's.\n"},{"id":"381362","messageId":"pull.305.v2.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.git.gitgitgadget@gmail.com","subject":"[PATCH v2 0/3] Port git to Plan 9","fromName":"KADOTA, Kyohei via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-27T13:46:16Z","receivedAt":"2019-08-27T13:46:20Z","isPatch":true,"sender":{"key":"name:KADOTA, Kyohei","avatar":null},"body":"Changes from v1\n===============\n\n * Use gmake\n * Use sh\n * Remove dependencies to Plan 9 tools; rc and mk\n\nWhat I did\n==========\n\nI ported git, and git subcommands with gmake to Plan 9. This pull request\ncontains patches for existing codes, and new files to build git in Plan 9.\n\nI added three new options into Makefile.\n\n * USER_GITCONFIG - default ~/.gitconfig\n * USER_GITCREDENTIALS - default ~/.git-credentials\n * USER_GITCREDENTIAL_CACHE - default ~/.git-credential-cache\n * USE_EXEC_WRAPPER - default empty\n\nIn Plan 9, user configuration files are stored at $home/lib, instead of\ndotfiles.\nhttp://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html\n\nAnd Plan 9 haven't hard link and symbolic link. Thus I added exec-wrapper to\nwant to shrink disk usage.\nhttp://doc.cat-v.org/plan_9/4th_edition/papers/lexnames\n\nInstallation\n============\n\n# ANSI/POSIX commands are installed at /bin only in current namespace.\n% bind -a /bin/ape /bin\n\n# Plan 9 C compiler can't initialize struct fields that is bit field so remove bit fields from all C files.\n% ./remove-bitfields.sh\n\n# build Git toolchain with /n/sources/contrib/andrey/make-3.81.tgz\n% gmake 'prefix=' 'gitexecdir=bin/git-core' 'sysconfdir=sys/lib/git' 'template_dir=sys/lib/git/templates' install\n\nlufia (3):\n  Change HOME, PATH, and .gitconfig paths to be customizable\n  Fix C syntactic errors for the Plan 9 C compiler\n  Support Plan 9 dialect\n\n GIT-VERSION-GEN               |  2 +-\n Makefile                      | 81 +++++++++++++++++++++++-----\n builtin/config.c              |  2 +-\n compat/plan9/openssl/crypto.h |  5 ++\n compat/regex/regex_internal.h |  3 ++\n config.c                      |  5 +-\n config.mak.uname              | 99 +++++++++++++++++++++++++++++++++++\n credential-cache.c            |  2 +-\n credential-store.c            |  2 +-\n exec-cmd.c                    |  4 +-\n exec-wrapper.c                | 16 ++++++\n generate-cmdlist.sh           | 24 ++++++---\n git-compat-util.h             | 17 +++++-\n help.c                        |  2 +-\n parse-options.h               | 18 +++----\n path.c                        |  6 +--\n remove-bitfields.sh           | 17 ++++++\n run-command.c                 |  4 +-\n sequencer.c                   |  2 +-\n shell.c                       |  2 +-\n t/chainlint.sed               | 66 +++++++++++------------\n templates/Makefile            | 12 ++++-\n 22 files changed, 311 insertions(+), 80 deletions(-)\n create mode 100644 compat/plan9/openssl/crypto.h\n create mode 100644 exec-wrapper.c\n create mode 100755 remove-bitfields.sh\n\n\nbase-commit: 745f6812895b31c02b29bdfe4ae8e5498f776c26\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-305%2Flufia%2Fplan9-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-305/lufia/plan9-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/305\n\nRange-diff vs v1:\n\n 1:  fa539c75b2 ! 1:  63e7e7794e Change HOME, PATH, and .gitconfig paths to be customizable\n     @@ -10,12 +10,26 @@\n       --- a/Makefile\n       +++ b/Makefile\n      @@\n     + localedir = $(sharedir)/locale\n     + template_dir = share/git-core/templates\n       htmldir = $(prefix)/share/doc/git-doc\n     - ETC_GITCONFIG = $(sysconfdir)/gitconfig\n     - ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes\n     -+USER_GITCONFIG = ~/.gitconfig\n     -+USER_GITCREDENTIALS = ~/.git-credentials\n     -+USER_GITCREDENTIAL_CACHE = ~/.git-credential-cache\n     +-ETC_GITCONFIG = $(sysconfdir)/gitconfig\n     +-ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes\n     ++ifndef ETC_GITCONFIG\n     ++\tETC_GITCONFIG = $(sysconfdir)/gitconfig\n     ++endif\n     ++ifndef ETC_GITATTRIBUTES\n     ++\tETC_GITATTRIBUTES = $(sysconfdir)/gitattributes\n     ++endif\n     ++ifndef USER_GITCONFIG\n     ++\tUSER_GITCONFIG = ~/.gitconfig\n     ++endif\n     ++ifndef USER_GITCREDENTIALS\n     ++\tUSER_GITCREDENTIALS = ~/.git-credentials\n     ++endif\n     ++ifndef USER_GITCREDENTIAL_CACHE\n     ++\tUSER_GITCREDENTIAL_CACHE = ~/.git-credential-cache\n     ++endif\n       lib = lib\n       # DESTDIR =\n       pathsep = :\n 2:  301a796de9 ! 2:  7abbd36e1d Fix C syntactic errors for the Plan 9 C compiler\n     @@ -114,22 +114,25 @@\n        * It's okay for the caller to consume argv/argc in the usual way.\n        * Other fields of that structure are private to parse-options and should not\n      \n     - diff --git a/remove-bitfields.rc b/remove-bitfields.rc\n     - new file mode 100644\n     + diff --git a/remove-bitfields.sh b/remove-bitfields.sh\n     + new file mode 100755\n       --- /dev/null\n     - +++ b/remove-bitfields.rc\n     + +++ b/remove-bitfields.sh\n      @@\n     -+#!/bin/rc\n     ++#!/bin/ape/sh\n      +# Plan 9 C compiler rejects initialization a structure including bit field.\n     -+# usage: remove-bitfields.rc [dir ...]\n     ++# usage: remove-bitfields.sh [dir ...]\n     ++\n     ++if ! echo abc | sed 's/(ab)c/\\1/' >/dev/null 2>&1\n     ++then\n     ++\talias sed='sed -E'\n     ++fi\n      +\n     -+fn sigexit sighup sigint sigquit sigterm {\n     -+\trm -f /tmp/remove-bitfields.$pid\n     -+\texit\n     -+}\n     ++trap 'rm -f /tmp/remove-bitfields.$pid; exit 1' 1 2 3 15 EXIT\n      +\n     -+files=`{du -a $* | awk '/\\.[ch]$/ { print $2 }'}\n     -+for(i in $files){\n     ++files=$(du -a $* | awk '/\\.[ch]$/ { print $2 }')\n     ++for i in $files\n     ++do\n      +\tsed '/(^[ \t]*\\*|\\?)/!s/([a-z]+[a-z0-9]*) *: *[0-9]+([,;])/\\1\\2/g' $i >/tmp/remove-bitfields.$pid\n      +\tcp /tmp/remove-bitfields.$pid $i\n     -+}\n     ++done\n 3:  df67a7e1d3 < -:  ---------- GIT-VERSION-GEN: Use sed instead of expr\n 4:  d25bcb43e1 < -:  ---------- Port generate-cmdline.sh to rc\n 5:  d00bbdce0d < -:  ---------- Add plan9/wrap.c\n 6:  0494971306 < -:  ---------- Add mkfile to build git and subcommands for Plan 9\n -:  ---------- > 3:  7505e85fc5 Support Plan 9 dialect\n\n-- \ngitgitgadget\n"},{"id":"381363","messageId":"63e7e7794ee2afed1b57fe7585ef6e7af9cf8391.1566913575.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 1/3] Change HOME, PATH, and .gitconfig paths to be customizable","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-27T13:46:17Z","receivedAt":"2019-08-27T13:46:21Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nIn Plan 9, almost environment variables are not capitalized.\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n Makefile           | 40 +++++++++++++++++++++++++++++++++++++---\n builtin/config.c   |  2 +-\n config.c           |  2 +-\n credential-cache.c |  2 +-\n credential-store.c |  2 +-\n exec-cmd.c         |  4 ++--\n git-compat-util.h  |  8 ++++++++\n help.c             |  2 +-\n path.c             |  6 +++---\n run-command.c      |  4 ++--\n sequencer.c        |  2 +-\n shell.c            |  2 +-\n 12 files changed, 59 insertions(+), 17 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex f9255344ae..04ff7df64a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -539,8 +539,21 @@ perllibdir = $(sharedir)/perl5\n localedir = $(sharedir)/locale\n template_dir = share/git-core/templates\n htmldir = $(prefix)/share/doc/git-doc\n-ETC_GITCONFIG = $(sysconfdir)/gitconfig\n-ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes\n+ifndef ETC_GITCONFIG\n+\tETC_GITCONFIG = $(sysconfdir)/gitconfig\n+endif\n+ifndef ETC_GITATTRIBUTES\n+\tETC_GITATTRIBUTES = $(sysconfdir)/gitattributes\n+endif\n+ifndef USER_GITCONFIG\n+\tUSER_GITCONFIG = ~/.gitconfig\n+endif\n+ifndef USER_GITCREDENTIALS\n+\tUSER_GITCREDENTIALS = ~/.git-credentials\n+endif\n+ifndef USER_GITCREDENTIAL_CACHE\n+\tUSER_GITCREDENTIAL_CACHE = ~/.git-credential-cache\n+endif\n lib = lib\n # DESTDIR =\n pathsep = :\n@@ -1910,6 +1923,9 @@ endif\n \n ETC_GITCONFIG_SQ = $(subst ','\\'',$(ETC_GITCONFIG))\n ETC_GITATTRIBUTES_SQ = $(subst ','\\'',$(ETC_GITATTRIBUTES))\n+USER_GITCONFIG_SQ = $(subst ','\\'',$(USER_GITCONFIG))\n+USER_GITCREDENTIALS_SQ = $(subst ','\\'',$(USER_GITCREDENTIALS))\n+USER_GITCREDENTIAL_CACHE_SQ = $(subst ','\\'',$(USER_GITCREDENTIAL_CACHE))\n \n DESTDIR_SQ = $(subst ','\\'',$(DESTDIR))\n bindir_SQ = $(subst ','\\'',$(bindir))\n@@ -2400,12 +2416,30 @@ builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n \n config.sp config.s config.o: GIT-PREFIX\n config.sp config.s config.o: EXTRA_CPPFLAGS = \\\n-\t-DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n+\t-DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"' \\\n+\t-DUSER_GITCONFIG='\"$(USER_GITCONFIG_SQ)\"'\n+\n+builtin/config.sp builtin/config.s builtin/config.o: GIT-PREFIX\n+builtin/config.sp builtin/config.s builtin/config.o: EXTRA_CPPFLAGS = \\\n+\t-DUSER_GITCONFIG='\"$(USER_GITCONFIG_SQ)\"'\n+\n+sequencer.sp sequencer.s sequencer.o: GIT-PREFIX\n+sequencer.sp sequencer.s sequencer.o: EXTRA_CPPFLAGS = \\\n+\t-DUSER_GITCONFIG='\"$(USER_GITCONFIG_SQ)\"'\n \n attr.sp attr.s attr.o: GIT-PREFIX\n attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \\\n \t-DETC_GITATTRIBUTES='\"$(ETC_GITATTRIBUTES_SQ)\"'\n \n+credential-cache.sp credential-cache.s credential-cache.o: GIT-PREFIX\n+credential-cache.sp credential-cache.s credential-cache.o: EXTRA_CPPFLAGS = \\\n+\t-DUSER_GITCONFIG='\"$(USER_GITCONFIG_SQ)\"' \\\n+\t-DUSER_GITCREDENTIAL_CACHE='\"$(USER_GITCREDENTIAL_CACHE_SQ)\"'\n+\n+credential-store.sp credential-store.s credential-store.o: GIT-PREFIX\n+credential-store.sp credential-store.s credential-store.o: EXTRA_CPPFLAGS = \\\n+\t-DUSER_GITCREDENTIALS='\"$(USER_GITCREDENTIALS_SQ)\"'\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_relative_SQ)\"'\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 98d65bc0ad..22c4f0ab71 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -625,7 +625,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (use_global_config) {\n-\t\tchar *user_config = expand_user_path(\"~/.gitconfig\", 0);\n+\t\tchar *user_config = expand_user_path(USER_GITCONFIG, 0);\n \t\tchar *xdg_config = xdg_config_home(\"config\");\n \n \t\tif (!user_config)\ndiff --git a/config.c b/config.c\nindex 3900e4947b..14de96ee6d 100644\n--- a/config.c\n+++ b/config.c\n@@ -1700,7 +1700,7 @@ static int do_git_config_sequence(const struct config_options *opts,\n {\n \tint ret = 0;\n \tchar *xdg_config = xdg_config_home(\"config\");\n-\tchar *user_config = expand_user_path(\"~/.gitconfig\", 0);\n+\tchar *user_config = expand_user_path(USER_GITCONFIG, 0);\n \tchar *repo_config;\n \n \tif (opts->commondir)\ndiff --git a/credential-cache.c b/credential-cache.c\nindex 1cccc3a0b9..3e2ed6c0be 100644\n--- a/credential-cache.c\n+++ b/credential-cache.c\n@@ -87,7 +87,7 @@ static char *get_socket_path(void)\n {\n \tstruct stat sb;\n \tchar *old_dir, *socket;\n-\told_dir = expand_user_path(\"~/.git-credential-cache\", 0);\n+\told_dir = expand_user_path(USER_GITCREDENTIAL_CACHE, 0);\n \tif (old_dir && !stat(old_dir, &sb) && S_ISDIR(sb.st_mode))\n \t\tsocket = xstrfmt(\"%s/socket\", old_dir);\n \telse\ndiff --git a/credential-store.c b/credential-store.c\nindex ac295420dd..37256ee942 100644\n--- a/credential-store.c\n+++ b/credential-store.c\n@@ -168,7 +168,7 @@ int cmd_main(int argc, const char **argv)\n \tif (file) {\n \t\tstring_list_append(&fns, file);\n \t} else {\n-\t\tif ((file = expand_user_path(\"~/.git-credentials\", 0)))\n+\t\tif ((file = expand_user_path(USER_GITCREDENTIALS, 0)))\n \t\t\tstring_list_append_nodup(&fns, file);\n \t\tfile = xdg_config_home(\"credentials\");\n \t\tif (file)\ndiff --git a/exec-cmd.c b/exec-cmd.c\nindex 7deeab3039..c95fc8dbdd 100644\n--- a/exec-cmd.c\n+++ b/exec-cmd.c\n@@ -304,7 +304,7 @@ static void add_path(struct strbuf *out, const char *path)\n void setup_path(void)\n {\n \tconst char *exec_path = git_exec_path();\n-\tconst char *old_path = getenv(\"PATH\");\n+\tconst char *old_path = getenv(PATH_ENVIRONMENT);\n \tstruct strbuf new_path = STRBUF_INIT;\n \n \tgit_set_exec_path(exec_path);\n@@ -315,7 +315,7 @@ void setup_path(void)\n \telse\n \t\tstrbuf_addstr(&new_path, _PATH_DEFPATH);\n \n-\tsetenv(\"PATH\", new_path.buf, 1);\n+\tsetenv(PATH_ENVIRONMENT, new_path.buf, 1);\n \n \tstrbuf_release(&new_path);\n }\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 83be89de0a..f8fdd79591 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1238,6 +1238,14 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);\n # define SHELL_PATH \"/bin/sh\"\n #endif\n \n+#ifndef HOME_ENVIRONMENT\n+# define HOME_ENVIRONMENT \"HOME\"\n+#endif\n+\n+#ifndef PATH_ENVIRONMENT\n+# define PATH_ENVIRONMENT \"PATH\"\n+#endif\n+\n #ifndef _POSIX_THREAD_SAFE_FUNCTIONS\n #define flockfile(fh)\n #define funlockfile(fh)\ndiff --git a/help.c b/help.c\nindex 5261d83ecf..6094bfae7d 100644\n--- a/help.c\n+++ b/help.c\n@@ -260,7 +260,7 @@ void load_command_list(const char *prefix,\n \t\tstruct cmdnames *main_cmds,\n \t\tstruct cmdnames *other_cmds)\n {\n-\tconst char *env_path = getenv(\"PATH\");\n+\tconst char *env_path = getenv(PATH_ENVIRONMENT);\n \tconst char *exec_path = git_exec_path();\n \n \tif (exec_path) {\ndiff --git a/path.c b/path.c\nindex 25e97b8c3f..45bde04d37 100644\n--- a/path.c\n+++ b/path.c\n@@ -719,7 +719,7 @@ char *expand_user_path(const char *path, int real_home)\n \t\tconst char *username = path + 1;\n \t\tsize_t username_len = first_slash - username;\n \t\tif (username_len == 0) {\n-\t\t\tconst char *home = getenv(\"HOME\");\n+\t\t\tconst char *home = getenv(HOME_ENVIRONMENT);\n \t\t\tif (!home)\n \t\t\t\tgoto return_null;\n \t\t\tif (real_home)\n@@ -1426,7 +1426,7 @@ char *xdg_config_home(const char *filename)\n \tif (config_home && *config_home)\n \t\treturn mkpathdup(\"%s/git/%s\", config_home, filename);\n \n-\thome = getenv(\"HOME\");\n+\thome = getenv(HOME_ENVIRONMENT);\n \tif (home)\n \t\treturn mkpathdup(\"%s/.config/git/%s\", home, filename);\n \treturn NULL;\n@@ -1441,7 +1441,7 @@ char *xdg_cache_home(const char *filename)\n \tif (cache_home && *cache_home)\n \t\treturn mkpathdup(\"%s/git/%s\", cache_home, filename);\n \n-\thome = getenv(\"HOME\");\n+\thome = getenv(HOME_ENVIRONMENT);\n \tif (home)\n \t\treturn mkpathdup(\"%s/.cache/git/%s\", home, filename);\n \treturn NULL;\ndiff --git a/run-command.c b/run-command.c\nindex 3449db319b..85d7a8c342 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -180,14 +180,14 @@ int is_executable(const char *name)\n  */\n static char *locate_in_PATH(const char *file)\n {\n-\tconst char *p = getenv(\"PATH\");\n+\tconst char *p = getenv(PATH_ENVIRONMENT);\n \tstruct strbuf buf = STRBUF_INIT;\n \n \tif (!p || !*p)\n \t\treturn NULL;\n \n \twhile (1) {\n-\t\tconst char *end = strchrnul(p, ':');\n+\t\tconst char *end = strchrnul(p, PATH_SEP);\n \n \t\tstrbuf_reset(&buf);\n \ndiff --git a/sequencer.c b/sequencer.c\nindex 34ebf8ed94..044b0fabea 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1246,7 +1246,7 @@ N_(\"Your name and email address were configured automatically based\\n\"\n \n static const char *implicit_ident_advice(void)\n {\n-\tchar *user_config = expand_user_path(\"~/.gitconfig\", 0);\n+\tchar *user_config = expand_user_path(USER_GITCONFIG, 0);\n \tchar *xdg_config = xdg_config_home(\"config\");\n \tint config_exists = file_exists(user_config) || file_exists(xdg_config);\n \ndiff --git a/shell.c b/shell.c\nindex 40084a3013..fa844425b9 100644\n--- a/shell.c\n+++ b/shell.c\n@@ -39,7 +39,7 @@ static char *make_cmd(const char *prog)\n \n static void cd_to_homedir(void)\n {\n-\tconst char *home = getenv(\"HOME\");\n+\tconst char *home = getenv(HOME_ENVIRONMENT);\n \tif (!home)\n \t\tdie(\"could not determine user's home directory; HOME is unset\");\n \tif (chdir(home) == -1)\n-- \ngitgitgadget\n\n"},{"id":"381364","messageId":"7abbd36e1ddc2037925c3ff148f62f0352a8954b.1566913575.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 2/3] Fix C syntactic errors for the Plan 9 C compiler","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-27T13:46:18Z","receivedAt":"2019-08-27T13:46:22Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n compat/plan9/openssl/crypto.h |  5 +++++\n compat/regex/regex_internal.h |  3 +++\n config.c                      |  3 ++-\n git-compat-util.h             |  9 ++++++++-\n parse-options.h               | 18 +++++++++---------\n remove-bitfields.sh           | 17 +++++++++++++++++\n 6 files changed, 44 insertions(+), 11 deletions(-)\n create mode 100644 compat/plan9/openssl/crypto.h\n create mode 100755 remove-bitfields.sh\n\ndiff --git a/compat/plan9/openssl/crypto.h b/compat/plan9/openssl/crypto.h\nnew file mode 100644\nindex 0000000000..9d1ef43422\n--- /dev/null\n+++ b/compat/plan9/openssl/crypto.h\n@@ -0,0 +1,5 @@\n+#ifndef __attribute__\n+#define __attribute__(x)\n+#endif\n+\n+#include_next <openssl/crypto.h>\ndiff --git a/compat/regex/regex_internal.h b/compat/regex/regex_internal.h\nindex 3ee8aae59d..7313c747a6 100644\n--- a/compat/regex/regex_internal.h\n+++ b/compat/regex/regex_internal.h\n@@ -26,6 +26,9 @@\n #include <stdlib.h>\n #include <string.h>\n \n+#ifdef NEEDS_SYS_PARAM_H\n+#include <sys/param.h>\n+#endif\n #if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC\n # include <langinfo.h>\n #endif\ndiff --git a/config.c b/config.c\nindex 14de96ee6d..0024b767e5 100644\n--- a/config.c\n+++ b/config.c\n@@ -2462,7 +2462,8 @@ static int store_aux_event(enum config_event_t type,\n \t\t\treturn error(_(\"invalid section name '%s'\"), cf->var.buf);\n \n \t\tif (cf->subsection_case_sensitive)\n-\t\t\tcmpfn = strncasecmp;\n+\t\t\t/* Plan 9's strncasecmp is typed (char*, char*, int) */\n+\t\t\tcmpfn = (int (*)(const char*, const char*, size_t))strncasecmp;\n \t\telse\n \t\t\tcmpfn = strncmp;\n \ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex f8fdd79591..1aa7877af4 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -164,7 +164,11 @@\n #define GIT_WINDOWS_NATIVE\n #endif\n \n+#include <sys/types.h>\n #include <unistd.h>\n+#ifdef __PLAN9__\n+#include <libv.h>\n+#endif\n #include <stdio.h>\n #include <sys/stat.h>\n #include <fcntl.h>\n@@ -180,7 +184,6 @@\n #ifdef NEEDS_SYS_PARAM_H\n #include <sys/param.h>\n #endif\n-#include <sys/types.h>\n #include <dirent.h>\n #include <sys/time.h>\n #include <time.h>\n@@ -282,6 +285,10 @@ char *gitbasename(char *);\n char *gitdirname(char *);\n #endif\n \n+#ifdef __PLAN9__\n+#include <machine/endian.h>\n+#endif\n+\n #ifndef NO_ICONV\n #include <iconv.h>\n #endif\ndiff --git a/parse-options.h b/parse-options.h\nindex a4bd40bb6a..38a33a087e 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -46,6 +46,15 @@ enum parse_opt_option_flags {\n \tPARSE_OPT_COMP_ARG = 1024\n };\n \n+enum parse_opt_result {\n+\tPARSE_OPT_COMPLETE = -3,\n+\tPARSE_OPT_HELP = -2,\n+\tPARSE_OPT_ERROR = -1,\t/* must be the same as error() */\n+\tPARSE_OPT_DONE = 0,\t/* fixed so that \"return 0\" works */\n+\tPARSE_OPT_NON_OPTION,\n+\tPARSE_OPT_UNKNOWN\n+};\n+\n struct option;\n typedef int parse_opt_cb(const struct option *, const char *arg, int unset);\n \n@@ -241,15 +250,6 @@ const char *optname(const struct option *opt, int flags);\n \n /*----- incremental advanced APIs -----*/\n \n-enum parse_opt_result {\n-\tPARSE_OPT_COMPLETE = -3,\n-\tPARSE_OPT_HELP = -2,\n-\tPARSE_OPT_ERROR = -1,\t/* must be the same as error() */\n-\tPARSE_OPT_DONE = 0,\t/* fixed so that \"return 0\" works */\n-\tPARSE_OPT_NON_OPTION,\n-\tPARSE_OPT_UNKNOWN\n-};\n-\n /*\n  * It's okay for the caller to consume argv/argc in the usual way.\n  * Other fields of that structure are private to parse-options and should not\ndiff --git a/remove-bitfields.sh b/remove-bitfields.sh\nnew file mode 100755\nindex 0000000000..952bd34f12\n--- /dev/null\n+++ b/remove-bitfields.sh\n@@ -0,0 +1,17 @@\n+#!/bin/ape/sh\n+# Plan 9 C compiler rejects initialization a structure including bit field.\n+# usage: remove-bitfields.sh [dir ...]\n+\n+if ! echo abc | sed 's/(ab)c/\\1/' >/dev/null 2>&1\n+then\n+\talias sed='sed -E'\n+fi\n+\n+trap 'rm -f /tmp/remove-bitfields.$pid; exit 1' 1 2 3 15 EXIT\n+\n+files=$(du -a $* | awk '/\\.[ch]$/ { print $2 }')\n+for i in $files\n+do\n+\tsed '/(^[ \t]*\\*|\\?)/!s/([a-z]+[a-z0-9]*) *: *[0-9]+([,;])/\\1\\2/g' $i >/tmp/remove-bitfields.$pid\n+\tcp /tmp/remove-bitfields.$pid $i\n+done\n-- \ngitgitgadget\n\n"},{"id":"381365","messageId":"7505e85fc5508edd65a67eb9f4a57ebf41e9074c.1566913575.git.gitgitgadget@gmail.com","threadId":"51584","inReplyTo":"pull.305.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 3/3] Support Plan 9 dialect","fromName":"lufia via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-08-27T13:46:19Z","receivedAt":"2019-08-27T13:46:23Z","isPatch":true,"sender":{"key":"name:lufia","avatar":null},"body":"From: lufia <lufia@lufia.org>\n\nPlan 9 ANSI/POSIX environment is:\n* No expr(1)\n* sed(1) limits max length of label to 7 characters\n* pcc ignores object files that has incorrect extension,\n  so should use underlying loader directly.\n* No ln(1). Instead use bind(1), but bind isn't persisted to the disk.\n  However it isn't efficient to copy git to git subcommands such as git-add.\n  Therefore Plan 9 needs exec-wrapper to switch behavior by executable name.\n* tar(1) don't have -o option\n\nSigned-off-by: lufia <lufia@lufia.org>\n---\n GIT-VERSION-GEN     |  2 +-\n Makefile            | 41 ++++++++++++++-----\n config.mak.uname    | 99 +++++++++++++++++++++++++++++++++++++++++++++\n exec-wrapper.c      | 16 ++++++++\n generate-cmdlist.sh | 24 ++++++++---\n t/chainlint.sed     | 66 +++++++++++++++---------------\n templates/Makefile  | 12 +++++-\n 7 files changed, 208 insertions(+), 52 deletions(-)\n create mode 100644 exec-wrapper.c\n\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 98f88a28d3..ec5635b120 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -26,7 +26,7 @@ else\n \tVN=\"$DEF_VER\"\n fi\n \n-VN=$(expr \"$VN\" : v*'\\(.*\\)')\n+VN=${VN#v}\n \n if test -r $GVF\n then\ndiff --git a/Makefile b/Makefile\nindex 04ff7df64a..a2729ba6d3 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -570,6 +570,7 @@ export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir\n \n # Set our default programs\n CC = cc\n+LD = cc\n AR = ar\n RM = rm -f\n DIFF = diff\n@@ -800,6 +801,10 @@ ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)\n # what 'all' will build but not install in gitexecdir\n OTHER_PROGRAMS = git$X\n \n+# what 'all' will build but not install in neither bindir and gitexecdir,\n+COMPAT_PROGRAM_OBJS =\n+COMPAT_PROGRAMS =\n+\n # what test wrappers are needed and 'install' will install, in bindir\n BINDIR_PROGRAMS_NEED_X += git\n BINDIR_PROGRAMS_NEED_X += git-upload-pack\n@@ -1863,6 +1868,11 @@ ifndef PAGER_ENV\n PAGER_ENV = LESS=FRX LV=-c\n endif\n \n+ifdef USE_EXEC_WRAPPER\n+\tCOMPAT_PROGRAM_OBJS += exec-wrapper.o\n+\tCOMPAT_PROGRAMS += exec-wrapper$X\n+endif\n+\n QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir\n QUIET_SUBDIR1  =\n \n@@ -2062,7 +2072,7 @@ profile-fast: profile-clean\n \t$(MAKE) PROFILE=USE all\n \n \n-all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS\n+all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) $(COMPAT_PROGRAMS) GIT-BUILD-OPTIONS\n ifneq (,$X)\n \t$(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)\n endif\n@@ -2122,7 +2132,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = \\\n \t'-DGIT_INFO_PATH=\"$(infodir_relative_SQ)\"'\n \n git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \\\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) \\\n \t\t$(filter %.o,$^) $(LIBS)\n \n help.sp help.s help.o: command-list.h\n@@ -2141,10 +2151,11 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \\\n \t\tGIT_CEILING_DIRECTORIES=\"$(CURDIR)/..\" \\\n \t\tgit rev-parse -q --verify HEAD 2>/dev/null)\"'\n \n-$(BUILT_INS): git$X\n+$(BUILT_INS): git$X $(COMPAT_PROGRAMS)\n \t$(QUIET_BUILT_IN)$(RM) $@ && \\\n \tln $< $@ 2>/dev/null || \\\n \tln -s $< $@ 2>/dev/null || \\\n+\tcp exec-wrapper$X $@ 2>/dev/null || \\\n \tcp $< $@\n \n command-list.h: generate-cmdlist.sh command-list.txt\n@@ -2344,6 +2355,7 @@ VCSSVN_OBJS += vcs-svn/svndump.o\n \n TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))\n OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \\\n+\t$(COMPAT_PROGRAM_OBJS) \\\n \t$(XDIFF_OBJS) \\\n \t$(VCSSVN_OBJS) \\\n \t$(FUZZ_OBJS) \\\n@@ -2464,22 +2476,29 @@ compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \\\n compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null\n endif\n \n+exec-wrapper.sp exec-wrapper.s exec-wrapper.o: EXTRA_CPPFLAGS = \\\n+\t'-DGIT_EXEC_PATH=\"$(gitexecdir_SQ)\"' \\\n+\t'-DBINDIR=\"$(bindir_relative_SQ)\"'\n+\n+exec-wrapper$X: exec-wrapper.o GIT-LDFLAGS\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^)\n+\n git-%$X: %.o GIT-LDFLAGS $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)\n \n git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(IMAP_SEND_LDFLAGS) $(LIBS)\n \n git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(CURL_LIBCURL) $(LIBS)\n git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)\n \n git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \\\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \\\n \t$(VCSSVN_LIB)\n \n $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)\n@@ -2489,7 +2508,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)\n \tcp $< $@\n \n $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n \t\t$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)\n \n $(LIB_FILE): $(LIB_OBJS)\n@@ -2783,7 +2802,7 @@ t/helper/test-svn-fe$X: $(VCSSVN_LIB)\n t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))\n \n t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)\n-\t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n+\t$(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)\n \n check-sha1:: t/helper/test-tool$X\n \tt/helper/test-sha1.sh\n@@ -2966,6 +2985,7 @@ endif\n \t\t{ test -z \"$(NO_INSTALL_HARDLINKS)\" && \\\n \t\t  ln \"$$bindir/git$X\" \"$$bindir/$$p\" 2>/dev/null || \\\n \t\t  ln -s \"git$X\" \"$$bindir/$$p\" 2>/dev/null || \\\n+\t\t  cp \"exec-wrapper$X\" \"$$execdir/$$p\" 2>/dev/null || \\\n \t\t  cp \"$$bindir/git$X\" \"$$bindir/$$p\" || exit; } \\\n \tdone && \\\n \tfor p in $(BUILT_INS); do \\\n@@ -2975,6 +2995,7 @@ endif\n \t\t{ test -z \"$(NO_INSTALL_HARDLINKS)\" && \\\n \t\t  ln \"$$execdir/git$X\" \"$$execdir/$$p\" 2>/dev/null || \\\n \t\t  ln -s \"git$X\" \"$$execdir/$$p\" 2>/dev/null || \\\n+\t\t  cp \"exec-wrapper$X\" \"$$execdir/$$p\" 2>/dev/null || \\\n \t\t  cp \"$$execdir/git$X\" \"$$execdir/$$p\" || exit; } \\\n \tdone && \\\n \tremote_curl_aliases=\"$(REMOTE_CURL_ALIASES)\" && \\\ndiff --git a/config.mak.uname b/config.mak.uname\nindex db7f06b95f..77dc661107 100644\n--- a/config.mak.uname\n+++ b/config.mak.uname\n@@ -427,6 +427,7 @@ ifeq ($(uname_S),Windows)\n \n \tCC = compat/vcbuild/scripts/clink.pl\n \tAR = compat/vcbuild/scripts/lib.pl\n+\tLD = $(CC)\n \tCFLAGS =\n \tBASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE\n \tCOMPAT_OBJS = compat/msvc.o compat/winansi.o \\\n@@ -510,6 +511,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)\n \t# INLINE='' would just replace one set of warnings with another and\n \t# still not compile in c89 mode, due to non-const array initializations.\n \tCC = cc -c99\n+\tLD = $(CC)\n \t# Build down-rev compatible objects that don't use our new getopt_long.\n \tifeq ($(uname_R).$(uname_V),J06.21)\n \t\tCC += -WRVU=J06.20\n@@ -657,8 +659,10 @@ else\n \t\t\tBASIC_LDFLAGS += -Wl,--large-address-aware\n \t\tendif\n \t\tCC = gcc\n+\t\tLD = $(CC)\n \t\tCOMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \\\n \t\t\t-fstack-protector-strong\n+\t\tBASIC_LDFLAGS += -fstack-protector-strong\n \t\tEXTLIBS += -lntdll\n \t\tINSTALL = /bin/install\n \t\tNO_R_TO_GCC_LINKER = YesPlease\n@@ -691,6 +695,101 @@ ifeq ($(uname_S),QNX)\n \tNO_STRCASESTR = YesPlease\n \tNO_STRLCPY = YesPlease\n endif\n+ifeq ($(uname_S),Plan9)\n+\tCC = pcc\n+\tCFLAGS = -FVB+\n+\tARFLAGS = uv\n+\t# pcc don't use mismatched objfiles\n+\tifeq ($(objtype),386)\n+\t\tLD = 8l\n+\tendif\n+\tifeq ($(objtype),amd64)\n+\t\tLD = 6l\n+\tendif\n+\tifeq ($(objtype),arm)\n+\t\tLD = 5l\n+\tendif\n+\tifeq ($(objtype),mips)\n+\t\tLD = vl\n+\tendif\n+\tifeq ($(objtype),mips64)\n+\t\tLD = 4l\n+\tendif\n+\tifeq ($(objtype),power)\n+\t\tLD = ql\n+\tendif\n+\tifeq ($(objtype),sparc)\n+\t\tLD = kl\n+\tendif\n+\tifeq ($(objtype),spim)\n+\t\tLD = 0l\n+\tendif\n+\tifeq ($(objtype),spim64)\n+\t\tLD = xl\n+\tendif\n+\tBASIC_CFLAGS += -Icompat/plan9\n+\tBASIC_CFLAGS += -D__PLAN9__\n+\tBASIC_CFLAGS += -D_POSIX_SOURCE\n+\tBASIC_CFLAGS += -D_BSD_EXTENSION\n+\tBASIC_CFLAGS += -D_SUSV2_SOURCE\n+\tBASIC_CFLAGS += -D_PLAN9_SOURCE\n+\tBASIC_CFLAGS += -D_RESEARCH_SOURCE\n+\tBASIC_CFLAGS += -D_REENTRANT_SOURCE\n+\tBASIC_CFLAGS += -DHAVE_SOCK_OPTS\n+\tBASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6\n+\tBASIC_CFLAGS += -DHOME_ENVIRONMENT=\\\"home\\\"\n+\tBASIC_CFLAGS += -DPATH_ENVIRONMENT=\\\"path\\\"\n+\tBASIC_CFLAGS += -D_PATH_SEP=1\n+\tBASIC_CFLAGS += -D_PATH_DEFPATH=\\\"/bin\\\\x01.\\\\x01/bin/ape\\\"\n+\tCOMPAT_CFLAGS += -DHAVE_STDINT_H\n+\tCOMPAT_CFLAGS += -DHAVE_LOCALE_H\n+\tLDFLAGS = -L/$(objtype)/lib/ape\n+\n+\tNEEDS_CRYPTO_WITH_SSL = YesPlease\n+\tNEEDS_SYS_PARAM_H = YesPlease\n+\tNO_NSEC = YesPlease\n+\tNO_SYMLINK_HEAD = YesPlease\n+\tNO_GECOS_IN_PWENT = YesPlease\n+\tNO_GETTEXT = YesPlease\n+\tNO_SETENV = YesPlease\n+\tNO_STRCASESTR = YesPlease\n+\tNO_STRLCPY = YesPlease\n+\tNO_STRTOUMAX = YesPlease\n+\tNO_REGEX = YesPlease\n+\tNO_MKDTEMP = YesPlease\n+\tNO_UNSETENV = YesPlease\n+\tNO_INITGROUPS = YesPlease\n+\tNO_MMAP = YesPlease\n+\tNO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease\n+\tNO_STRUCT_ITIMERVAL = YesPlease\n+\tNO_SETITIMER = YesPlease\n+\tNO_ICONV = YesPlease\n+\tNO_SYMLINK_HEAD = YesPlease\n+\tOPENSSL_SHA1 = YesPlease\n+\tOPENSSL_SHA256 = YesPlease\n+\tNO_MEMMEM = YesPlease\n+\tHAVE_CLOCK_GETTIME = YesPlease\n+\n+\tNO_SVN_TESTS = YesPlease\n+\tNO_PERL = YesPlease\n+\tNO_PYTHON = YesPlease\n+\tNO_TCLTK = YesPlease\n+\tNO_INSTALL_HARDLINKS = YesPlease\n+\n+\tETC_GITCONFIG = /sys/lib/git/config\n+\tETC_GITATTRIBUTES = /sys/lib/git/attributes\n+\tUSER_GITCONFIG = ~/lib/git/config\n+\tUSER_GITCREDENTIALS = ~/lib/git/credentials\n+\tUSER_GITCREDENTIAL_CACHE = ~/lib/git/credential-cache\n+\n+\tDEFAULT_PAGER = /bin/p\n+\tPAGER_ENV = terminal=\n+\tSHELL_PATH = /bin/ape/sh\n+\tDEFAULT_EDITOR = /bin/ed\n+\n+\tCURL_LDFLAGS = -lcurl -lssl -lcrypto\n+\tUSE_EXEC_WRAPPER = YesPlease\n+endif\n \n vcxproj:\n \t# Require clean work tree\ndiff --git a/exec-wrapper.c b/exec-wrapper.c\nnew file mode 100644\nindex 0000000000..b56e871d02\n--- /dev/null\n+++ b/exec-wrapper.c\n@@ -0,0 +1,16 @@\n+#include <stdio.h>\n+#include <errno.h>\n+#include <string.h>\n+#include <unistd.h>\n+\n+int main(int argc, char **argv)\n+{\n+\t/* we should detect git-core path */\n+\n+\tUSED(argc);\n+\tif (execv(\"/bin/git\", argv) < 0) {\n+\t\tfprintf(stderr, \"%s: %s\\n\", argv[0], strerror(errno));\n+\t\treturn 1;\n+\t}\n+\treturn 0; /* can't happen */\n+}\ndiff --git a/generate-cmdlist.sh b/generate-cmdlist.sh\nindex 71158f7d8b..e4fe3ea608 100755\n--- a/generate-cmdlist.sh\n+++ b/generate-cmdlist.sh\n@@ -1,5 +1,10 @@\n #!/bin/sh\n \n+if ! echo abc | sed 's/(ab)c/\\1/' >/dev/null 2>&1\n+then\n+\talias sed='sed -E'\n+fi\n+\n die () {\n \techo \"$@\" >&2\n \texit 1\n@@ -10,7 +15,7 @@ command_list () {\n }\n \n get_categories () {\n-\ttr ' ' '\\n'|\n+\ttr ' ' '\\012'|\n \tgrep -v '^$' |\n \tsort |\n \tuniq\n@@ -18,16 +23,16 @@ get_categories () {\n \n category_list () {\n \tcommand_list \"$1\" |\n-\tcut -c 40- |\n+\tawk '{ print substr($0, 40) }' |\n \tget_categories\n }\n \n get_synopsis () {\n \tsed -n '\n-\t\t/^NAME/,/'\"$1\"'/H\n+\t\t/^NAME/,/'\"$1\"'/h\n \t\t${\n \t\t\tx\n-\t\t\ts/.*'\"$1\"' - \\(.*\\)/N_(\"\\1\")/\n+\t\t\ts/.*'\"$1\"' - (.*)/N_(\"\\1\")/\n \t\t\tp\n \t\t}' \"Documentation/$1.txt\"\n }\n@@ -60,16 +65,23 @@ define_category_names () {\n \techo \"};\"\n }\n \n+if test -z \"$(echo -n)\"\n+then\n+\talias print='echo -n'\n+else\n+\talias print='printf %s'\n+fi\n+\n print_command_list () {\n \techo \"static struct cmdname_help command_list[] = {\"\n \n \tcommand_list \"$1\" |\n \twhile read cmd rest\n \tdo\n-\t\tprintf \"\t{ \\\"$cmd\\\", $(get_synopsis $cmd), 0\"\n+\t\tprint \"\t{ \\\"$cmd\\\", $(get_synopsis $cmd), 0\"\n \t\tfor cat in $(echo \"$rest\" | get_categories)\n \t\tdo\n-\t\t\tprintf \" | CAT_$cat\"\n+\t\t\tprint \" | CAT_$cat\"\n \t\tdone\n \t\techo \" },\"\n \tdone\ndiff --git a/t/chainlint.sed b/t/chainlint.sed\nindex 70df40e34b..7282e7b426 100644\n--- a/t/chainlint.sed\n+++ b/t/chainlint.sed\n@@ -117,7 +117,7 @@\n /^[ \t]*!*[ \t]*(..*)[ \t]*[0-9]*[<>|&]/boneline\n \n # multi-line \"(...\\n...)\"\n-/^[ \t]*(/bsubshell\n+/^[ \t]*(/bsubsh\n \n # innocuous line -- print it and advance to next line\n b\n@@ -130,11 +130,11 @@ b\n }\n b\n \n-:subshell\n+:subsh\n # bare \"(\" line? -- stash for later printing\n /^[ \t]*([\t]*$/ {\n \th\n-\tbnextline\n+\tbnextln\n }\n # \"(...\" line -- split off and stash \"(\", then process \"...\" as its own line\n x\n@@ -143,7 +143,7 @@ x\n s/(//\n bslurp\n \n-:nextline\n+:nextln\n N\n s/.*\\n//\n \n@@ -151,10 +151,10 @@ s/.*\\n//\n # incomplete line \"...\\\"\n /\\\\$/bicmplte\n # multi-line quoted string \"...\\n...\"?\n-/\"/bdqstring\n+/\"/bdqstr\n # multi-line quoted string '...\\n...'? (but not contraction in string \"it's\")\n /'/{\n-\t/\"[^'\"]*'[^'\"]*\"/!bsqstring\n+\t/\"[^'\"]*'[^'\"]*\"/!bsqstr\n }\n :folded\n # here-doc -- swallow it\n@@ -163,8 +163,8 @@ s/.*\\n//\n # before closing \")\", \"done\", \"elsif\", \"else\", or \"fi\" will need to be\n # re-visited to drop \"suspect\" marking since final line of those constructs\n # legitimately lacks \"&&\", so \"suspect\" mark must be removed\n-/^[ \t]*#/bnextline\n-/^[ \t]*$/bnextline\n+/^[ \t]*#/bnextln\n+/^[ \t]*$/bnextln\n # in-line comment -- strip it (but not \"#\" in a string, Bash ${#...} array\n # length, or Perforce \"//depot/path#42\" revision in filespec)\n /[ \t]#/{\n@@ -175,22 +175,22 @@ s/.*\\n//\n # multi-line \"case ... esac\"\n /^[ \t]*case[ \t]..*[ \t]in/bcase\n # multi-line \"for ... done\" or \"while ... done\"\n-/^[ \t]*for[ \t]..*[ \t]in/bcontinue\n-/^[ \t]*while[ \t]/bcontinue\n-/^[ \t]*do[ \t]/bcontinue\n-/^[ \t]*do[ \t]*$/bcontinue\n-/;[ \t]*do/bcontinue\n+/^[ \t]*for[ \t]..*[ \t]in/bcnt\n+/^[ \t]*while[ \t]/bcnt\n+/^[ \t]*do[ \t]/bcnt\n+/^[ \t]*do[ \t]*$/bcnt\n+/;[ \t]*do/bcnt\n /^[ \t]*done[ \t]*&&[ \t]*$/bdone\n /^[ \t]*done[ \t]*$/bdone\n /^[ \t]*done[ \t]*[<>|]/bdone\n /^[ \t]*done[ \t]*)/bdone\n-/||[ \t]*exit[ \t]/bcontinue\n-/||[ \t]*exit[ \t]*$/bcontinue\n+/||[ \t]*exit[ \t]/bcnt\n+/||[ \t]*exit[ \t]*$/bcnt\n # multi-line \"if...elsif...else...fi\"\n-/^[ \t]*if[ \t]/bcontinue\n-/^[ \t]*then[ \t]/bcontinue\n-/^[ \t]*then[ \t]*$/bcontinue\n-/;[ \t]*then/bcontinue\n+/^[ \t]*if[ \t]/bcnt\n+/^[ \t]*then[ \t]/bcnt\n+/^[ \t]*then[ \t]*$/bcnt\n+/;[ \t]*then/bcnt\n /^[ \t]*elif[ \t]/belse\n /^[ \t]*elif[ \t]*$/belse\n /^[ \t]*else[ \t]/belse\n@@ -234,10 +234,10 @@ s/.*\\n//\n \t}\n }\n # line ends with pipe \"...|\" -- valid; not missing \"&&\"\n-/|[ \t]*$/bcontinue\n+/|[ \t]*$/bcnt\n # missing end-of-line \"&&\" -- mark suspect\n /&&[ \t]*$/!s/^/?!AMP?!/\n-:continue\n+:cnt\n # retrieve and print previous line\n x\n n\n@@ -250,7 +250,7 @@ s/\\\\\\n//\n bslurp\n \n # check for multi-line double-quoted string \"...\\n...\" -- fold to one line\n-:dqstring\n+:dqstr\n # remove all quote pairs\n s/\"\\([^\"]*\\)\"/@!\\1@!/g\n # done if no dangling quote\n@@ -258,13 +258,13 @@ s/\"\\([^\"]*\\)\"/@!\\1@!/g\n # otherwise, slurp next line and try again\n N\n s/\\n//\n-bdqstring\n+bdqstr\n :dqdone\n s/@!/\"/g\n bfolded\n \n # check for multi-line single-quoted string '...\\n...' -- fold to one line\n-:sqstring\n+:sqstr\n # remove all quote pairs\n s/'\\([^']*\\)'/@!\\1@!/g\n # done if no dangling quote\n@@ -272,7 +272,7 @@ s/'\\([^']*\\)'/@!\\1@!/g\n # otherwise, slurp next line and try again\n N\n s/\\n//\n-bsqstring\n+bsqstr\n :sqdone\n s/@!/'/g\n bfolded\n@@ -282,11 +282,11 @@ bfolded\n :heredoc\n s/^\\(.*\\)<<[ \t]*[-\\\\'\"]*\\([A-Za-z0-9_][A-Za-z0-9_]*\\)['\"]*/<\\2>\\1<</\n s/[ \t]*<<//\n-:heredsub\n+:heresub\n N\n /^<\\([^>]*\\)>.*\\n[ \t]*\\1[ \t]*$/!{\n \ts/\\n.*$//\n-\tbheredsub\n+\tbheresub\n }\n s/^<[^>]*>//\n s/\\n.*$//\n@@ -305,7 +305,7 @@ bcase\n x\n s/?!AMP?!//\n x\n-bcontinue\n+bcnt\n \n # found \"done\" closing for-loop or while-loop, or \"fi\" closing if-then -- drop\n # \"suspect\" from final contained line since that line legitimately lacks \"&&\"\n@@ -321,10 +321,10 @@ bchkchn\n # found nested multi-line \"(...\\n...)\" -- pass through untouched\n :nest\n x\n-:nstslurp\n+:nstslrp\n n\n # closing \")\" on own line -- stop nested slurp\n-/^[ \t]*)/bnstclose\n+/^[ \t]*)/bnstclos\n # comment -- not closing \")\" if in comment\n /^[ \t]*#/bnstcnt\n # \"$((...))\" -- arithmetic expansion; not closing \")\"\n@@ -332,11 +332,11 @@ n\n # \"$(...)\" -- command substitution; not closing \")\"\n /\\$([^)][^)]*)[^)]*$/bnstcnt\n # closing \"...)\" -- stop nested slurp\n-/)/bnstclose\n+/)/bnstclos\n :nstcnt\n x\n-bnstslurp\n-:nstclose\n+bnstslrp\n+:nstclos\n s/^/>>/\n # is it \"))\" which closes nested and parent subshells?\n /)[ \t]*)/bslurp\ndiff --git a/templates/Makefile b/templates/Makefile\nindex d22a71a399..19216a924a 100644\n--- a/templates/Makefile\n+++ b/templates/Makefile\n@@ -4,8 +4,16 @@ ifndef V\n \tQUIET = @\n endif\n \n+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n+\n INSTALL ?= install\n TAR ?= tar\n+TAR_CF = $(TAR) cf\n+TAR_XF = $(TAR) xof\n+ifeq ($(uname_S),Plan9)\n+\tTAR_CF = $(TAR) cf\n+\tTAR_XF = $(TAR) xf\n+endif\n RM ?= rm -f\n prefix ?= $(HOME)\n template_instdir ?= $(prefix)/share/git-core/templates\n@@ -62,5 +70,5 @@ clean:\n \n install: all\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'\n-\t(cd blt && $(TAR) cf - .) | \\\n-\t(cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -)\n+\t(cd blt && $(TAR_CF) - .) | \\\n+\t(cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR_XF) -)\n-- \ngitgitgadget\n"}]}