@@ -886,6 +886,41 @@ func (s *WorktreeSuite) TestCheckoutTag(c *C) {
886
886
c .Assert (head .Name ().String (), Equals , "HEAD" )
887
887
}
888
888
889
+ func (s * WorktreeSuite ) TestCheckoutTagHash (c * C ) {
890
+ f := fixtures .ByTag ("tags" ).One ()
891
+ r := s .NewRepositoryWithEmptyWorktree (f )
892
+ w , err := r .Worktree ()
893
+ c .Assert (err , IsNil )
894
+
895
+ for _ , hash := range []string {
896
+ "b742a2a9fa0afcfa9a6fad080980fbc26b007c69" , // annotated tag
897
+ "ad7897c0fb8e7d9a9ba41fa66072cf06095a6cfc" , // commit tag
898
+ "f7b877701fbf855b44c0a9e86f3fdce2c298b07f" , // lightweight tag
899
+ } {
900
+ err = w .Checkout (& CheckoutOptions {
901
+ Hash : plumbing .NewHash (hash ),
902
+ })
903
+ c .Assert (err , IsNil )
904
+ head , err := w .r .Head ()
905
+ c .Assert (err , IsNil )
906
+ c .Assert (head .Name ().String (), Equals , "HEAD" )
907
+
908
+ status , err := w .Status ()
909
+ c .Assert (err , IsNil )
910
+ c .Assert (status .IsClean (), Equals , true )
911
+ }
912
+
913
+ for _ , hash := range []string {
914
+ "fe6cb94756faa81e5ed9240f9191b833db5f40ae" , // blob tag
915
+ "152175bf7e5580299fa1f0ba41ef6474cc043b70" , // tree tag
916
+ } {
917
+ err = w .Checkout (& CheckoutOptions {
918
+ Hash : plumbing .NewHash (hash ),
919
+ })
920
+ c .Assert (err , NotNil )
921
+ }
922
+ }
923
+
889
924
func (s * WorktreeSuite ) TestCheckoutBisect (c * C ) {
890
925
if testing .Short () {
891
926
c .Skip ("skipping test in short mode." )
0 commit comments