3 . /sys/lib/git/common.rc
6 name=`{git/conf user.name}
7 email=`{git/conf user.email}
8 if(test -f /adm/keys.who){
10 name=`{awk -F'|' '$1=="'$user'" {x=$3} END{print x}' </adm/keys.who}
12 email=`{awk -F'|' '$1=="'$user'" {x=$5} END{print x}' </adm/keys.who}
17 email=glenda@9front.local
22 if(test -e $gitfs/branch/$branch/tree){
23 refpath=.git/refs/$branch
26 if not if(test -e $gitfs/object/$branch/tree){
30 if not if(! test -e $gitfs/HEAD/tree){
31 refpath=.git/refs/$branch
35 die 'invalid branch:' $branch
38 # Remove commentary lines.
39 # Remove leading and trailing empty lines.
40 # Combine consecutive empty lines between paragraphs.
41 # Remove trailing spaces from lines.
42 # Ensure there's trailing newline.
46 /^[ ]*$/ {empty = 1; next}
48 wet && empty {printf "\n"}
50 {sub(/[ ]+$/, ""); print $0}
55 if(! test -s $msgfile.tmp){
57 echo '# Author:' $name '<'$email'>'
61 git/walk -fAMR $files | subst '^' '# '
63 echo '# Commit message:'
68 giteditor=`{git/conf core.editor}
75 cleanmsg < $msgfile.tmp > $msgfile
76 if(! test -s $msgfile)
77 die 'empty commit message'
82 parents=`{cat $gitfs/HEAD/parent}
83 if not if(test -f .git/index9/merge-parents)
84 parents=`{cat .git/index9/merge-parents | sort | uniq}
85 if not if(~ $initial true)
88 parents=`{git/query $branch}
95 hash=`{git/save -n $"name -e $"email -m $"msg $pflags $files || die $status}
96 rm -f .git/index9/merge-parents
100 mkdir -p `{basename -d $refpath}
101 # Paranoia: let's not mangle the repo.
105 echo $hash > $refpath
107 if(test -e .git/index9/removed/$f || ! test -e $f){
108 rm -f .git/index9/removed/$f
109 rm -f .git/index9/tracked/$f
112 mkdir -p `{basename -d $f}
113 walk -eq $f > .git/index9/tracked/$f
119 rm -f $msgfile $msgfile.tmp
124 flagfmt='m:msg message, r:revise, e:edit'; args='[file ...]'
125 eval `''{aux/getflags $*} || exec aux/usage
127 msgfile=/tmp/git-msg.$pid
129 echo $msg >$msgfile.tmp
130 if not if(~ $#revise 1){
132 echo revising commit `{cat $gitfs/HEAD/hash}
133 cat $gitfs/HEAD/msg >$msgfile.tmp
138 files=`$nl{git/walk -c `$nl{cleanname -d $gitrel $*}}
139 if(~ $status '' || ~ $#files 0 && ! test -f .git/index9/merge-parents && ~ $#revise 0)
140 die 'nothing to commit' $status
149 } || die 'could not commit:' $status