From 799687bcb9c7d6bc66b0dfd8b84fdb0942a30c13 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 4 Jul 2020 22:58:25 -0700 Subject: [PATCH] Provide a simple implementation of "nogit sync" There's one piece of this that requires a cooperating repository. Specifically, nogit really wants a merge with no input required from the user. The "union" merge driver does what we want here, (putting lines from both sides into the files without conflict markers). The only trick is that there's no way (that I've found at least) to request this merge driver from the command line of the "git merge" invocation. Instead, we need a .gitattributes file to specify "merge=union". So, for now, we're relying on the repository being used with nogit to provide a working .gitattributes file that specifies "merge=union" for all appropriate paths. --- nogit | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nogit b/nogit index b9a248e..212ca33 100755 --- a/nogit +++ b/nogit @@ -103,7 +103,17 @@ nogit_clone() nogit_sync() { - echo "Internal error: 'nogit sync' not yet implemented" + # First commit any locally modified nogit files + GIT_DIR=$NOGIT_DIR git commit -a -m "nogit-sync commit" >/dev/null 2>&1 || true + + # Then, fetch and merge any upstream changes + GIT_DIR=$NOGIT_DIR git fetch >/dev/null 2>&1 + GIT_DIR=$NOGIT_DIR git merge -m "nogit-sync merge" >/dev/null 2>&1 + + # Finally, push any new commits up to the upstream repository + GIT_DIR=$NOGIT_DIR git push >/dev/null 2>&1 + + echo "Completed nogit sync" } if [ $# -lt 1 ]; then -- 2.43.0