From 2b7f3ee3f2e33c338926950950da8ca8a0c74355 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 26 Mar 2015 14:02:35 -0400 Subject: [PATCH] assistant: Committing a whole lot of files at once could overflow command-line length limits and cause the commit to fail. This only happened when using the assistant in an indirect mode repository. --- Assistant/Threads/Committer.hs | 8 ++++++-- debian/changelog | 3 +++ ...itter_crash_on_OSX_when_adding_lots_of_files.mdwn | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs index 8fecc1c510..2951a80182 100644 --- a/Assistant/Threads/Committer.hs +++ b/Assistant/Threads/Committer.hs @@ -290,8 +290,12 @@ handleAdds havelsof delayadd cs = returnWhen (null incomplete) $ do -- files. The ls-files is run on a batch of files. findnew [] = return ([], noop) findnew pending@(exemplar:_) = do - (newfiles, cleanup) <- liftAnnex $ - inRepo (Git.LsFiles.notInRepo False $ map changeFile pending) + let segments = segmentXargs $ map changeFile pending + rs <- liftAnnex $ forM segments $ \fs -> + inRepo (Git.LsFiles.notInRepo False fs) + let (newfiles, cleanup) = foldl' + (\(l1, a1) (l2, a2) -> (l1 ++ l2, a1 >> a2)) + ([], return True) rs -- note: timestamp info is lost here let ts = changeTime exemplar return (map (PendingAddChange ts) newfiles, void $ liftIO cleanup) diff --git a/debian/changelog b/debian/changelog index 79810d546f..c41a3c0b51 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,9 @@ git-annex (5.20150318) UNRELEASED; urgency=medium command that ignored it.) * Improve error message when --in @date is used and there is no reflog for the git-annex branch. + * assistant: Committing a whole lot of files at once could overflow + command-line length limits and cause the commit to fail. This + only happened when using the assistant in an indirect mode repository. -- Joey Hess Thu, 19 Mar 2015 17:05:32 -0400 diff --git a/doc/bugs/assistant_committer_crash_on_OSX_when_adding_lots_of_files.mdwn b/doc/bugs/assistant_committer_crash_on_OSX_when_adding_lots_of_files.mdwn index fd5242fdfd..9fa44710c3 100644 --- a/doc/bugs/assistant_committer_crash_on_OSX_when_adding_lots_of_files.mdwn +++ b/doc/bugs/assistant_committer_crash_on_OSX_when_adding_lots_of_files.mdwn @@ -8,3 +8,15 @@ long) Probably need to tune the command length limit for !linux. --[[Joey]] + +> Investigation suggests this is the problem: + + inRepo (Git.LsFiles.notInRepo False $ map changeFile pending) + +> If a lot of new files have been added, the `pending` list can be +> arbitrarily large, and this passes it to git ls-files as parameters.a +> +> It's not the actual commit that fails; that uses Git.Queue and xargs. +> --[[Joey]] + +>> [[fixed|done]] --[[Joey]]