Skip to content

perf: avoid listing modified files twice in checkout-file - #546

Merged
cjappl merged 1 commit into
mainfrom
capple/dont_fetch_files_twice
Jul 15, 2026
Merged

perf: avoid listing modified files twice in checkout-file#546
cjappl merged 1 commit into
mainfrom
capple/dont_fetch_files_twice

Conversation

@cjappl

@cjappl cjappl commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

_forgit_checkout_file called _forgit_list_modified_files once to check for an empty result and again to feed fzf, running git diff twice on every invocation. Cache the result and reuse it for both checks.

Check list

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have added unit tests for my code
  • I have made corresponding changes to the documentation

Description

Type of change

  • Performance

Test environment

  • Shell
    • bash
    • zsh
    • fish
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:

Summary by CodeRabbit

  • Bug Fixes
    • Improved the modified-file checkout picker by reusing a single, consistent list of modified files for both the empty-state check and the selection display.
    • Prevented cases where the candidates shown in the picker could differ from the availability logic used to decide whether files were selectable.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc16b0bc-c437-41d4-ba40-8d8b934b9c18

📥 Commits

Reviewing files that changed from the base of the PR and between 7890a06 and 88ddf4a.

📒 Files selected for processing (1)
  • bin/git-forgit
🚧 Files skipped from review as they are similar to previous changes (1)
  • bin/git-forgit

📝 Walkthrough

Walkthrough

_forgit_checkout_file captures modified files once, uses that value for the empty-list check, and passes the same list to fzf for checkout target selection.

Changes

Checkout file selection

Layer / File(s) Summary
Capture and reuse modified files
bin/git-forgit
_forgit_checkout_file stores the modified-file output once, checks whether it is empty, and feeds the captured list to fzf.

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related PRs

  • wfxr/forgit#544: Both changes update the checkout-file flow to use _forgit_list_modified_files for the empty-list check and fzf candidates.

Suggested reviewers: wfxr, carlfriedrich

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main performance change.
Description check ✅ Passed The description is mostly complete with a summary, checklist, and test environment, though the Description section is sparse.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch capple/dont_fetch_files_twice

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cjappl
cjappl force-pushed the capple/dont_fetch_files_twice branch from 868809b to 0ff3a59 Compare July 13, 2026 17:15
@cjappl

cjappl commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

This originated from a coderabbit review here:
#544 (review)

@sandr01d sandr01d left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, just one comment.

Comment thread bin/git-forgit
@cjappl
cjappl force-pushed the capple/dont_fetch_files_twice branch from 0ff3a59 to 7890a06 Compare July 13, 2026 22:34
_forgit_checkout_file called _forgit_list_modified_files once to check for
an empty result and again to feed fzf, running git diff twice on every
invocation. Cache the result and reuse it for both checks.
@cjappl
cjappl force-pushed the capple/dont_fetch_files_twice branch from 7890a06 to 88ddf4a Compare July 14, 2026 20:39
@cjappl
cjappl requested a review from sandr01d July 14, 2026 20:39

@sandr01d sandr01d left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@cjappl
cjappl merged commit 15db001 into main Jul 15, 2026
14 checks passed
@cjappl
cjappl deleted the capple/dont_fetch_files_twice branch July 15, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants