ref: 42a4ed8c60af89cd2415e26e3610ce7d12b751d3
parent: 3f850076fca20fe4f5bd98bf6e4f2227d928d9cc
author: Ori Bernstein <[email protected]>
date: Tue Sep 24 14:15:19 EDT 2019
Check if merges are necessary before pulling.
--- a/pull
+++ b/pull
@@ -16,9 +16,18 @@
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/{