Skip to content

dolthub/dolt#10488: Add --overwrite-ignore and --no-overwrite-ignore - #10549

Merged
elianddb merged 12 commits into
dolthub:mainfrom
codeaucafe:codeaucafe/10488-add-overwrite-and-no-overwrite-ignore-flags
Mar 25, 2026
Merged

elianddb merged 12 commits into
dolthub:mainfrom
codeaucafe:codeaucafe/10488-add-overwrite-and-no-overwrite-ignore-flags

Conversation

@codeaucafe

@codeaucafe codeaucafe commented Feb 23, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds --overwrite-ignore and --no-overwrite-ignore to dolt checkout (for both CLI and SQL procedure). This attempts to mirror Git's behavior. By default, --overwrite-ignore is implied, and checkout silently overwrites ignored tables during a branch switch. When --no-overwrite-ignore is specified, checkout aborts if the target branch would overwrite ignored tables in the working set. Per Git docs, the check only triggers "when the new branch contains ignored files," so tables that only exist locally are not flagged.

  • Register flag constants and argparser entries
  • Add overwriteIgnore bool through all checkout paths: doDoltCheckout -> checkoutNewBranch / checkoutExistingBranch / checkoutRemoteBranch -> doGlobalCheckout -> MoveWorkingSetToBranch -> transferWorkingChanges -> RootsForBranch
  • Add FindOverwrittenIgnoredTables() using dolt_ignore to detect ignored tables that differ between working set and target branch
  • Add ErrCheckoutWouldOverwriteIgnoredTables error type with clear user-facing message

Closes #10488
Closes #10616

Add support for --overwrite-ignore and --no-overwrite-ignore flags to
dolt checkout, matching Git's behavior. By default, ignored tables are
silently overwritten during branch switch (preserving existing
behavior). The new --no-overwrite-ignore flag aborts the checkout if
any ignored tables would be overwritten.

Changes:
- Add flag definitions in flags.go and arg_parser_helpers.go
- Thread overwriteIgnore parameter through SQL procedure call chain
in dolt_checkout.go and dolt_checkout_helpers.go
- Implement FindOverwrittenIgnoredTables() in checkout.go to identify
ignored tables that differ between current working root and target
branch
- Add ErrCheckoutWouldOverwriteIgnoredTables error type
- Add CLI-level mutual exclusivity validation and error handling
- Add 9 BATS integration tests

Note, the implementation handles two checkout paths:
1. With uncommitted changes: check runs via RootsForBranch() during
transferWorkingChanges()
2. Without uncommitted changes: check runs before SwitchWorkingSet()
in MoveWorkingSetToBranch()

Refs: dolthub#10488
Fix FindOverwrittenIgnoredTables to correctly handle the case
where an ignored table exists in the working set but not on the
target branch. Before, the function would incorrectly flag
this as an overwrite scenario when using --no-overwrite-ignore. Added
test for this scenario.

Also, used tbl.String() in FindOverwrittenIgnoredTables instead of
tbl.Name for consistent table name formatting in error messaging.

Refs: dolthub#10488
Extract repeated ignored table check logic into a helper func. Also,
add more edge case tests. Also improve error message wording and add
code comments explaining the semantics of the
--no-overwrite-ignore flag.

Refs: dolthub#10488
Only resolve the target branch head root in the non-move checkout
path when --no-overwrite-ignore is specified. In the default case
(overwrite allowed), the branch head is not needed for the ignored
table check.

Also refactor error message.

Refs: dolthub#10488
@codeaucafe codeaucafe changed the title dolthub/dolt#10488: Add --overwrite-ignore and --no-overwrite-ignore to dolt checkout dolthub/dolt#10488: Add --overwrite-ignore and --no-overwrite-ignore Feb 23, 2026
@codeaucafe

Copy link
Copy Markdown
Contributor Author

@elianddb i think this can be reviewed now: the one failing BATS test is that unrelated docked bats test that always fails for me, so I think we are good on that front.

Thanks in advance for reviewing!

@elianddb elianddb left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeaucafe Looks good! I've left specific nit picks on the implementation before merging.

Comment thread integration-tests/bats/checkout.bats Resolved
@codeaucafe

Copy link
Copy Markdown
Contributor Author

Thank you @elianddb. I'll make corresponding changes tonight

Move CheckOverwrittenIgnoredTables out of RootsForBranch and
transferWorkingChanges and into MoveWorkingSetToBranch. This keeps
ignored-table logic at correct abstraction level rather than threading
it through low-level root-move helpers. Also, add SQL engine tests to
DoltCheckoutScripts to validate the overwrite-ignore flags through the
SQL procedure path.

Refs: dolthub#10488
@codeaucafe
codeaucafe requested a review from elianddb March 3, 2026 07:17
@codeaucafe

Copy link
Copy Markdown
Contributor Author

@elianddb The --no-overwrite-ignore ScriptTest asserts an ExpectedErrStr containing the unqualified table name ignored_tbl. In DoltgreSQL, TableName.String() returns public.ignored_tbl, so the DoltgreSQL integration test fails on the contains check. Dolt's test harness uses exact match, so I can't shorten the expected string either. I see three options to handle here:

  1. Skip the test in DoltgreSQL harness
  2. Use tbl.Name instead of tbl.String() in the error message so both environments produce ignored_tbl (though I don't think this is the better of the options since I think showing the schema-qualified name is more useful for DoltgreSQL users)
  3. Something else you'd prefer

Which approach works best here?

@elianddb

elianddb commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

@elianddb The --no-overwrite-ignore ScriptTest asserts an ExpectedErrStr containing the unqualified table name ignored_tbl. In DoltgreSQL, TableName.String() returns public.ignored_tbl, so the DoltgreSQL integration test fails on the contains check. Dolt's test harness uses exact match, so I can't shorten the expected string either. I see three options to handle here:

  1. Skip the test in DoltgreSQL harness
  2. Use tbl.Name instead of tbl.String() in the error message so both environments produce ignored_tbl (though I don't think this is the better of the options since I think showing the schema-qualified name is more useful for DoltgreSQL users)
  3. Something else you'd prefer

Which approach works best here?

Sorry for the late reply, I managed to get sick so I've been churning slower.

You don't have to match the error string exactly so you could just check for the part of the name after the ".". Also, if the error is an error.Kind, you should be able to use the ExpectedErr field in combination to match the error message.

@codeaucafe

codeaucafe commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor Author

ahh yea good call. I realized later today what I asked was kinda useless because of what you said. Thank you

hope you are feeling better

Replace the ErrCheckoutWouldOverwriteIgnoredTables plain struct with
a errors.Kind so the test assertion can use ExpectedErr instead of
ExpectedErrStr.

This eliminates the DoltgreSQL incompatibility where the error message
contained schema-qualified table names (e.g. public.ignored_tbl) that
did not match the Dolt-only string. Kind.Is() ignores the formatted
message entirely, making the check engine-agnostic.

Refs: dolthub#10488
@codeaucafe

Copy link
Copy Markdown
Contributor Author

@elianddb i resolved and believe this is good to fully review again. The only failing workflows are the ones that generally fail for me as a contributor although it seems there is an issue with Maven install for Bats Unix workflow (have same issue in another PR). Ill check if that is fixed in master after work and if so pull/push updates

@codeaucafe

Copy link
Copy Markdown
Contributor Author

@elianddb thought me pulling your Maven fix from main would fix my BATS tests failing for Maven issue but i guess something is still up. I'm on vacation until early next week so I'll check it when I get back if I don't get to it tonight (still need to look at specific errors/logs)

@codeaucafe

Copy link
Copy Markdown
Contributor Author

@elianddb I think this can be reviewed again.
For failing workflow:

  • sql-server integration: I believe TestCloneNoConjoin test failure is unrelated (could be wrong though?)
  • Test bats unix remote: still having Maven failure issues. I thought there was recent merged PR that fixed this that I pulled in but still having this failure. Maybe its flaky or something else I'm missing?
  • other failing workflows: these always fail for my PRs so I believe its expected due to be being outside contributor?

@elianddb elianddb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeaucafe LGTM! Yeah most of the tests have to be approved to run in the first place, sorry about that.

@elianddb elianddb mentioned this pull request Mar 25, 2026
@elianddb
elianddb merged commit 4a9808a into dolthub:main Mar 25, 2026
51 of 59 checks passed
@codeaucafe

Copy link
Copy Markdown
Contributor Author

No problem at all, completely understandable.

Thank you for taking the time to review the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --overwrite-ignore and --no-overwrite-ignore to dolt checkout

3 participants