File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -81,12 +81,22 @@ impl GitSync {
81
81
} ;
82
82
let num_roots_before = num_roots ( ) ?;
83
83
84
+ let sha = cmd ! ( sh, "git rev-parse HEAD" ) . output ( ) . context ( "FAILED to get current commit" ) ?. stdout ;
85
+
84
86
// Merge the fetched commit.
85
87
const MERGE_COMMIT_MESSAGE : & str = "Merge from rustc" ;
86
88
cmd ! ( sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}" )
87
89
. run ( )
88
90
. context ( "FAILED to merge new commits, something went wrong" ) ?;
89
91
92
+ let current_sha = cmd ! ( sh, "git rev-parse HEAD" ) . output ( ) . context ( "FAILED to get current commit" ) ?. stdout ;
93
+ if current_sha == sha {
94
+ cmd ! ( sh, "git reset --hard HEAD^" )
95
+ . run ( )
96
+ . expect ( "FAILED to clean up after creating the preparation commit" ) ;
97
+ return Err ( anyhow:: anyhow!( "No merge was performed, nothing to pull. Rolled back the preparation commit." ) ) ;
98
+ }
99
+
90
100
// Check that the number of roots did not increase.
91
101
if num_roots ( ) ? != num_roots_before {
92
102
bail ! ( "Josh created a new root commit. This is probably not the history you want." ) ;
You can’t perform that action at this time.
0 commit comments