Skip to content

lakectl: switch tracked ref on local checkout even when the commit is unchanged - #10524

Open
ChrisJr404 wants to merge 1 commit into
treeverse:masterfrom
ChrisJr404:fix/local-checkout-switch-ref
Open

lakectl: switch tracked ref on local checkout even when the commit is unchanged#10524
ChrisJr404 wants to merge 1 commit into
treeverse:masterfrom
ChrisJr404:fix/local-checkout-switch-ref

Conversation

@ChrisJr404

Copy link
Copy Markdown

Closes #8361

Change Description

Background

lakectl local checkout --ref <other-branch> is supposed to switch the local directory to track a different ref. It works when the new ref points at a different commit, but when the requested ref resolves to the same commit the directory is already at, the tracked ref in .lakefs_ref.yaml is left untouched, so the directory keeps following the ref it was originally checked out from.

Bug Fix

  1. Problem - checking out a ref that points at the current commit does not switch which ref the local directory tracks.
  2. Root cause - localCheckout only rewrote the index when newHead != idx.AtHead, so a ref change with an unchanged head was ignored.
  3. Solution - rewrite the index when the requested ref differs from the currently tracked ref as well, not only when the commit changes. When the head is unchanged there are no files to sync, so this just updates the tracked ref.

Testing Details

Added a unit test for the new checkoutSwitchesRef predicate covering same ref/same commit, different ref/same commit (the reported case), same ref/new commit, and different ref/different commit.

Breaking Change?

No. Existing checkouts that move to a different commit behave exactly as before.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added area/testing Improvements or additions to tests area/lakectl Issues related to lakeFS' command line interface (lakectl) labels Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/lakectl Issues related to lakeFS' command line interface (lakectl) area/testing Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lakectl local checkout to a new branch in a local directory

2 participants