plan9fox/sys/src/cmd/git/merge
Ori Bernstein d9564c0642 git: separate author and committer
Git has the ability to track the person who
creates a commit separately from the person
who wrote the commit. For git9, we ignored
this feature.

However, as we start using git/import more,
it will be useful to figure out who imported
a commit, as well as who wrote it.

This change adds support for seeing this
information in git, as well as setting the
author and committer separately in git/import.
2021-09-03 02:47:18 +00:00

47 lines
942 B
Bash
Executable file

#!/bin/rc -e
rfork ne
. /sys/lib/git/common.rc
fn merge{
ourbr=$gitfs/object/$1/tree
basebr=$gitfs/object/$2/tree
theirbr=$gitfs/object/$3/tree
all=`$nl{{git/query -c $1 $2; git/query -c $2 $3} | sed 's/^..//' | sort | uniq}
for(f in $all){
ours=$ourbr/$f
base=$basebr/$f
theirs=$theirbr/$f
merge1 ./$f $ours $base $theirs
}
}
gitup
flagfmt=''; args='theirs'
eval `''{aux/getflags $*} || exec aux/usage
if(! ~ $#* 1)
exec aux/usage
theirs=`{git/query $1}
ours=`{git/query HEAD}
base=`{git/query $theirs ^ ' ' ^ $ours ^ '@'}
if(~ $base $theirs)
die 'nothing to merge, doofus'
if(! git/walk -q)
die 'dirty work tree, refusing to merge'
if(~ $base $ours){
>[1=2] echo 'fast forwarding...'
echo $theirs > .git/refs/`{git/branch}
git/revert .
exit ''
}
echo $ours >> .git/index9/merge-parents
echo $theirs >> .git/index9/merge-parents
merge $ours $base $theirs
>[1=2] echo 'merge complete: remember to commit'
exit ''