File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
git-branchless-lib/src/git Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -938,6 +938,9 @@ impl Repo {
938938 return Err ( Error :: UnsupportedRevParseSpec ( spec. to_owned ( ) ) ) ;
939939 }
940940
941+ // `libgit2` doesn't understand that `-` is short for `@{-1}`
942+ let spec = if spec == "-" { "@{-1}" } else { spec } ;
943+
941944 match self . inner . revparse_single ( spec) {
942945 Ok ( object) => match object. into_commit ( ) {
943946 Ok ( commit) => Ok ( Some ( Commit { inner : commit } ) ) ,
Original file line number Diff line number Diff line change @@ -909,6 +909,32 @@ fn test_navigation_switch_revset() -> eyre::Result<()> {
909909 "### ) ;
910910 }
911911
912+ {
913+ // switching back to "last checkout"
914+ let ( stdout, _stderr) = git. branchless ( "switch" , & [ "@{-1}" ] ) ?;
915+ insta:: assert_snapshot!( stdout, @r###"
916+ branchless: running command: <git-executable> checkout @{-1}
917+ O f777ecc (master) create initial.txt
918+ |\
919+ | o 62fc20d create test1.txt
920+ |
921+ @ fe65c1f create test2.txt
922+ "### ) ;
923+ }
924+
925+ {
926+ // switching back to "last checkout"
927+ let ( stdout, _stderr) = git. branchless ( "switch" , & [ "-" ] ) ?;
928+ insta:: assert_snapshot!( stdout, @r###"
929+ branchless: running command: <git-executable> checkout -
930+ @ f777ecc (master) create initial.txt
931+ |\
932+ | o 62fc20d create test1.txt
933+ |
934+ o fe65c1f create test2.txt
935+ "### ) ;
936+ }
937+
912938 Ok ( ( ) )
913939}
914940
You can’t perform that action at this time.
0 commit comments