Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: no-op dolt_pull() was leaving working set dirty #7882

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}


Loading