[v2,0/3] Port git to Plan 9
mbox series

Message ID pull.305.v2.git.gitgitgadget@gmail.com
Headers show
Series
  • Port git to Plan 9
Related show

Message

Ben Keene via GitGitGadget Aug. 27, 2019, 1:46 p.m. UTC
Changes from v1
===============

 * Use gmake
 * Use sh
 * Remove dependencies to Plan 9 tools; rc and mk

What I did
==========

I ported git, and git subcommands with gmake to Plan 9. This pull request
contains patches for existing codes, and new files to build git in Plan 9.

I added three new options into Makefile.

 * USER_GITCONFIG - default ~/.gitconfig
 * USER_GITCREDENTIALS - default ~/.git-credentials
 * USER_GITCREDENTIAL_CACHE - default ~/.git-credential-cache
 * USE_EXEC_WRAPPER - default empty

In Plan 9, user configuration files are stored at $home/lib, instead of
dotfiles.
http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html

And Plan 9 haven't hard link and symbolic link. Thus I added exec-wrapper to
want to shrink disk usage.
http://doc.cat-v.org/plan_9/4th_edition/papers/lexnames

Installation
============

# ANSI/POSIX commands are installed at /bin only in current namespace.
% bind -a /bin/ape /bin

# Plan 9 C compiler can't initialize struct fields that is bit field so remove bit fields from all C files.
% ./remove-bitfields.sh

# build Git toolchain with /n/sources/contrib/andrey/make-3.81.tgz
% gmake 'prefix=' 'gitexecdir=bin/git-core' 'sysconfdir=sys/lib/git' 'template_dir=sys/lib/git/templates' install

lufia (3):
  Change HOME, PATH, and .gitconfig paths to be customizable
  Fix C syntactic errors for the Plan 9 C compiler
  Support Plan 9 dialect

 GIT-VERSION-GEN               |  2 +-
 Makefile                      | 81 +++++++++++++++++++++++-----
 builtin/config.c              |  2 +-
 compat/plan9/openssl/crypto.h |  5 ++
 compat/regex/regex_internal.h |  3 ++
 config.c                      |  5 +-
 config.mak.uname              | 99 +++++++++++++++++++++++++++++++++++
 credential-cache.c            |  2 +-
 credential-store.c            |  2 +-
 exec-cmd.c                    |  4 +-
 exec-wrapper.c                | 16 ++++++
 generate-cmdlist.sh           | 24 ++++++---
 git-compat-util.h             | 17 +++++-
 help.c                        |  2 +-
 parse-options.h               | 18 +++----
 path.c                        |  6 +--
 remove-bitfields.sh           | 17 ++++++
 run-command.c                 |  4 +-
 sequencer.c                   |  2 +-
 shell.c                       |  2 +-
 t/chainlint.sed               | 66 +++++++++++------------
 templates/Makefile            | 12 ++++-
 22 files changed, 311 insertions(+), 80 deletions(-)
 create mode 100644 compat/plan9/openssl/crypto.h
 create mode 100644 exec-wrapper.c
 create mode 100755 remove-bitfields.sh


base-commit: 745f6812895b31c02b29bdfe4ae8e5498f776c26
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-305%2Flufia%2Fplan9-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-305/lufia/plan9-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/305

Range-diff vs v1:

 1:  fa539c75b2 ! 1:  63e7e7794e Change HOME, PATH, and .gitconfig paths to be customizable
     @@ -10,12 +10,26 @@
       --- a/Makefile
       +++ b/Makefile
      @@
     + localedir = $(sharedir)/locale
     + template_dir = share/git-core/templates
       htmldir = $(prefix)/share/doc/git-doc
     - ETC_GITCONFIG = $(sysconfdir)/gitconfig
     - ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
     -+USER_GITCONFIG = ~/.gitconfig
     -+USER_GITCREDENTIALS = ~/.git-credentials
     -+USER_GITCREDENTIAL_CACHE = ~/.git-credential-cache
     +-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 = :
 2:  301a796de9 ! 2:  7abbd36e1d Fix C syntactic errors for the Plan 9 C compiler
     @@ -114,22 +114,25 @@
        * It's okay for the caller to consume argv/argc in the usual way.
        * Other fields of that structure are private to parse-options and should not
      
     - diff --git a/remove-bitfields.rc b/remove-bitfields.rc
     - new file mode 100644
     + diff --git a/remove-bitfields.sh b/remove-bitfields.sh
     + new file mode 100755
       --- /dev/null
     - +++ b/remove-bitfields.rc
     + +++ b/remove-bitfields.sh
      @@
     -+#!/bin/rc
     ++#!/bin/ape/sh
      +# Plan 9 C compiler rejects initialization a structure including bit field.
     -+# usage: remove-bitfields.rc [dir ...]
     ++# usage: remove-bitfields.sh [dir ...]
     ++
     ++if ! echo abc | sed 's/(ab)c/\1/' >/dev/null 2>&1
     ++then
     ++	alias sed='sed -E'
     ++fi
      +
     -+fn sigexit sighup sigint sigquit sigterm {
     -+	rm -f /tmp/remove-bitfields.$pid
     -+	exit
     -+}
     ++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){
     ++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
 3:  df67a7e1d3 < -:  ---------- GIT-VERSION-GEN: Use sed instead of expr
 4:  d25bcb43e1 < -:  ---------- Port generate-cmdline.sh to rc
 5:  d00bbdce0d < -:  ---------- Add plan9/wrap.c
 6:  0494971306 < -:  ---------- Add mkfile to build git and subcommands for Plan 9
 -:  ---------- > 3:  7505e85fc5 Support Plan 9 dialect