Skip to content

Conversation

@Tillerino
Copy link

This Pull Request partly addresses #2748.

The "error" result from the binary search was not taken into account after an update to the status tree, which lead to files being skipped when the last file in a directory was staged.

Before:

Screencast_20251029_204232.webm

(skips zzz)

After:

Screencast_20251029_204327.webm

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

@Tillerino Tillerino force-pushed the binary-search-error-result branch from 8409e2c to 01815be Compare October 29, 2025 19:53
@extrawurst extrawurst added this to the v0.28 milestone Nov 28, 2025
@extrawurst extrawurst requested a review from cruessler November 28, 2025 21:19
@extrawurst
Copy link
Collaborator

@Tillerino could you fix the conflicts?

Copy link
Collaborator

@cruessler cruessler left a comment

Choose a reason for hiding this comment

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

I really like this change as that is something that has been bothering me for quite some time now. Thanks for the fix! I tested the fix briefly and did not find any issues. I left two minor comments, but nothing major.

});
match res {
Ok(i) => Some(i),
Err(i) => Some(cmp::min(i, self.tree.len() - 1)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this ever pick self.tree.len() - 1 or could we just return i? Can we add a test case specifically for the former scenario if this can happen? (I can’t tell whether this is covered by existing tests already.)

Also, last_index is now an unused parameter. Can it be removed.


#[test]
fn test_next_when_dir_disappears() {
let mut res = StatusTree::default();
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think about renaming res to tree for clarity? (res probably comes from existing tests, but tree carries more context, so I think is better here).

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.

3 participants