[[!comment format=mdwn
 username="asakurareiko@f3d908c71c009580228b264f63f21c7274df7476"
 nickname="asakurareiko"
 avatar="http://cdn.libravatar.org/avatar/a865743e357add9d15081840179ce082"
 subject="comment 4"
 date="2021-10-22T15:58:11Z"
 content="""
I understand `annex.thinmode=forcehardlink` presents a greater risk. Personally that's something I can manage. In case anyone else is interested in doing the same, this patch will make `git annex fix` always create hardlinks with `annex.thin=true`.

```
diff --git a/Annex/Content/LowLevel.hs b/Annex/Content/LowLevel.hs
index c686e462e..b7cf95d24 100644
--- a/Annex/Content/LowLevel.hs
+++ b/Annex/Content/LowLevel.hs
@@ -57,10 +57,8 @@ linkOrCopy' canhardlink key src dest destmode = catchDefaultIO Nothing $
   where
 	hardlink = do
 		s <- getstat
-		if linkCount s > 1
-			then copy s
-			else liftIO (R.createLink src dest >> preserveGitMode dest destmode >> return (Just Linked))
-				`catchIO` const (copy s)
+		liftIO (R.createLink src dest >> preserveGitMode dest destmode >> return (Just Linked))
+			`catchIO` const (copy s)
 	copy s = ifM (checkedCopyFile' key src dest destmode s)
 		( return (Just Copied)
 		, return Nothing
diff --git a/Command/Fix.hs b/Command/Fix.hs
index 6a84652ce..40a93b357 100644
--- a/Command/Fix.hs
+++ b/Command/Fix.hs
@@ -62,10 +62,10 @@ start fixwhat si file key = do
 			thin <- annexThin <$> Annex.getGitConfig
 			fs <- liftIO $ catchMaybeIO $ R.getFileStatus file
 			os <- liftIO $ catchMaybeIO $ R.getFileStatus obj
-			case (linkCount <$> fs, linkCount <$> os, thin) of
-				(Just 1, Just 1, True) ->
+			case (fileID <$> fs, fileID <$> os, thin) of
+				(Just n, Just n', True) | n /= n' ->
 					fixby $ makeHardLink file key
-				(Just n, Just n', False) | n > 1 && n == n' ->
+				(Just n, Just n', False) | n == n' ->
 					fixby $ breakHardLink file key obj
 				_ -> stop
 
```
"""]]
