Skip to content

Commit

Permalink
Merge pull request #7882 from dolthub/zachmu/pull-bug
Browse files Browse the repository at this point in the history
Bug fix: no-op `dolt_pull()` was leaving working set dirty
  • Loading branch information
zachmu committed May 21, 2024
2 parents 9165f6b + f28be4c commit 4cd8fb7
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 5 deletions.
5 changes: 0 additions & 5 deletions go/libraries/doltcore/sqle/dprocedures/dolt_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,6 @@ func doDoltPull(ctx *sql.Context, args []string) (int, int, string, error) {
if err != nil && !errors.Is(doltdb.ErrUpToDate, err) {
return conflicts, fastForward, "", err
}

err = sess.SetWorkingSet(ctx, dbName, ws)
if err != nil {
return conflicts, fastForward, "", err
}
}
if !rsSeen {
return noConflictsOrViolations, threeWayMerge, "", fmt.Errorf("%w: '%s'", ref.ErrInvalidRefSpec, refSpec.GetRemRefToLocal())
Expand Down
95 changes: 95 additions & 0 deletions integration-tests/bats/sql-pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,98 @@ SQL
[[ "$output" =~ "merge from origin" ]] || false
}

@test "sql-pull: pull two different branches in the same session" {
cd repo2
dolt pull

dolt sql <<SQL
call dolt_checkout('main');
insert into t1 values (1,1), (2,2);
call dolt_commit('-Am', 'new rows in t1');
call dolt_checkout('-b', 'b1');
insert into t1 values (3,3);
call dolt_commit('-Am', 'new row on b1');
SQL

dolt push origin main
dolt checkout b1
dolt push origin b1
dolt checkout main

cd ../repo1
dolt pull origin main
dolt checkout b1
dolt pull origin b1

cd ../repo2
dolt sql <<SQL
call dolt_checkout('main');
insert into t1 values (4,4);
call dolt_commit('-Am', 'new row in t1');
call dolt_checkout('b1');
insert into t1 values (5,5);
call dolt_commit('-Am', 'new row on b1');
SQL

dolt push origin main
dolt checkout b1
dolt push origin b1
dolt checkout main

cd ../repo1

dolt sql <<SQL
call dolt_checkout('main');
insert into t1 values (6,6);
call dolt_commit('-Am', 'new row in t1');
call dolt_checkout('b1');
insert into t1 values (7,7);
call dolt_commit('-Am', 'new row on b1');
SQL

# Now pull from both branches and make sure we can commit the result in a single tx
dolt sql <<SQL
set autocommit = 0;
call dolt_checkout('main');
call dolt_pull('origin', 'main');
call dolt_checkout('b1');
call dolt_pull('origin', 'b1');
commit;
SQL
}

@test "sql-pull: pull two different branches same session, already up to date" {
cd repo2
dolt pull

dolt sql <<SQL
call dolt_checkout('main');
insert into t1 values (1,1), (2,2);
call dolt_commit('-Am', 'new rows in t1');
call dolt_checkout('-b', 'b1');
insert into t1 values (3,3);
call dolt_commit('-Am', 'new row on b1');
SQL

dolt push origin main
dolt checkout b1
dolt push origin b1
dolt checkout main

cd ../repo1
dolt pull origin main
dolt checkout b1
dolt pull origin b1

# Make sure we can commit the result after a no-op pull on two branches
dolt sql <<SQL
set autocommit=off;
call dolt_checkout('main');
call dolt_pull('origin', 'main');
call dolt_checkout('b1');
call dolt_pull('origin', 'b1');
commit;
SQL
}


0 comments on commit 4cd8fb7

Please sign in to comment.