summaryrefslogtreecommitdiff
path: root/src/Command/Checkout.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Command/Checkout.hs')
-rw-r--r--src/Command/Checkout.hs10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/Command/Checkout.hs b/src/Command/Checkout.hs
index 3667e76..7cba593 100644
--- a/src/Command/Checkout.hs
+++ b/src/Command/Checkout.hs
@@ -52,11 +52,7 @@ instance Command CheckoutCommand where
cmdCheckout :: CheckoutCommand -> CommandExec ()
cmdCheckout (CheckoutCommand CheckoutOptions {..} name mbrev) = do
repo <- maybe getDefaultRepo getRepo name
- root <- getCommitTree =<< case mbrev of
- Just revision -> readCommit repo revision
- Nothing -> createWipCommit repo
- tree <- case coSubtree of
- Nothing -> return root
- Just subtree -> maybe (fail $ "subtree `" <> subtree <> "' not found in " <> maybe "current worktree" (("revision `" <>) . (<> "'") . T.unpack) mbrev) return =<<
- getSubtree subtree root
+ mbCommit <- sequence $ fmap (readCommit repo) mbrev
+ root <- getCommitTree =<< maybe (createWipCommit repo) return mbCommit
+ tree <- maybe return (getSubtree mbCommit) coSubtree $ root
checkoutAt tree $ maybe "." id coDestination