Added a comment
authorasakurareiko@f3d908c71c009580228b264f63f21c7274df7476 <asakurareiko@web>
Fri, 22 Oct 2021 15:58:11 +0000 (15:58 +0000)
committeradmin <admin@branchable.com>
Fri, 22 Oct 2021 15:58:11 +0000 (15:58 +0000)
doc/todo/More_space_savings_for_annex.thin/comment_4_a87baf5ad6b7688bb40a6c463cb1b8db._comment [new file with mode: 0644]

diff --git a/doc/todo/More_space_savings_for_annex.thin/comment_4_a87baf5ad6b7688bb40a6c463cb1b8db._comment b/doc/todo/More_space_savings_for_annex.thin/comment_4_a87baf5ad6b7688bb40a6c463cb1b8db._comment
new file mode 100644 (file)
index 0000000..bf7dab7
--- /dev/null
@@ -0,0 +1,47 @@
+[[!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
+```
+"""]]