diff options
author | Joey Hess <joey@kitenet.net> | 2014-02-18 20:57:14 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-02-18 20:57:14 -0400 |
commit | 935f5ed55b1ed9a218955fdd34cb40db3b1c9425 (patch) | |
tree | 0409ba3b6decae4764b39b0b4b827d093f081039 /Command/View.hs | |
parent | 59d66243ab57890cbbe7fdc0a7c7c78c24702b95 (diff) |
fix view changing when in subdir
Failed reading some files with relative paths. This is a quick and dirty
fix.
Diffstat (limited to 'Command/View.hs')
-rw-r--r-- | Command/View.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Command/View.hs b/Command/View.hs index 4e642e50f..9e1b981a7 100644 --- a/Command/View.hs +++ b/Command/View.hs @@ -40,8 +40,7 @@ start params = do perform :: View -> CommandPerform perform view = do showSideAction "searching" - branch <- applyView view - next $ checkoutViewBranch view branch + next $ checkoutViewBranch view applyView paramView :: String paramView = paramPair (paramRepeating "FIELD=VALUE") (paramRepeating "TAG") @@ -63,20 +62,25 @@ mkView params = do viewbranch = fromMaybe (error "not on any branch!") <$> inRepo Git.Branch.current -checkoutViewBranch :: View -> Git.Branch -> CommandCleanup -checkoutViewBranch view branch = do +checkoutViewBranch :: View -> (View -> Annex Git.Branch) -> CommandCleanup +checkoutViewBranch view mkbranch = do + oldcwd <- liftIO getCurrentDirectory + + {- Change to top of repository before creating view branch. -} + liftIO . setCurrentDirectory =<< fromRepo Git.repoPath + branch <- mkbranch view + ok <- inRepo $ Git.Command.runBool [ Param "checkout" , Param (show $ Git.Ref.base branch) ] when ok $ do setView view - top <- fromRepo Git.repoPath - cwd <- liftIO getCurrentDirectory {- A git repo can easily have empty directories in it, - and this pollutes the view, so remove them. -} - liftIO $ removeemptydirs top - unlessM (liftIO $ doesDirectoryExist cwd) $ + liftIO $ removeemptydirs "." + unlessM (liftIO $ doesDirectoryExist oldcwd) $ do + top <- fromRepo Git.repoPath showLongNote (cwdmissing top) return ok where |