From 2bf3addf4997023584e32812a9d8cbc46833d672 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Sun, 27 Nov 2011 13:50:05 -0400
Subject: [PATCH] Bugfix: dropunused did not drop keys with two spaces in their
 name.

---
 Command/DropUnused.hs                                         | 4 ++--
 debian/changelog                                              | 1 +
 ...punused_doesn__39__t_handle_double_spaces_in_filename.mdwn | 4 ++++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs
index 2c3bb296ad..3df9ab6c2b 100644
--- a/Command/DropUnused.hs
+++ b/Command/DropUnused.hs
@@ -73,6 +73,6 @@ readUnusedLog prefix = do
 		then M.fromList . map parse . lines <$> liftIO (readFile f)
 		else return M.empty
 	where
-		parse line = (head ws, fromJust $ readKey $ unwords $ tail ws)
+		parse line = (num, fromJust $ readKey $ tail rest)
 			where
-				ws = words line
+				(num, rest) = break (== ' ') line
diff --git a/debian/changelog b/debian/changelog
index 35f3a7c8d7..943d1e01cd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,7 @@ git-annex (3.20111123) UNRELEASED; urgency=low
   * Flush json output, avoiding a buffering problem that could result in
     doubled output.
   * Avoid needing haskell98 and other fixes for new ghc. Thanks, Mark Wright.
+  * Bugfix: dropunused did not drop keys with two spaces in their name.
 
  -- Joey Hess <joeyh@debian.org>  Tue, 22 Nov 2011 17:53:42 -0400
 
diff --git a/doc/bugs/dropunused_doesn__39__t_handle_double_spaces_in_filename.mdwn b/doc/bugs/dropunused_doesn__39__t_handle_double_spaces_in_filename.mdwn
index 930e23ea9d..a6b44cd2a3 100644
--- a/doc/bugs/dropunused_doesn__39__t_handle_double_spaces_in_filename.mdwn
+++ b/doc/bugs/dropunused_doesn__39__t_handle_double_spaces_in_filename.mdwn
@@ -81,3 +81,7 @@ Output:
     ok
 
 Strange that `dropunused` still said "ok" when it didn't succeed at removing the file.
+
+> It was misparsing the unused file, so it thought you'd asked it to drop a
+> key that didn't exist (which means already dropped) so no error. I've
+> fixed the bug. [[done]] --[[Joey]]