From f6c9f227cbd4335c45d51df640a4a95210066e5e Mon Sep 17 00:00:00 2001 From: Andy Arthur Date: Tue, 3 Aug 2021 15:14:54 -0700 Subject: [PATCH 1/2] added skipped bats to repro dirty index after 'dolt merge --abort' --- integration-tests/bats/merge.bats | 25 +++++++++++++++++++++ integration-tests/bats/sql-merge.bats | 32 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/integration-tests/bats/merge.bats b/integration-tests/bats/merge.bats index 7a1653f1e3..1c9452aa58 100644 --- a/integration-tests/bats/merge.bats +++ b/integration-tests/bats/merge.bats @@ -88,6 +88,31 @@ teardown() { [[ "${lines[1]}" =~ "9,9,9" ]] || false } +@test "merge: --abort leaves clean working, staging roots" { + dolt branch other + + dolt sql -q "INSERT INTO test1 VALUES (1,10,10);" + dolt commit -am "added rows to test1 on master" + + dolt checkout other + dolt sql -q "INSERT INTO test1 VALUES (2,20,20);" + dolt commit -am "added rows to test1 on other" + + dolt checkout master + dolt merge other + run dolt status + [ "$status" -eq 0 ] + [[ "$output" =~ "still merging" ]] || false + [[ "$output" =~ "modified: test" ]] || false + + dolt merge --abort + run dolt status + [ "$status" -eq 0 ] + [[ "${lines[0]}" =~ "On branch master" ]] || false + skip "index is left dirty after --abort" + [[ "${lines[1]}" =~ "nothing to commit, working tree clean" ]] || false +} + @test "merge: squash merge" { dolt checkout -b merge_branch dolt SQL -q "INSERT INTO test1 values (0,1,2)" diff --git a/integration-tests/bats/sql-merge.bats b/integration-tests/bats/sql-merge.bats index f1b5bf17bb..c63dc86ad1 100644 --- a/integration-tests/bats/sql-merge.bats +++ b/integration-tests/bats/sql-merge.bats @@ -348,6 +348,38 @@ SQL [[ "$output" =~ "9,9,9" ]] || false } + +@test "sql-merge: DOLT_MERGE(--abort) clears index state" { + run dolt sql --disable-batch << SQL +set autocommit = off; +CREATE TABLE one_pk ( + pk1 BIGINT NOT NULL, + c1 BIGINT, + c2 BIGINT, + PRIMARY KEY (pk1) +); +SELECT DOLT_COMMIT('-a', '-m', 'add tables'); +SELECT DOLT_CHECKOUT('-b', 'feature-branch'); +SELECT DOLT_CHECKOUT('master'); +INSERT INTO one_pk (pk1,c1,c2) VALUES (0,0,0); +SELECT DOLT_COMMIT('-a', '-m', 'changed master'); +SELECT DOLT_CHECKOUT('feature-branch'); +INSERT INTO one_pk (pk1,c1,c2) VALUES (0,1,1); +SELECT DOLT_COMMIT('-a', '-m', 'changed feature branch'); +SELECT DOLT_CHECKOUT('master'); +SELECT DOLT_MERGE('feature-branch'); +SELECT DOLT_MERGE('--abort'); +commit; +SQL + [ $status -eq 0 ] + + run dolt status + [ "$status" -eq 0 ] + [[ "${lines[0]}" =~ "On branch master" ]] || false + skip "index is left dirty after --abort" + [[ "${lines[1]}" =~ "nothing to commit, working tree clean" ]] || false +} + @test "sql-merge: DOLT_MERGE with unresolved conflicts throws an error" { run dolt sql << SQL CREATE TABLE one_pk ( From d18c2e800381cae15703aaecd23be1a30b34b396 Mon Sep 17 00:00:00 2001 From: Andy Arthur Date: Tue, 3 Aug 2021 15:19:10 -0700 Subject: [PATCH 2/2] set stagedRoot = workingRoot in WorkingSet.AbortMerge() --- go/libraries/doltcore/doltdb/workingset.go | 1 + integration-tests/bats/merge.bats | 1 - integration-tests/bats/sql-merge.bats | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/go/libraries/doltcore/doltdb/workingset.go b/go/libraries/doltcore/doltdb/workingset.go index 44f3fa2e06..6f7966ee2f 100755 --- a/go/libraries/doltcore/doltdb/workingset.go +++ b/go/libraries/doltcore/doltdb/workingset.go @@ -136,6 +136,7 @@ func (ws WorkingSet) StartMerge(commit *Commit) *WorkingSet { func (ws WorkingSet) AbortMerge() *WorkingSet { ws.workingRoot = ws.mergeState.PreMergeWorkingRoot() + ws.stagedRoot = ws.workingRoot ws.mergeState = nil return &ws } diff --git a/integration-tests/bats/merge.bats b/integration-tests/bats/merge.bats index 1c9452aa58..80bcdd247d 100644 --- a/integration-tests/bats/merge.bats +++ b/integration-tests/bats/merge.bats @@ -109,7 +109,6 @@ teardown() { run dolt status [ "$status" -eq 0 ] [[ "${lines[0]}" =~ "On branch master" ]] || false - skip "index is left dirty after --abort" [[ "${lines[1]}" =~ "nothing to commit, working tree clean" ]] || false } diff --git a/integration-tests/bats/sql-merge.bats b/integration-tests/bats/sql-merge.bats index c63dc86ad1..2a0dfe6b52 100644 --- a/integration-tests/bats/sql-merge.bats +++ b/integration-tests/bats/sql-merge.bats @@ -376,7 +376,6 @@ SQL run dolt status [ "$status" -eq 0 ] [[ "${lines[0]}" =~ "On branch master" ]] || false - skip "index is left dirty after --abort" [[ "${lines[1]}" =~ "nothing to commit, working tree clean" ]] || false }