File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -647,10 +647,23 @@ impl Build {
647
647
if !update ( true ) . status ( ) . map_or ( false , |status| status. success ( ) ) {
648
648
self . run ( & mut update ( false ) ) ;
649
649
}
650
- self . run ( Command :: new ( "git" ) . args ( & [ "stash" , "push" ] ) . current_dir ( & absolute_path) ) ;
650
+
651
+ // Save any local changes, but avoid running `git stash pop` if there are none (since it will exit with an error).
652
+ let has_local_modifications = !self . try_run (
653
+ Command :: new ( "git" )
654
+ . args ( & [ "diff-index" , "--quiet" , "HEAD" ] )
655
+ . current_dir ( & absolute_path) ,
656
+ ) ;
657
+ if has_local_modifications {
658
+ self . run ( Command :: new ( "git" ) . args ( & [ "stash" , "push" ] ) . current_dir ( & absolute_path) ) ;
659
+ }
660
+
651
661
self . run ( Command :: new ( "git" ) . args ( & [ "reset" , "-q" , "--hard" ] ) . current_dir ( & absolute_path) ) ;
652
662
self . run ( Command :: new ( "git" ) . args ( & [ "clean" , "-qdfx" ] ) . current_dir ( & absolute_path) ) ;
653
- self . run ( Command :: new ( "git" ) . args ( & [ "stash" , "pop" ] ) . current_dir ( absolute_path) ) ;
663
+
664
+ if has_local_modifications {
665
+ self . run ( Command :: new ( "git" ) . args ( & [ "stash" , "pop" ] ) . current_dir ( absolute_path) ) ;
666
+ }
654
667
}
655
668
656
669
/// If any submodule has been initialized already, sync it unconditionally.
You can’t perform that action at this time.
0 commit comments