work around git segfault
authorJoey Hess <joeyh@joeyh.name>
Thu, 4 Aug 2022 18:20:57 +0000 (14:20 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 4 Aug 2022 18:20:57 +0000 (14:20 -0400)
Work around bug in git 2.37 that causes a segfault when when
core.untrackedCache is set, and broke git-annex init.

Depending on when git gets fixed and how widely the buggy versions are
used, this could be reverted quite soon, or need to linger for a long time.
It only makes git-annex init a tiny bit slower in a new repo.

Sponsored-by: Max Thoursie on Patreon
Annex/Branch.hs
CHANGELOG
doc/bugs/Incompatibility_with_git_2.37/comment_6_3bb6424838d4f8a971f3dce6d1b8dbfb._comment [new file with mode: 0644]

index 61e6012c2e1c2064af188afefa2ec1ec0a72ba38..b227adb32c810b7cae94f5fc47bc97693336aac3 100644 (file)
@@ -133,6 +133,11 @@ getBranch = maybe (hasOrigin >>= go >>= use) return =<< branchsha
                fromMaybe (error $ "failed to create " ++ fromRef name)
                        <$> branchsha
        go False = withIndex' True $ do
+               -- Create the index file. This is not necessary,
+               -- except to avoid a bug in git that causes
+               -- git write-tree to segfault when the index file does not
+               -- exist.
+               inRepo $ flip Git.UpdateIndex.streamUpdateIndex []
                cmode <- annexCommitMode <$> Annex.getGitConfig
                cmessage <- createMessage
                inRepo $ Git.Branch.commitAlways cmode cmessage fullname []
index b62c1d81b528383912500bdc9dd1f55b56194df6..05989b18042930eb8ebb1ead2ac7a7097186d14a 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,8 @@ git-annex (10.20220725) UNRELEASED; urgency=medium
   * Allow find --branch to be used in a bare repository, the same as
     the deprecated findref can be.
   * add --dry-run: New option. 
+  * Work around bug in git 2.37 that causes a segfault
+    when when core.untrackedCache is set, and broke git-annex init.
 
  -- Joey Hess <id@joeyh.name>  Mon, 25 Jul 2022 15:35:45 -0400
 
diff --git a/doc/bugs/Incompatibility_with_git_2.37/comment_6_3bb6424838d4f8a971f3dce6d1b8dbfb._comment b/doc/bugs/Incompatibility_with_git_2.37/comment_6_3bb6424838d4f8a971f3dce6d1b8dbfb._comment
new file mode 100644 (file)
index 0000000..787d17a
--- /dev/null
@@ -0,0 +1,16 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 6"""
+ date="2022-08-04T17:46:32Z"
+ content="""
+Now 2 weeks since the segfault in git has been known, and they have not
+fixed it.
+
+Now feeling that it's might be worth git-annex init avoiding the
+segfault, by making sure to do something that creates the index file before
+write-tree. So I don't have to worry about when this gets fixed in git,
+or the chances that a buggy release will start being widely used for a long
+time.
+
+Yeah, done so.
+"""]]