remove slightly unsafe use of head
authorJoey Hess <joeyh@joeyh.name>
Thu, 26 Sep 2024 21:21:22 +0000 (17:21 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 26 Sep 2024 21:21:22 +0000 (17:21 -0400)
If git rev-parse somehow didn't output anything, git-annex would crash
here.

Command/Uninit.hs

index 1b2e8395a862152b7b14f25d155287fdeabd9bc1..a38ac9a7e604e95e245a08bc1d53ef3bc089efbd 100644 (file)
@@ -79,7 +79,7 @@ checkCanUninit recordok =
        
        current_branch = 
                ifM (inRepo Git.Ref.headExists)
-                       ( Just . Git.Ref . encodeBS . Prelude.head . lines . decodeBS <$> revhead
+                       ( headMaybe . map (Git.Ref . encodeBS) . lines . decodeBS <$> revhead
                        , return Nothing
                        )
        revhead = inRepo $ Git.Command.pipeReadStrict