From 0f25d4863990edeb53b154b4ea596aac228c94e9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 16 Aug 2018 16:00:03 -0400 Subject: [PATCH] pass absolute path to update-index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test suite found a case where this is necessary. And the man page says this, although current behavior is not as documented.. Note that files beginning with . are discarded. This includes ./file and dir/./file. If you don’t want this, then use cleaner names. This may hit path length limits on Windows. shrug This commit was supported by the NSF-funded DataLad project. --- Annex/Link.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Annex/Link.hs b/Annex/Link.hs index 1d1f4e7d32..4b01d5a9d6 100644 --- a/Annex/Link.hs +++ b/Annex/Link.hs @@ -167,16 +167,20 @@ restagePointerFile (Restage False) f _ = toplevelWarning True $ unwords , "To fix the git status display, you can run:" , "git update-index -q --refresh " ++ f ] -restagePointerFile (Restage True) f orig = withTSDelta $ \tsd -> +restagePointerFile (Restage True) f orig = withTSDelta $ \tsd -> do + -- update-index is documented as picky about "./file" and it + -- fails on "../../repo/path/file" when cwd is not in the repo + -- being acted on. Avoid these problems with an absolute path. + absf <- liftIO $ absPath f Annex.Queue.addCommandCond "update-index" [Param "-q", Param "--refresh"] - [(f, check tsd)] + [(absf, check tsd)] where -- If the file gets modified before update-index runs, -- it would stage the modified file, which would be surprising -- behavior. So check for modifications and avoid running -- update-index on the file. This does not close the race, but it -- makes the window as narrow as possible. - check tsd = genInodeCache f tsd >>= return . \case + check f tsd = genInodeCache f tsd >>= return . \case Nothing -> False Just new -> compareStrong orig new