Skip to content

Fix 483 unable to checkout table(s)/branch(s) with same name#9371

Merged
elianddb merged 39 commits intomainfrom
elianddb/fix-483-unable-to-checkout-table-branch
Jun 25, 2025
Merged

Fix 483 unable to checkout table(s)/branch(s) with same name#9371
elianddb merged 39 commits intomainfrom
elianddb/fix-483-unable-to-checkout-table-branch

Conversation

@elianddb
Copy link
Copy Markdown
Contributor

@elianddb elianddb commented Jun 18, 2025

Fixes: #483
Local/remote refs take priority in Do What I Mean (DWIM) scenarios where dolt has to interpret ambiguous input in checkout.
If a table and tracking branch share the same name, but local does not exist an error will occur.
-- can now be used to clear up ambiguity.
case 1: dolt checkout <ref> -- [<tables>]
<ref> must be a singular valid tree, everything else after '--' must be a table.
case 2: dolt checkout -- [<tables>]
This is case 1 but without <ref>.
case 3: git checkout <something> [--]
(a) If is a commit switch to branch.
(b) If isn’t a commit, and either "--" is present or isn’t a table, no -t or -b is given, and there’s a tracking branch named on exactly one remote (or on the specified remote), then this acts as shorthand to fork local from that remote-tracking branch.
(c) Otherwise, if "--" is present, treat it like case 1.
(d) Otherwise, if a ref treat it like case 1. If a table treat like case 2. If neither fail.
case 4: git checkout <something> <tables>
The first argument must not be ambiguous. If a <ref> follow case 1, if a table follow case 2. Otherwise, fail.

@elianddb elianddb linked an issue Jun 18, 2025 that may be closed by this pull request
@coffeegoddd
Copy link
Copy Markdown
Contributor

@elianddb DOLT

comparing_percentages
100.000000 to 100.000000
version result total
fecea6b ok 5937457
version total_tests
fecea6b 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
0631c39 ok 5937457
version total_tests
0631c39 5937457
correctness_percentage
100.0

@elianddb elianddb force-pushed the elianddb/fix-483-unable-to-checkout-table-branch branch from 0631c39 to 7587982 Compare June 18, 2025 17:00
@elianddb
Copy link
Copy Markdown
Contributor Author

Extra issue I found though I didn't handle since they weren't relevant to this one:
On dolt checkout or dolt checkout -- the relationship between the current branch and its upstream (tracking) branch should be displayed, however, dolt currently displays the checkout usage message.

dolt checkout test0 test1 if test0 is not found it prevents test1 from being checkout in dolt but in git each is processed without affecting the other.

@coffeegoddd
Copy link
Copy Markdown
Contributor

@elianddb DOLT

comparing_percentages
100.000000 to 100.000000
version result total
7587982 ok 5937457
version total_tests
7587982 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
7282025 ok 5937457
version total_tests
7282025 5937457
correctness_percentage
100.0

@elianddb elianddb force-pushed the elianddb/fix-483-unable-to-checkout-table-branch branch 2 times, most recently from d2316fe to 662b7a4 Compare June 18, 2025 21:08
@coffeegoddd
Copy link
Copy Markdown
Contributor

@elianddb DOLT

comparing_percentages
100.000000 to 100.000000
version result total
662b7a4 ok 5937457
version total_tests
662b7a4 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
1d251bb ok 5937457
version total_tests
1d251bb 5937457
correctness_percentage
100.0

@elianddb elianddb force-pushed the elianddb/fix-483-unable-to-checkout-table-branch branch from 1d251bb to c919512 Compare June 18, 2025 22:31
@elianddb elianddb self-assigned this Jun 18, 2025
@coffeegoddd
Copy link
Copy Markdown
Contributor

@elianddb DOLT

comparing_percentages
100.000000 to 100.000000
version result total
c919512 ok 5937457
version total_tests
c919512 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
050269d ok 5937457
version total_tests
050269d 5937457
correctness_percentage
100.0

@elianddb elianddb force-pushed the elianddb/fix-483-unable-to-checkout-table-branch branch 3 times, most recently from b1d1e9d to 1c0a523 Compare June 18, 2025 23:53
@coffeegoddd
Copy link
Copy Markdown
Contributor

@elianddb DOLT

comparing_percentages
100.000000 to 100.000000
version result total
1c0a523 ok 5937457
version total_tests
1c0a523 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
7f915f1 ok 5937457
version total_tests
7f915f1 5937457
correctness_percentage
100.0

@elianddb elianddb force-pushed the elianddb/fix-483-unable-to-checkout-table-branch branch 2 times, most recently from 4518931 to 5b4d2f4 Compare June 19, 2025 04:36
@coffeegoddd
Copy link
Copy Markdown
Contributor

@elianddb DOLT

comparing_percentages
100.000000 to 100.000000
version result total
5b4d2f4 ok 5937457
version total_tests
5b4d2f4 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
83507fd ok 5937457
version total_tests
83507fd 5937457
correctness_percentage
100.0

@elianddb elianddb force-pushed the elianddb/fix-483-unable-to-checkout-table-branch branch from 83507fd to 05b3bff Compare June 19, 2025 05:49
@coffeegoddd
Copy link
Copy Markdown
Contributor

@elianddb DOLT

comparing_percentages
100.000000 to 100.000000
version result total
05b3bff ok 5937457
version total_tests
05b3bff 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
f2ec13f ok 5937457
version total_tests
f2ec13f 5937457
correctness_percentage
100.0

Copy link
Copy Markdown
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

LGTM, see comments.

You should also add some spot checks to make sure these work in the SQL context for the dolt_checkout procedure. There's a dolt_queries.go file with lots of checkout tests in it.

dolt checkout main

# Use explicit branch reference
dolt checkout feature --
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This answers my question from the code, didn't know about this syntax. Good to make that explicit in the code

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good tests

@elianddb elianddb force-pushed the elianddb/fix-483-unable-to-checkout-table-branch branch from f2ec13f to 72cbbbd Compare June 23, 2025 21:43
@elianddb elianddb force-pushed the elianddb/fix-483-unable-to-checkout-table-branch branch from e69bc56 to cd81f2f Compare June 25, 2025 15:17
@coffeegoddd
Copy link
Copy Markdown
Contributor

@elianddb DOLT

comparing_percentages
100.000000 to 100.000000
version result total
cd81f2f ok 5937457
version total_tests
cd81f2f 5937457
correctness_percentage
100.0

@coffeegoddd
Copy link
Copy Markdown
Contributor

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
852f652 ok 5937457
version total_tests
852f652 5937457
correctness_percentage
100.0

@elianddb elianddb merged commit af8a3f7 into main Jun 25, 2025
21 of 22 checks passed
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.

Unable to checkout table if branch name and table name are identical

3 participants