From 30cea4875fc38803872d995d3ace1e9b4aa7aa63 Mon Sep 17 00:00:00 2001 From: lufia Date: Mon, 19 Aug 2019 13:26:53 +0900 Subject: [PATCH 1/3] Change HOME, PATH, and .gitconfig paths to be customizable In Plan 9, almost environment variables are not capitalized. Signed-off-by: lufia --- Makefile | 40 +++++++++++++++++++++++++++++++++++++--- builtin/config.c | 2 +- config.c | 2 +- credential-cache.c | 2 +- credential-store.c | 2 +- exec-cmd.c | 4 ++-- git-compat-util.h | 8 ++++++++ help.c | 2 +- path.c | 6 +++--- run-command.c | 4 ++-- sequencer.c | 2 +- shell.c | 2 +- 12 files changed, 59 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 90aa329eb78368..95bf9bdb25c6bb 100644 --- a/Makefile +++ b/Makefile @@ -525,8 +525,21 @@ perllibdir = $(sharedir)/perl5 localedir = $(sharedir)/locale template_dir = share/git-core/templates htmldir = $(prefix)/share/doc/git-doc -ETC_GITCONFIG = $(sysconfdir)/gitconfig -ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes +ifndef ETC_GITCONFIG + ETC_GITCONFIG = $(sysconfdir)/gitconfig +endif +ifndef ETC_GITATTRIBUTES + ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes +endif +ifndef USER_GITCONFIG + USER_GITCONFIG = ~/.gitconfig +endif +ifndef USER_GITCREDENTIALS + USER_GITCREDENTIALS = ~/.git-credentials +endif +ifndef USER_GITCREDENTIAL_CACHE + USER_GITCREDENTIAL_CACHE = ~/.git-credential-cache +endif lib = lib # DESTDIR = pathsep = : @@ -1930,6 +1943,9 @@ endif ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG)) ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES)) +USER_GITCONFIG_SQ = $(subst ','\'',$(USER_GITCONFIG)) +USER_GITCREDENTIALS_SQ = $(subst ','\'',$(USER_GITCREDENTIALS)) +USER_GITCREDENTIAL_CACHE_SQ = $(subst ','\'',$(USER_GITCREDENTIAL_CACHE)) DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) bindir_SQ = $(subst ','\'',$(bindir)) @@ -2426,12 +2442,30 @@ builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \ config.sp config.s config.o: GIT-PREFIX config.sp config.s config.o: EXTRA_CPPFLAGS = \ - -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' + -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' \ + -DUSER_GITCONFIG='"$(USER_GITCONFIG_SQ)"' + +builtin/config.sp builtin/config.s builtin/config.o: GIT-PREFIX +builtin/config.sp builtin/config.s builtin/config.o: EXTRA_CPPFLAGS = \ + -DUSER_GITCONFIG='"$(USER_GITCONFIG_SQ)"' + +sequencer.sp sequencer.s sequencer.o: GIT-PREFIX +sequencer.sp sequencer.s sequencer.o: EXTRA_CPPFLAGS = \ + -DUSER_GITCONFIG='"$(USER_GITCONFIG_SQ)"' attr.sp attr.s attr.o: GIT-PREFIX attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \ -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"' +credential-cache.sp credential-cache.s credential-cache.o: GIT-PREFIX +credential-cache.sp credential-cache.s credential-cache.o: EXTRA_CPPFLAGS = \ + -DUSER_GITCONFIG='"$(USER_GITCONFIG_SQ)"' \ + -DUSER_GITCREDENTIAL_CACHE='"$(USER_GITCREDENTIAL_CACHE_SQ)"' + +credential-store.sp credential-store.s credential-store.o: GIT-PREFIX +credential-store.sp credential-store.s credential-store.o: EXTRA_CPPFLAGS = \ + -DUSER_GITCREDENTIALS='"$(USER_GITCREDENTIALS_SQ)"' + gettext.sp gettext.s gettext.o: GIT-PREFIX gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \ -DGIT_LOCALE_PATH='"$(localedir_relative_SQ)"' diff --git a/builtin/config.c b/builtin/config.c index ee4aef6a355576..90434bbdd57988 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -642,7 +642,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) } if (use_global_config) { - char *user_config = expand_user_path("~/.gitconfig", 0); + char *user_config = expand_user_path(USER_GITCONFIG, 0); char *xdg_config = xdg_config_home("config"); if (!user_config) diff --git a/config.c b/config.c index 8db9c77098f01b..ba46bced671c23 100644 --- a/config.c +++ b/config.c @@ -1716,7 +1716,7 @@ static int do_git_config_sequence(const struct config_options *opts, { int ret = 0; char *xdg_config = xdg_config_home("config"); - char *user_config = expand_user_path("~/.gitconfig", 0); + char *user_config = expand_user_path(USER_GITCONFIG, 0); char *repo_config; enum config_scope prev_parsing_scope = current_parsing_scope; diff --git a/credential-cache.c b/credential-cache.c index 1cccc3a0b9cfb2..3e2ed6c0bed251 100644 --- a/credential-cache.c +++ b/credential-cache.c @@ -87,7 +87,7 @@ static char *get_socket_path(void) { struct stat sb; char *old_dir, *socket; - old_dir = expand_user_path("~/.git-credential-cache", 0); + old_dir = expand_user_path(USER_GITCREDENTIAL_CACHE, 0); if (old_dir && !stat(old_dir, &sb) && S_ISDIR(sb.st_mode)) socket = xstrfmt("%s/socket", old_dir); else diff --git a/credential-store.c b/credential-store.c index 294e7716815622..7d236a3129ee1f 100644 --- a/credential-store.c +++ b/credential-store.c @@ -169,7 +169,7 @@ int cmd_main(int argc, const char **argv) if (file) { string_list_append(&fns, file); } else { - if ((file = expand_user_path("~/.git-credentials", 0))) + if ((file = expand_user_path(USER_GITCREDENTIALS, 0))) string_list_append_nodup(&fns, file); file = xdg_config_home("credentials"); if (file) diff --git a/exec-cmd.c b/exec-cmd.c index 7deeab30397cf2..c95fc8dbdd81a3 100644 --- a/exec-cmd.c +++ b/exec-cmd.c @@ -304,7 +304,7 @@ static void add_path(struct strbuf *out, const char *path) void setup_path(void) { const char *exec_path = git_exec_path(); - const char *old_path = getenv("PATH"); + const char *old_path = getenv(PATH_ENVIRONMENT); struct strbuf new_path = STRBUF_INIT; git_set_exec_path(exec_path); @@ -315,7 +315,7 @@ void setup_path(void) else strbuf_addstr(&new_path, _PATH_DEFPATH); - setenv("PATH", new_path.buf, 1); + setenv(PATH_ENVIRONMENT, new_path.buf, 1); strbuf_release(&new_path); } diff --git a/git-compat-util.h b/git-compat-util.h index a73632e8e43ce9..9f0856e1c53b78 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -1224,6 +1224,14 @@ int warn_on_fopen_errors(const char *path); # define SHELL_PATH "/bin/sh" #endif +#ifndef HOME_ENVIRONMENT +# define HOME_ENVIRONMENT "HOME" +#endif + +#ifndef PATH_ENVIRONMENT +# define PATH_ENVIRONMENT "PATH" +#endif + #ifndef _POSIX_THREAD_SAFE_FUNCTIONS #define flockfile(fh) #define funlockfile(fh) diff --git a/help.c b/help.c index 1de9c0d589cd9b..3b29a1c89a8c73 100644 --- a/help.c +++ b/help.c @@ -260,7 +260,7 @@ void load_command_list(const char *prefix, struct cmdnames *main_cmds, struct cmdnames *other_cmds) { - const char *env_path = getenv("PATH"); + const char *env_path = getenv(PATH_ENVIRONMENT); const char *exec_path = git_exec_path(); if (exec_path) { diff --git a/path.c b/path.c index 8b2c7531919eef..1cca180767bcd5 100644 --- a/path.c +++ b/path.c @@ -737,7 +737,7 @@ char *expand_user_path(const char *path, int real_home) const char *username = path + 1; size_t username_len = first_slash - username; if (username_len == 0) { - const char *home = getenv("HOME"); + const char *home = getenv(HOME_ENVIRONMENT); if (!home) goto return_null; if (real_home) @@ -1507,7 +1507,7 @@ char *xdg_config_home(const char *filename) if (config_home && *config_home) return mkpathdup("%s/git/%s", config_home, filename); - home = getenv("HOME"); + home = getenv(HOME_ENVIRONMENT); if (home) return mkpathdup("%s/.config/git/%s", home, filename); return NULL; @@ -1522,7 +1522,7 @@ char *xdg_cache_home(const char *filename) if (cache_home && *cache_home) return mkpathdup("%s/git/%s", cache_home, filename); - home = getenv("HOME"); + home = getenv(HOME_ENVIRONMENT); if (home) return mkpathdup("%s/.cache/git/%s", home, filename); return NULL; diff --git a/run-command.c b/run-command.c index 9b3a57d1e392c8..7ddf5ad4f0a198 100644 --- a/run-command.c +++ b/run-command.c @@ -180,14 +180,14 @@ int is_executable(const char *name) */ static char *locate_in_PATH(const char *file) { - const char *p = getenv("PATH"); + const char *p = getenv(PATH_ENVIRONMENT); struct strbuf buf = STRBUF_INIT; if (!p || !*p) return NULL; while (1) { - const char *end = strchrnul(p, ':'); + const char *end = strchrnul(p, PATH_SEP); strbuf_reset(&buf); diff --git a/sequencer.c b/sequencer.c index fd7701c88a8643..a40dc85d4dc468 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1170,7 +1170,7 @@ N_("Your name and email address were configured automatically based\n" static const char *implicit_ident_advice(void) { - char *user_config = expand_user_path("~/.gitconfig", 0); + char *user_config = expand_user_path(USER_GITCONFIG, 0); char *xdg_config = xdg_config_home("config"); int config_exists = file_exists(user_config) || file_exists(xdg_config); diff --git a/shell.c b/shell.c index cef7ffdc9e1d30..06c69411c38046 100644 --- a/shell.c +++ b/shell.c @@ -40,7 +40,7 @@ static char *make_cmd(const char *prog) static void cd_to_homedir(void) { - const char *home = getenv("HOME"); + const char *home = getenv(HOME_ENVIRONMENT); if (!home) die("could not determine user's home directory; HOME is unset"); if (chdir(home) == -1) From 8aadd6444dfafe554d452555d42e7dd885d7155e Mon Sep 17 00:00:00 2001 From: lufia Date: Mon, 19 Aug 2019 13:29:44 +0900 Subject: [PATCH 2/3] Fix C syntactic errors for the Plan 9 C compiler Signed-off-by: lufia --- compat/plan9/openssl/crypto.h | 5 +++++ compat/regex/regex_internal.h | 3 +++ config.c | 3 ++- git-compat-util.h | 9 ++++++++- parse-options.h | 9 +++++++++ remove-bitfields.sh | 17 +++++++++++++++++ 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 compat/plan9/openssl/crypto.h create mode 100755 remove-bitfields.sh diff --git a/compat/plan9/openssl/crypto.h b/compat/plan9/openssl/crypto.h new file mode 100644 index 00000000000000..9d1ef43422ce19 --- /dev/null +++ b/compat/plan9/openssl/crypto.h @@ -0,0 +1,5 @@ +#ifndef __attribute__ +#define __attribute__(x) +#endif + +#include_next diff --git a/compat/regex/regex_internal.h b/compat/regex/regex_internal.h index 0bad8b841eda89..dd17948e4e4a8f 100644 --- a/compat/regex/regex_internal.h +++ b/compat/regex/regex_internal.h @@ -25,6 +25,9 @@ #include #include +#ifdef NEEDS_SYS_PARAM_H +#include +#endif #if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC # include #endif diff --git a/config.c b/config.c index ba46bced671c23..6b3057e9cd1014 100644 --- a/config.c +++ b/config.c @@ -2457,7 +2457,8 @@ static int store_aux_event(enum config_event_t type, return error(_("invalid section name '%s'"), cf->var.buf); if (cf->subsection_case_sensitive) - cmpfn = strncasecmp; + /* Plan 9's strncasecmp is typed (char*, char*, int) */ + cmpfn = (int (*)(const char*, const char*, size_t))strncasecmp; else cmpfn = strncmp; diff --git a/git-compat-util.h b/git-compat-util.h index 9f0856e1c53b78..2d977cde0bd563 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -164,7 +164,11 @@ #define GIT_WINDOWS_NATIVE #endif +#include #include +#ifdef __PLAN9__ +#include +#endif #include #include #include @@ -180,7 +184,6 @@ #ifdef NEEDS_SYS_PARAM_H #include #endif -#include #include #include #include @@ -282,6 +285,10 @@ char *gitbasename(char *); char *gitdirname(char *); #endif +#ifdef __PLAN9__ +#include +#endif + #ifndef NO_ICONV #include #endif diff --git a/parse-options.h b/parse-options.h index 46af9420930552..6e932ab0a5511e 100644 --- a/parse-options.h +++ b/parse-options.h @@ -59,6 +59,15 @@ enum parse_opt_result { PARSE_OPT_UNKNOWN }; +enum parse_opt_result { + PARSE_OPT_COMPLETE = -3, + PARSE_OPT_HELP = -2, + PARSE_OPT_ERROR = -1, /* must be the same as error() */ + PARSE_OPT_DONE = 0, /* fixed so that "return 0" works */ + PARSE_OPT_NON_OPTION, + PARSE_OPT_UNKNOWN +}; + struct option; typedef int parse_opt_cb(const struct option *, const char *arg, int unset); diff --git a/remove-bitfields.sh b/remove-bitfields.sh new file mode 100755 index 00000000000000..952bd34f124e62 --- /dev/null +++ b/remove-bitfields.sh @@ -0,0 +1,17 @@ +#!/bin/ape/sh +# Plan 9 C compiler rejects initialization a structure including bit field. +# usage: remove-bitfields.sh [dir ...] + +if ! echo abc | sed 's/(ab)c/\1/' >/dev/null 2>&1 +then + alias sed='sed -E' +fi + +trap 'rm -f /tmp/remove-bitfields.$pid; exit 1' 1 2 3 15 EXIT + +files=$(du -a $* | awk '/\.[ch]$/ { print $2 }') +for i in $files +do + sed '/(^[ ]*\*|\?)/!s/([a-z]+[a-z0-9]*) *: *[0-9]+([,;])/\1\2/g' $i >/tmp/remove-bitfields.$pid + cp /tmp/remove-bitfields.$pid $i +done From 8d54009a44c9e660bf29b3053b8d9bf1b78e2871 Mon Sep 17 00:00:00 2001 From: lufia Date: Sat, 24 Aug 2019 12:15:03 +0900 Subject: [PATCH 3/3] Support Plan 9 dialect Plan 9 ANSI/POSIX environment is: * No expr(1) * sed(1) limits max length of label to 7 characters * pcc ignores object files that has incorrect extension, so should use underlying loader directly. * No ln(1). Instead use bind(1), but bind isn't persisted to the disk. However it isn't efficient to copy git to git subcommands such as git-add. Therefore Plan 9 needs exec-wrapper to switch behavior by executable name. * tar(1) don't have -o option Signed-off-by: lufia --- GIT-VERSION-GEN | 2 +- Makefile | 41 ++++++++++++++----- config.mak.uname | 99 +++++++++++++++++++++++++++++++++++++++++++++ exec-wrapper.c | 16 ++++++++ generate-cmdlist.sh | 24 ++++++++--- t/chainlint.sed | 66 +++++++++++++++--------------- templates/Makefile | 12 +++++- 7 files changed, 208 insertions(+), 52 deletions(-) create mode 100644 exec-wrapper.c diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index c30d71abda0b3d..e8b3c250e911b5 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -26,7 +26,7 @@ else VN="$DEF_VER" fi -VN=$(expr "$VN" : v*'\(.*\)') +VN=${VN#v} if test -r $GVF then diff --git a/Makefile b/Makefile index 95bf9bdb25c6bb..36cfbda647e3bf 100644 --- a/Makefile +++ b/Makefile @@ -556,6 +556,7 @@ export prefix bindir sharedir sysconfdir gitwebdir perllibdir localedir # Set our default programs CC = cc +LD = cc AR = ar RM = rm -f DIFF = diff @@ -792,6 +793,10 @@ ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) # what 'all' will build but not install in gitexecdir OTHER_PROGRAMS = git$X +# what 'all' will build but not install in neither bindir and gitexecdir, +COMPAT_PROGRAM_OBJS = +COMPAT_PROGRAMS = + # what test wrappers are needed and 'install' will install, in bindir BINDIR_PROGRAMS_NEED_X += git BINDIR_PROGRAMS_NEED_X += git-receive-pack @@ -1882,6 +1887,11 @@ ifndef PAGER_ENV PAGER_ENV = LESS=FRX LV=-c endif +ifdef USE_EXEC_WRAPPER + COMPAT_PROGRAM_OBJS += exec-wrapper.o + COMPAT_PROGRAMS += exec-wrapper$X +endif + QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir QUIET_SUBDIR1 = @@ -2082,7 +2092,7 @@ profile-fast: profile-clean $(MAKE) PROFILE=USE all -all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS +all:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) $(COMPAT_PROGRAMS) GIT-BUILD-OPTIONS ifneq (,$X) $(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';) endif @@ -2142,7 +2152,7 @@ git.sp git.s git.o: EXTRA_CPPFLAGS = \ '-DGIT_INFO_PATH="$(infodir_relative_SQ)"' git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \ + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) \ $(filter %.o,$^) $(LIBS) help.sp help.s help.o: command-list.h @@ -2161,10 +2171,11 @@ version.sp version.s version.o: EXTRA_CPPFLAGS = \ GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \ git rev-parse -q --verify HEAD 2>/dev/null)"' -$(BUILT_INS): git$X +$(BUILT_INS): git$X $(COMPAT_PROGRAMS) $(QUIET_BUILT_IN)$(RM) $@ && \ ln $< $@ 2>/dev/null || \ ln -s $< $@ 2>/dev/null || \ + cp exec-wrapper$X $@ 2>/dev/null || \ cp $< $@ config-list.h: generate-configlist.sh @@ -2370,6 +2381,7 @@ VCSSVN_OBJS += vcs-svn/svndump.o TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \ + $(COMPAT_PROGRAM_OBJS) \ $(XDIFF_OBJS) \ $(VCSSVN_OBJS) \ $(FUZZ_OBJS) \ @@ -2490,26 +2502,33 @@ compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \ compat/nedmalloc/nedmalloc.sp: SP_EXTRA_FLAGS += -Wno-non-pointer-null endif +exec-wrapper.sp exec-wrapper.s exec-wrapper.o: EXTRA_CPPFLAGS = \ + '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \ + '-DBINDIR="$(bindir_relative_SQ)"' + +exec-wrapper$X: exec-wrapper.o GIT-LDFLAGS + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) + git-%$X: %.o GIT-LDFLAGS $(GITLIBS) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) git-bugreport$X: bugreport.o GIT-LDFLAGS $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(LIBS) git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(IMAP_SEND_LDFLAGS) $(LIBS) git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(CURL_LIBCURL) $(LIBS) git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS) git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \ + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \ $(VCSSVN_LIB) $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY) @@ -2519,7 +2538,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY) cp $< $@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \ $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS) $(LIB_FILE): $(LIB_OBJS) @@ -2814,7 +2833,7 @@ t/helper/test-svn-fe$X: $(VCSSVN_LIB) t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS) + $(QUIET_LINK)$(LD) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS) check-sha1:: t/helper/test-tool$X t/helper/test-sha1.sh @@ -2997,6 +3016,7 @@ endif { test -z "$(NO_INSTALL_HARDLINKS)" && \ ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \ ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \ + cp "exec-wrapper$X" "$$execdir/$$p" 2>/dev/null || \ cp "$$bindir/git$X" "$$bindir/$$p" || exit; } \ done && \ for p in $(BUILT_INS); do \ @@ -3006,6 +3026,7 @@ endif { test -z "$(NO_INSTALL_HARDLINKS)" && \ ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \ ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \ + cp "exec-wrapper$X" "$$execdir/$$p" 2>/dev/null || \ cp "$$execdir/git$X" "$$execdir/$$p" || exit; } \ done && \ remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \ diff --git a/config.mak.uname b/config.mak.uname index c7eba69e54e669..e176b74db12753 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -436,6 +436,7 @@ ifeq ($(uname_S),Windows) CC = compat/vcbuild/scripts/clink.pl AR = compat/vcbuild/scripts/lib.pl + LD = $(CC) CFLAGS = BASIC_CFLAGS = -nologo -I. -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE COMPAT_OBJS = compat/msvc.o compat/winansi.o \ @@ -518,6 +519,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL) # INLINE='' would just replace one set of warnings with another and # still not compile in c89 mode, due to non-const array initializations. CC = cc -c99 + LD = $(CC) # Build down-rev compatible objects that don't use our new getopt_long. ifeq ($(uname_R).$(uname_V),J06.21) CC += -WRVU=J06.20 @@ -665,8 +667,10 @@ else BASIC_LDFLAGS += -Wl,--large-address-aware endif CC = gcc + LD = $(CC) COMPAT_CFLAGS += -D__USE_MINGW_ANSI_STDIO=0 -DDETECT_MSYS_TTY \ -fstack-protector-strong + BASIC_LDFLAGS += -fstack-protector-strong EXTLIBS += -lntdll INSTALL = /bin/install NO_R_TO_GCC_LINKER = YesPlease @@ -699,6 +703,101 @@ ifeq ($(uname_S),QNX) NO_STRCASESTR = YesPlease NO_STRLCPY = YesPlease endif +ifeq ($(uname_S),Plan9) + CC = pcc + CFLAGS = -FVB+ + ARFLAGS = uv + # pcc don't use mismatched objfiles + ifeq ($(objtype),386) + LD = 8l + endif + ifeq ($(objtype),amd64) + LD = 6l + endif + ifeq ($(objtype),arm) + LD = 5l + endif + ifeq ($(objtype),mips) + LD = vl + endif + ifeq ($(objtype),mips64) + LD = 4l + endif + ifeq ($(objtype),power) + LD = ql + endif + ifeq ($(objtype),sparc) + LD = kl + endif + ifeq ($(objtype),spim) + LD = 0l + endif + ifeq ($(objtype),spim64) + LD = xl + endif + BASIC_CFLAGS += -Icompat/plan9 + BASIC_CFLAGS += -D__PLAN9__ + BASIC_CFLAGS += -D_POSIX_SOURCE + BASIC_CFLAGS += -D_BSD_EXTENSION + BASIC_CFLAGS += -D_SUSV2_SOURCE + BASIC_CFLAGS += -D_PLAN9_SOURCE + BASIC_CFLAGS += -D_RESEARCH_SOURCE + BASIC_CFLAGS += -D_REENTRANT_SOURCE + BASIC_CFLAGS += -DHAVE_SOCK_OPTS + BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in6 + BASIC_CFLAGS += -DHOME_ENVIRONMENT=\"home\" + BASIC_CFLAGS += -DPATH_ENVIRONMENT=\"path\" + BASIC_CFLAGS += -D_PATH_SEP=1 + BASIC_CFLAGS += -D_PATH_DEFPATH=\"/bin\\x01.\\x01/bin/ape\" + COMPAT_CFLAGS += -DHAVE_STDINT_H + COMPAT_CFLAGS += -DHAVE_LOCALE_H + LDFLAGS = -L/$(objtype)/lib/ape + + NEEDS_CRYPTO_WITH_SSL = YesPlease + NEEDS_SYS_PARAM_H = YesPlease + NO_NSEC = YesPlease + NO_SYMLINK_HEAD = YesPlease + NO_GECOS_IN_PWENT = YesPlease + NO_GETTEXT = YesPlease + NO_SETENV = YesPlease + NO_STRCASESTR = YesPlease + NO_STRLCPY = YesPlease + NO_STRTOUMAX = YesPlease + NO_REGEX = YesPlease + NO_MKDTEMP = YesPlease + NO_UNSETENV = YesPlease + NO_INITGROUPS = YesPlease + NO_MMAP = YesPlease + NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease + NO_STRUCT_ITIMERVAL = YesPlease + NO_SETITIMER = YesPlease + NO_ICONV = YesPlease + NO_SYMLINK_HEAD = YesPlease + OPENSSL_SHA1 = YesPlease + OPENSSL_SHA256 = YesPlease + NO_MEMMEM = YesPlease + HAVE_CLOCK_GETTIME = YesPlease + + NO_SVN_TESTS = YesPlease + NO_PERL = YesPlease + NO_PYTHON = YesPlease + NO_TCLTK = YesPlease + NO_INSTALL_HARDLINKS = YesPlease + + ETC_GITCONFIG = /sys/lib/git/config + ETC_GITATTRIBUTES = /sys/lib/git/attributes + USER_GITCONFIG = ~/lib/git/config + USER_GITCREDENTIALS = ~/lib/git/credentials + USER_GITCREDENTIAL_CACHE = ~/lib/git/credential-cache + + DEFAULT_PAGER = /bin/p + PAGER_ENV = terminal= + SHELL_PATH = /bin/ape/sh + DEFAULT_EDITOR = /bin/ed + + CURL_LDFLAGS = -lcurl -lssl -lcrypto + USE_EXEC_WRAPPER = YesPlease +endif vcxproj: # Require clean work tree diff --git a/exec-wrapper.c b/exec-wrapper.c new file mode 100644 index 00000000000000..b56e871d029782 --- /dev/null +++ b/exec-wrapper.c @@ -0,0 +1,16 @@ +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + /* we should detect git-core path */ + + USED(argc); + if (execv("/bin/git", argv) < 0) { + fprintf(stderr, "%s: %s\n", argv[0], strerror(errno)); + return 1; + } + return 0; /* can't happen */ +} diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh index 45fecf8bdfb21a..bb6f9d7e0b30d5 100755 --- a/generate-cmdlist.sh +++ b/generate-cmdlist.sh @@ -1,5 +1,10 @@ #!/bin/sh +if ! echo abc | sed 's/(ab)c/\1/' >/dev/null 2>&1 +then + alias sed='sed -E' +fi + die () { echo "$@" >&2 exit 1 @@ -10,7 +15,7 @@ command_list () { } get_categories () { - tr ' ' '\n'| + tr ' ' '\012'| grep -v '^$' | sort | uniq @@ -18,16 +23,16 @@ get_categories () { category_list () { command_list "$1" | - cut -c 40- | + awk '{ print substr($0, 40) }' | get_categories } get_synopsis () { sed -n ' - /^NAME/,/'"$1"'/H + /^NAME/,/'"$1"'/h ${ x - s/.*'"$1"' - \(.*\)/N_("\1")/ + s/.*'"$1"' - (.*)/N_("\1")/ p }' "Documentation/$1.txt" } @@ -60,16 +65,23 @@ define_category_names () { echo "};" } +if test -z "$(echo -n)" +then + alias print='echo -n' +else + alias print='printf %s' +fi + print_command_list () { echo "static struct cmdname_help command_list[] = {" command_list "$1" | while read cmd rest do - printf " { \"$cmd\", $(get_synopsis $cmd), 0" + print " { \"$cmd\", $(get_synopsis $cmd), 0" for cat in $(echo "$rest" | get_categories) do - printf " | CAT_$cat" + print " | CAT_$cat" done echo " }," done diff --git a/t/chainlint.sed b/t/chainlint.sed index 70df40e34b7df8..7282e7b4266d2d 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -117,7 +117,7 @@ /^[ ]*!*[ ]*(..*)[ ]*[0-9]*[<>|&]/boneline # multi-line "(...\n...)" -/^[ ]*(/bsubshell +/^[ ]*(/bsubsh # innocuous line -- print it and advance to next line b @@ -130,11 +130,11 @@ b } b -:subshell +:subsh # bare "(" line? -- stash for later printing /^[ ]*([ ]*$/ { h - bnextline + bnextln } # "(..." line -- split off and stash "(", then process "..." as its own line x @@ -143,7 +143,7 @@ x s/(// bslurp -:nextline +:nextln N s/.*\n// @@ -151,10 +151,10 @@ s/.*\n// # incomplete line "...\" /\\$/bicmplte # multi-line quoted string "...\n..."? -/"/bdqstring +/"/bdqstr # multi-line quoted string '...\n...'? (but not contraction in string "it's") /'/{ - /"[^'"]*'[^'"]*"/!bsqstring + /"[^'"]*'[^'"]*"/!bsqstr } :folded # here-doc -- swallow it @@ -163,8 +163,8 @@ s/.*\n// # before closing ")", "done", "elsif", "else", or "fi" will need to be # re-visited to drop "suspect" marking since final line of those constructs # legitimately lacks "&&", so "suspect" mark must be removed -/^[ ]*#/bnextline -/^[ ]*$/bnextline +/^[ ]*#/bnextln +/^[ ]*$/bnextln # in-line comment -- strip it (but not "#" in a string, Bash ${#...} array # length, or Perforce "//depot/path#42" revision in filespec) /[ ]#/{ @@ -175,22 +175,22 @@ s/.*\n// # multi-line "case ... esac" /^[ ]*case[ ]..*[ ]in/bcase # multi-line "for ... done" or "while ... done" -/^[ ]*for[ ]..*[ ]in/bcontinue -/^[ ]*while[ ]/bcontinue -/^[ ]*do[ ]/bcontinue -/^[ ]*do[ ]*$/bcontinue -/;[ ]*do/bcontinue +/^[ ]*for[ ]..*[ ]in/bcnt +/^[ ]*while[ ]/bcnt +/^[ ]*do[ ]/bcnt +/^[ ]*do[ ]*$/bcnt +/;[ ]*do/bcnt /^[ ]*done[ ]*&&[ ]*$/bdone /^[ ]*done[ ]*$/bdone /^[ ]*done[ ]*[<>|]/bdone /^[ ]*done[ ]*)/bdone -/||[ ]*exit[ ]/bcontinue -/||[ ]*exit[ ]*$/bcontinue +/||[ ]*exit[ ]/bcnt +/||[ ]*exit[ ]*$/bcnt # multi-line "if...elsif...else...fi" -/^[ ]*if[ ]/bcontinue -/^[ ]*then[ ]/bcontinue -/^[ ]*then[ ]*$/bcontinue -/;[ ]*then/bcontinue +/^[ ]*if[ ]/bcnt +/^[ ]*then[ ]/bcnt +/^[ ]*then[ ]*$/bcnt +/;[ ]*then/bcnt /^[ ]*elif[ ]/belse /^[ ]*elif[ ]*$/belse /^[ ]*else[ ]/belse @@ -234,10 +234,10 @@ s/.*\n// } } # line ends with pipe "...|" -- valid; not missing "&&" -/|[ ]*$/bcontinue +/|[ ]*$/bcnt # missing end-of-line "&&" -- mark suspect /&&[ ]*$/!s/^/?!AMP?!/ -:continue +:cnt # retrieve and print previous line x n @@ -250,7 +250,7 @@ s/\\\n// bslurp # check for multi-line double-quoted string "...\n..." -- fold to one line -:dqstring +:dqstr # remove all quote pairs s/"\([^"]*\)"/@!\1@!/g # done if no dangling quote @@ -258,13 +258,13 @@ s/"\([^"]*\)"/@!\1@!/g # otherwise, slurp next line and try again N s/\n// -bdqstring +bdqstr :dqdone s/@!/"/g bfolded # check for multi-line single-quoted string '...\n...' -- fold to one line -:sqstring +:sqstr # remove all quote pairs s/'\([^']*\)'/@!\1@!/g # done if no dangling quote @@ -272,7 +272,7 @@ s/'\([^']*\)'/@!\1@!/g # otherwise, slurp next line and try again N s/\n// -bsqstring +bsqstr :sqdone s/@!/'/g bfolded @@ -282,11 +282,11 @@ bfolded :heredoc s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<]*\)>.*\n[ ]*\1[ ]*$/!{ s/\n.*$// - bheredsub + bheresub } s/^<[^>]*>// s/\n.*$// @@ -305,7 +305,7 @@ bcase x s/?!AMP?!// x -bcontinue +bcnt # found "done" closing for-loop or while-loop, or "fi" closing if-then -- drop # "suspect" from final contained line since that line legitimately lacks "&&" @@ -321,10 +321,10 @@ bchkchn # found nested multi-line "(...\n...)" -- pass through untouched :nest x -:nstslurp +:nstslrp n # closing ")" on own line -- stop nested slurp -/^[ ]*)/bnstclose +/^[ ]*)/bnstclos # comment -- not closing ")" if in comment /^[ ]*#/bnstcnt # "$((...))" -- arithmetic expansion; not closing ")" @@ -332,11 +332,11 @@ n # "$(...)" -- command substitution; not closing ")" /\$([^)][^)]*)[^)]*$/bnstcnt # closing "...)" -- stop nested slurp -/)/bnstclose +/)/bnstclos :nstcnt x -bnstslurp -:nstclose +bnstslrp +:nstclos s/^/>>/ # is it "))" which closes nested and parent subshells? /)[ ]*)/bslurp diff --git a/templates/Makefile b/templates/Makefile index d22a71a3999b3d..19216a924a4f9b 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -4,8 +4,16 @@ ifndef V QUIET = @ endif +uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') + INSTALL ?= install TAR ?= tar +TAR_CF = $(TAR) cf +TAR_XF = $(TAR) xof +ifeq ($(uname_S),Plan9) + TAR_CF = $(TAR) cf + TAR_XF = $(TAR) xf +endif RM ?= rm -f prefix ?= $(HOME) template_instdir ?= $(prefix)/share/git-core/templates @@ -62,5 +70,5 @@ clean: install: all $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)' - (cd blt && $(TAR) cf - .) | \ - (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xof -) + (cd blt && $(TAR_CF) - .) | \ + (cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR_XF) -)