aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-18 21:57:21 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-18 21:57:21 -0400
commita84f738053b0e5c05919296a59856b24f262d75c (patch)
tree75f7505c7d38343ef15f0c10822778148c572c8c
parentb20cb8393f503ea6b12d6155f80c5be12157af49 (diff)
vpop N
-rw-r--r--Command/VPop.hs19
-rw-r--r--Command/View.hs1
-rw-r--r--doc/git-annex.mdwn4
3 files changed, 16 insertions, 8 deletions
diff --git a/Command/VPop.hs b/Command/VPop.hs
index e62c2414a..fe6d35a32 100644
--- a/Command/VPop.hs
+++ b/Command/VPop.hs
@@ -17,27 +17,32 @@ import Command.View (checkoutViewBranch)
def :: [Command]
def = [notBareRepo $ notDirect $
- command "vpop" paramNothing seek SectionUtility
+ command "vpop" (paramOptional paramNumber) seek SectionUtility
"switch back to previous view"]
seek :: CommandSeek
-seek = withNothing start
+seek = withWords start
-start ::CommandStart
-start = go =<< currentView
+start :: [String] -> CommandStart
+start ps = go =<< currentView
where
go Nothing = error "Not in a view."
go (Just v) = do
- showStart "vpop" ""
+ showStart "vpop" (show num)
removeView v
- vs <- filter (sameparentbranch v) <$> recentViews
+ vs <- drop (num - 1) . filter (sameparentbranch v)
+ <$> recentViews
case vs of
(oldv:_) -> next $ next $ do
+ showOutput
checkoutViewBranch oldv (return . branchView)
- _ -> next $ next $
+ _ -> next $ next $ do
+ showOutput
inRepo $ Git.Command.runBool
[ Param "checkout"
, Param $ show $ Git.Ref.base $
viewParentBranch v
]
sameparentbranch a b = viewParentBranch a == viewParentBranch b
+
+ num = fromMaybe 1 $ readish =<< headMaybe ps
diff --git a/Command/View.hs b/Command/View.hs
index 9e1b981a7..5c1742855 100644
--- a/Command/View.hs
+++ b/Command/View.hs
@@ -70,6 +70,7 @@ checkoutViewBranch view mkbranch = do
liftIO . setCurrentDirectory =<< fromRepo Git.repoPath
branch <- mkbranch view
+ showOutput
ok <- inRepo $ Git.Command.runBool
[ Param "checkout"
, Param (show $ Git.Ref.base branch)
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 3b9a227be..a5f73ac8e 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -326,11 +326,13 @@ subdirectories).
When multiple field values match, the view branch will have a
subdirectory for each value.
-* `vpop`
+* `vpop [N]`
Switches from the currently active view back to the previous view.
Or, from the first view back to original branch.
+ The optional number tells how many views to pop.
+
* `vadd [field=value ...] [tag ...]`
Refines the currently checked out view branch, adding additional fields