add: If interrupted, add can leave files converted to symlinks but not yet added to git. Running the add again will now clean up this situtation.
This commit is contained in:
parent
d2ff311a34
commit
8047bba5b9
3 changed files with 20 additions and 10 deletions
|
@ -13,7 +13,7 @@ module Command (
|
||||||
prepCommand,
|
prepCommand,
|
||||||
doCommand,
|
doCommand,
|
||||||
whenAnnexed,
|
whenAnnexed,
|
||||||
notAnnexed,
|
ifAnnexed,
|
||||||
notBareRepo,
|
notBareRepo,
|
||||||
isBareRepo,
|
isBareRepo,
|
||||||
autoCopies,
|
autoCopies,
|
||||||
|
@ -71,10 +71,10 @@ doCommand = start
|
||||||
{- Modifies an action to only act on files that are already annexed,
|
{- Modifies an action to only act on files that are already annexed,
|
||||||
- and passes the key and backend on to it. -}
|
- and passes the key and backend on to it. -}
|
||||||
whenAnnexed :: (FilePath -> (Key, Backend Annex) -> Annex (Maybe a)) -> FilePath -> Annex (Maybe a)
|
whenAnnexed :: (FilePath -> (Key, Backend Annex) -> Annex (Maybe a)) -> FilePath -> Annex (Maybe a)
|
||||||
whenAnnexed a file = maybe (return Nothing) (a file) =<< Backend.lookupFile file
|
whenAnnexed a file = ifAnnexed file (a file) (return Nothing)
|
||||||
|
|
||||||
notAnnexed :: FilePath -> Annex (Maybe a) -> Annex (Maybe a)
|
ifAnnexed :: FilePath -> ((Key, Backend Annex) -> Annex a) -> (Annex a) -> Annex a
|
||||||
notAnnexed file a = maybe a (const $ return Nothing) =<< Backend.lookupFile file
|
ifAnnexed file yes no = maybe no yes =<< Backend.lookupFile file
|
||||||
|
|
||||||
notBareRepo :: Annex a -> Annex a
|
notBareRepo :: Annex a -> Annex a
|
||||||
notBareRepo a = do
|
notBareRepo a = do
|
||||||
|
|
|
@ -29,13 +29,21 @@ seek = [withFilesNotInGit start, withFilesUnlocked start]
|
||||||
- moving it into the annex directory and setting up the symlink pointing
|
- moving it into the annex directory and setting up the symlink pointing
|
||||||
- to its content. -}
|
- to its content. -}
|
||||||
start :: BackendFile -> CommandStart
|
start :: BackendFile -> CommandStart
|
||||||
start p@(_, file) = notBareRepo $ notAnnexed file $ do
|
start p@(_, file) = notBareRepo $ ifAnnexed file fixup add
|
||||||
s <- liftIO $ getSymbolicLinkStatus file
|
where
|
||||||
if isSymbolicLink s || not (isRegularFile s)
|
add = do
|
||||||
then stop
|
s <- liftIO $ getSymbolicLinkStatus file
|
||||||
else do
|
if isSymbolicLink s || not (isRegularFile s)
|
||||||
|
then stop
|
||||||
|
else do
|
||||||
|
showStart "add" file
|
||||||
|
next $ perform p
|
||||||
|
fixup (key, _) = do
|
||||||
|
-- fixup from an interrupted add; the symlink
|
||||||
|
-- is present but not yet added to git
|
||||||
showStart "add" file
|
showStart "add" file
|
||||||
next $ perform p
|
liftIO $ removeFile file
|
||||||
|
next $ next $ cleanup file key =<< inAnnex key
|
||||||
|
|
||||||
perform :: BackendFile -> CommandPerform
|
perform :: BackendFile -> CommandPerform
|
||||||
perform (backend, file) = Backend.genKey file backend >>= go
|
perform (backend, file) = Backend.genKey file backend >>= go
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -3,6 +3,8 @@ git-annex (3.20111204) UNRELEASED; urgency=low
|
||||||
* map: Fix a failure to detect a loop when both repositories are local
|
* map: Fix a failure to detect a loop when both repositories are local
|
||||||
and refer to each other with relative paths.
|
and refer to each other with relative paths.
|
||||||
* Prevent key names from containing newlines.
|
* Prevent key names from containing newlines.
|
||||||
|
* add: If interrupted, add can leave files converted to symlinks but not
|
||||||
|
yet added to git. Running the add again will now clean up this situtation.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sun, 04 Dec 2011 12:22:37 -0400
|
-- Joey Hess <joeyh@debian.org> Sun, 04 Dec 2011 12:22:37 -0400
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue