Repository navigation
Conversation
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
|
@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! |
There was a problem hiding this comment.
@codeaucafe Looks good! I've left specific nit picks on the implementation before merging.
|
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
|
@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:
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 |
|
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
|
@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 |
…e/10488-add-overwrite-and-no-overwrite-ignore-flags
|
@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) |
…e/10488-add-overwrite-and-no-overwrite-ignore-flags
|
@elianddb I think this can be reviewed again.
|
elianddb
left a comment
There was a problem hiding this comment.
@codeaucafe LGTM! Yeah most of the tests have to be approved to run in the first place, sorry about that.
|
No problem at all, completely understandable. Thank you for taking the time to review the PR! |
This PR adds
--overwrite-ignoreand--no-overwrite-ignoretodolt checkout(for both CLI and SQL procedure). This attempts to mirror Git's behavior. By default,--overwrite-ignoreis implied, and checkout silently overwrites ignored tables during a branch switch. When--no-overwrite-ignoreis 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.overwriteIgnore boolthrough all checkout paths:doDoltCheckout->checkoutNewBranch/checkoutExistingBranch/checkoutRemoteBranch->doGlobalCheckout->MoveWorkingSetToBranch->transferWorkingChanges->RootsForBranchFindOverwrittenIgnoredTables()usingdolt_ignoreto detect ignored tables that differ between working set and target branchErrCheckoutWouldOverwriteIgnoredTableserror type with clear user-facing messageCloses #10488
Closes #10616