summaryrefslogtreecommitdiff
path: root/sys/lib/git
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2022-05-15 16:29:48 +0000
committerOri Bernstein <ori@eigenstate.org>2022-05-15 16:29:48 +0000
commit5dd9b370a07b49a072025f5cd401361e8988c9e7 (patch)
tree050dbe96c19421d1603fbb2554eaa8cab2163f30 /sys/lib/git
parent1470d22cdbebc9c0c18a590891f2d43d1646f4bd (diff)
git/merge: correctly preserve permissions when merging
when doing a 3 way merge of a file, we also need to do a merge of the permission bits to avoid clobberign them.
Diffstat (limited to 'sys/lib/git')
-rw-r--r--sys/lib/git/common.rc18
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/lib/git/common.rc b/sys/lib/git/common.rc
index 320439ab0..43ea17895 100644
--- a/sys/lib/git/common.rc
+++ b/sys/lib/git/common.rc
@@ -29,13 +29,23 @@ fn drop {
' $*
}
-fn present {
+fn mergeperm {
if(~ $1 /dev/null && cmp $2 $3>/dev/null)
status=gone
if not if (~ $3 /dev/null && cmp $1 $2>/dev/null)
status=gone
- if not
+ if not {
+ mergedperms='-x'
+ if(test -x $2){
+ if(test -x $1 -a -x $3)
+ mergedperms='+x'
+ }
+ if not{
+ if(test -x $1 -o -x $3)
+ mergedperms='+x'
+ }
status=()
+ }
}
fn whoami{
@@ -73,13 +83,13 @@ fn merge1 {@{
base=/dev/null
if(! test -f $theirs)
theirs=/dev/null
- mkdir -p `{basename -d $tmp}
if(! ape/diff3 -3 -m $ours $base $theirs > $tmp)
echo merge needed: $out >[1=2]
- if(present $ours $base $theirs){
+ if(mergeperm $ours $base $theirs){
mv $tmp $out
git/add $out
+ chmod $mergedperms $out
}
if not {
rm -f $tmp $out