ref: f10ded757ffea343cf07e27cb0c504653444659f
parent: ad896193eace2d45c93cf7b82fef8e250b6ed647
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Oct 12 11:36:35 EDT 2019
Bring back clobbered change.
--- a/pull
+++ b/pull
@@ -11,14 +11,29 @@
upstream=$3
url=$4
dir=$5
-
- {git/fetch -b $branch -u $upstream $url >[2=3] | awk -v 'update='^$update '+
+ fetch=`{git/fetch -b $branch -u $upstream $url} |[2] tr '\x0d' '\x0a'+ st=$status
+ if(! ~ $st ''){+ echo fetch failed: $st
+ exit $st
+ }
+ echo $fetch | awk -v 'update='^$update '
function writeref(ref, hash)
{outfile = ".git/"ref
- system("mkdir -p `{basename -d "outfile"}")- print hash > outfile
- close(outfile)
+ # we have local commits: nothing to do
+ if(system("~ `{git/query ''HEAD "hash" @''} `{git/query "hash"}") == 0)+ exit("");+ # we have local commits *and* remote commits: request a merge
+ if(system("~ `{git/query ''HEAD "hash" @''} `{git/query HEAD}") != 0){+ printf("git/merge %s\n", hash) > "/fd/2";+ exit("merge");+ }
+ # we only have remote commits: update head
+ system("mkdir -p `{basename -d "outfile"}");+ print hash > outfile;
+ close(outfile);
}
/^remote/{@@ -30,7 +45,7 @@
gsub("^refs/heads", "refs/remotes/'$upstream'", $2)writeref($2, $3)
}
- '} |[3] tr '\x0d' '\x0a'
+ '
}
fn usage{@@ -75,8 +90,7 @@
exit 'not in git repository'
dir=/mnt/git/branch/$branch/tree
-if(! git/walk -q){- echo $status
+if(! ~ git/walk -q){echo 'repository is dirty; commit before pulling' >[1=2]
exit 'dirty'
}
--
⑨