Avoid using absolute paths when staging location log, as that can confuse git when a remote's path contains a symlink. Closes: #621386

This was a real PITA to fix, since location logs can be staged in
both the current repo, as well as in local remote's repos, in
which case the cwd will not be in the repo. And git add needs different
params in both cases, when absolute paths are not used.

In passing, git annex fsck now stages location log fixes.
This commit is contained in:
Joey Hess 2011-04-25 14:54:24 -04:00
parent e433c6f0bb
commit 76911a446a
5 changed files with 43 additions and 27 deletions

View file

@ -9,6 +9,7 @@ module Content (
inAnnex,
calcGitLink,
logStatus,
logStatusFor,
getViaTmp,
getViaTmpUnchecked,
checkDiskSpace,
@ -61,7 +62,8 @@ calcGitLink file key = do
return $ relPathDirToFile (parentDir absfile)
(Git.workTree g) </> ".git" </> annexLocation key
{- Updates the LocationLog when a key's presence changes.
{- Updates the LocationLog when a key's presence changes in the current
- repository.
-
- Note that the LocationLog is not updated in bare repositories.
- Operations that change a bare repository should be done from
@ -69,11 +71,19 @@ calcGitLink file key = do
- updated instead. -}
logStatus :: Key -> LogStatus -> Annex ()
logStatus key status = do
g <- Annex.gitRepo
u <- getUUID g
logStatusFor u key status
{- Updates the LocationLog when a key's presence changes in a repository
- identified by UUID. -}
logStatusFor :: UUID -> Key -> LogStatus -> Annex ()
logStatusFor u key status = do
g <- Annex.gitRepo
unless (Git.repoIsLocalBare g) $ do
u <- getUUID g
logfile <- liftIO $ logChange g key u status
AnnexQueue.add "add" [Param "--"] logfile
rellogfile <- liftIO $ Git.workTreeFile g logfile
AnnexQueue.add "add" [Param "--"] rellogfile
{- Runs an action, passing it a temporary filename to download,
- and if the action succeeds, moves the temp file into