diff --git a/go/libraries/doltcore/env/actions/staged.go b/go/libraries/doltcore/env/actions/staged.go index 6dcbd3801d..729f211a1f 100644 --- a/go/libraries/doltcore/env/actions/staged.go +++ b/go/libraries/doltcore/env/actions/staged.go @@ -17,6 +17,7 @@ package actions import ( "context" "fmt" + "strings" "github.com/dolthub/dolt/go/libraries/doltcore/diff" "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" @@ -47,7 +48,7 @@ func StageAllTables(ctx context.Context, roots doltdb.Roots, filterIgnoredTables return StageTables(ctx, roots, tbls, filterIgnoredTables) } -func StageDatabase(ctx context.Context, roots doltdb.Roots, filterIgnoredTables bool) (doltdb.Roots, error) { +func StageDatabase(ctx context.Context, roots doltdb.Roots) (doltdb.Roots, error) { wColl, err := roots.Working.GetCollation(ctx) if err != nil { return doltdb.Roots{}, err @@ -74,6 +75,9 @@ func StageModifiedAndDeletedTables(ctx context.Context, roots doltdb.Roots) (dol var tbls []doltdb.TableName for _, tableDelta := range unstaged { + if strings.HasPrefix(tableDelta.FromName.Name, diff.DBPrefix) { + continue + } if !tableDelta.IsAdd() { tbls = append(tbls, tableDelta.FromName) } diff --git a/go/libraries/doltcore/sqle/dprocedures/dolt_add.go b/go/libraries/doltcore/sqle/dprocedures/dolt_add.go index 6429c53a21..5da2e1012e 100644 --- a/go/libraries/doltcore/sqle/dprocedures/dolt_add.go +++ b/go/libraries/doltcore/sqle/dprocedures/dolt_add.go @@ -69,7 +69,7 @@ func doDoltAdd(ctx *sql.Context, args []string) (int, error) { return 1, err } - roots, err = actions.StageDatabase(ctx, roots, !apr.Contains(cli.ForceFlag)) + roots, err = actions.StageDatabase(ctx, roots) if err != nil { return 1, err } @@ -86,7 +86,7 @@ func doDoltAdd(ctx *sql.Context, args []string) (int, error) { } // remove from slice apr.Args = append(apr.Args[:i], apr.Args[i+1:]...) - roots, err = actions.StageDatabase(ctx, roots, !apr.Contains(cli.ForceFlag)) + roots, err = actions.StageDatabase(ctx, roots) if err != nil { return 1, err } diff --git a/go/libraries/doltcore/sqle/dprocedures/dolt_commit.go b/go/libraries/doltcore/sqle/dprocedures/dolt_commit.go index e38402a20b..b07ce1c6cc 100644 --- a/go/libraries/doltcore/sqle/dprocedures/dolt_commit.go +++ b/go/libraries/doltcore/sqle/dprocedures/dolt_commit.go @@ -86,7 +86,7 @@ func doDoltCommit(ctx *sql.Context, args []string) (string, bool, error) { if err != nil { return "", false, fmt.Errorf(err.Error()) } - roots, err = actions.StageDatabase(ctx, roots, true) + roots, err = actions.StageDatabase(ctx, roots) if err != nil { return "", false, fmt.Errorf(err.Error()) } @@ -95,6 +95,10 @@ func doDoltCommit(ctx *sql.Context, args []string) (string, bool, error) { if err != nil { return "", false, fmt.Errorf(err.Error()) } + roots, err = actions.StageDatabase(ctx, roots) + if err != nil { + return "", false, fmt.Errorf(err.Error()) + } } var name, email string diff --git a/integration-tests/bats/commit.bats b/integration-tests/bats/commit.bats index 262fc3dda6..03fc78b0a0 100644 --- a/integration-tests/bats/commit.bats +++ b/integration-tests/bats/commit.bats @@ -63,6 +63,19 @@ teardown() { [[ "$output" =~ "| 1" ]] || false } +@test "commit: --all (-a) adds changed database collation" { + dolt sql -q "create database colldb" + cd colldb + + dolt sql -q "alter database colldb collate utf8mb4_spanish_ci" + dolt commit -a -m "collation" + + run dolt status + [ $status -eq 0 ] + [[ "$output" =~ "On branch main" ]] || false + [[ "$output" =~ "nothing to commit, working tree clean" ]] || false +} + @test "commit: -m sets commit message properly" { dolt sql -q "CREATE table t1 (pk int primary key);" dolt add t1