summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2014-01-13 18:08:39 -0400
committerJoey Hess <joey@kitenet.net>2014-01-13 18:08:39 -0400
commitdd1d8e69d4c190c7bb60d5187f7a889c6fea0d62 (patch)
treee280c737e1f97f3af56a7de8c290860fd89e3a6d
parent403d565f5cc85a71369bcd2e1cac9da4f20ba7f2 (diff)
downloadgit-repair-dd1d8e69d4c190c7bb60d5187f7a889c6fea0d62.tar.gz
Support old git versions from before git fsck --no-dangling was implemented.
-rw-r--r--Git/Fsck.hs20
-rw-r--r--debian/changelog7
2 files changed, 22 insertions, 5 deletions
diff --git a/Git/Fsck.hs b/Git/Fsck.hs
index 5389d46..a49978d 100644
--- a/Git/Fsck.hs
+++ b/Git/Fsck.hs
@@ -20,6 +20,7 @@ import Git
import Git.Command
import Git.Sha
import Utility.Batch
+import qualified Git.BuildVersion
import qualified Data.Set as S
@@ -75,11 +76,20 @@ isMissing s r = either (const True) (const False) <$> tryIO dump
] r
findShas :: String -> [Sha]
-findShas = catMaybes . map extractSha . concat . map words . lines
+findShas = catMaybes . map extractSha . concat . map words . filter wanted . lines
+ where
+ wanted l
+ | supportsNoDangling = True
+ | otherwise = not ("dangling " `isPrefixOf` l)
fsckParams :: Repo -> [CommandParam]
-fsckParams = gitCommandLine $
- [ Param "fsck"
- , Param "--no-dangling"
- , Param "--no-reflogs"
+fsckParams = gitCommandLine $ map Param $ catMaybes
+ [ Just "fsck"
+ , if supportsNoDangling
+ then Just "--no-dangling"
+ else Nothing
+ , Just "--no-reflogs"
]
+
+supportsNoDangling :: Bool
+supportsNoDangling = not $ Git.BuildVersion.older "1.7.10"
diff --git a/debian/changelog b/debian/changelog
index 7914ff4..a34dc98 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+git-repair (1.20131214) UNRELEASED; urgency=medium
+
+ * Support old git versions from before git fsck --no-dangling was
+ implemented.
+
+ -- Joey Hess <joeyh@debian.org> Mon, 13 Jan 2014 18:07:13 -0400
+
git-repair (1.20131213) unstable; urgency=low
* Improve repair of index files in some situations.