]> git.cworth.org Git - nogit/commitdiff
Provide the merge=union semantics we want through an info/attributes file
authorCarl Worth <cworth@cworth.org>
Sun, 5 Jul 2020 18:41:04 +0000 (11:41 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 5 Jul 2020 18:51:06 +0000 (11:51 -0700)
This is much cleaner than we were doing before, (where we requiring a
nogit repository to provide its own .giattribtues file with the
merge=union configuration).

This is also much cleaner than an approach we had been considering
which was to temporarily move away any .gitattributes file, replacing
it with our own for the time of "nogit sync", and then restoring it.

Here, we take advantage of the define git semantics that:

1. A clone does not bring down .git/info/attributes so we are
   guaranteed to be safe to provide our own content here.

2. The content we provide in .git/info/attributes overrides anything
   set in any .gitattributes files so we can be confident that our
   configuration here will apply in all cases.

nogit

diff --git a/nogit b/nogit
index d55124d27d95ea92dcaa65d2475ab2f5c36f7e77..b0820fc224413e9bfbc0e51562e45309f3cadd5e 100755 (executable)
--- a/nogit
+++ b/nogit
@@ -97,6 +97,12 @@ nogit_clone()
         false
     fi
 
+    # Install the info/atttributes file that forces the "union" merge
+    # driver for all files, giving us the semantics of "keep both sides
+    # of all conflicts" that is at the heart of nogit.
+    mkdir -p tmp/.git/info
+    echo '* merge=union' > tmp/.git/info/attributes
+
     # Now that we've passed the sanity check, install the cloned .git
     # object store into $NOGIT_DIR, cleanup our temporary files, and
     # checkout the (known to not be conflicting) files.