@@ -1419,6 +1419,7 @@ func TestRebase_BranchDiverged_NoFF(t *testing.T) {
14191419 }
14201420 return true , nil
14211421 }
1422+ mock .MergeBaseForkPointFn = func (string , string ) (string , error ) { return "b1-remote-sha" , nil }
14221423 mock .UpdateBranchRefFn = func (string , string ) error {
14231424 updateBranchRefCalls ++
14241425 return nil
@@ -2262,6 +2263,7 @@ func TestIntegration_AdoptedBranchRebasesFromCommonAncestor(t *testing.T) {
22622263type serverRebasedRepo struct {
22632264 dir string
22642265 gitDir string
2266+ serverDir string
22652267 oldImported string
22662268 newImported string
22672269 parentSHA string
@@ -2321,6 +2323,7 @@ func setupServerRebasedRepo(t *testing.T) serverRebasedRepo {
23212323 return serverRebasedRepo {
23222324 dir : localDir ,
23232325 gitDir : gitDir ,
2326+ serverDir : serverDir ,
23242327 oldImported : oldImported ,
23252328 newImported : newImported ,
23262329 parentSHA : parentSHA ,
@@ -2341,8 +2344,9 @@ func assertServerRebasedRepoAdopted(t *testing.T, repo serverRebasedRepo) {
23412344 assert .Equal (t , repo .newImported , sf .Stacks [0 ].Branches [1 ].Head )
23422345}
23432346
2344- func TestIntegration_RebaseAdoptsServerRebasedBranches (t * testing.T ) {
2347+ func TestIntegration_RebaseAdoptsServerRebasedBranchesAfterPriorFetch (t * testing.T ) {
23452348 repo := setupServerRebasedRepo (t )
2349+ issue250Git (t , repo .dir , "fetch" , "origin" )
23462350 withIssue250Repo (t , repo .dir )
23472351 cfg := issue250TestConfig (t )
23482352
@@ -2358,3 +2362,21 @@ func TestIntegration_SyncAdoptsServerRebasedBranches(t *testing.T) {
23582362 require .NoError (t , runSync (cfg , & syncOptions {remote : "origin" }))
23592363 assertServerRebasedRepoAdopted (t , repo )
23602364}
2365+
2366+ func TestIntegration_SyncRejectsPrefetchedNonEquivalentRemoteRewrite (t * testing.T ) {
2367+ repo := setupServerRebasedRepo (t )
2368+ issue250Git (t , repo .serverDir , "checkout" , "imported" )
2369+ issue250WriteFile (t , repo .serverDir , "server-only.txt" , "server only\n " )
2370+ issue250Git (t , repo .serverDir , "add" , "." )
2371+ issue250Git (t , repo .serverDir , "commit" , "-m" , "server-only change" )
2372+ issue250Git (t , repo .serverDir , "push" , "origin" , "imported" )
2373+ issue250Git (t , repo .dir , "fetch" , "origin" )
2374+
2375+ withIssue250Repo (t , repo .dir )
2376+ cfg := issue250TestConfig (t )
2377+ require .ErrorIs (t , runSync (cfg , & syncOptions {remote : "origin" }), ErrSilent )
2378+
2379+ assert .Equal (t , repo .oldImported , issue250Git (t , repo .dir , "rev-parse" , "imported" ))
2380+ issue250Git (t , repo .serverDir , "fetch" , "origin" )
2381+ assert .Equal (t , "server only" , issue250Git (t , repo .serverDir , "show" , "origin/imported:server-only.txt" ))
2382+ }
0 commit comments