Repository navigation
feat(commit): ask before splitting, add undo split and fast-split setting - #82
Merged
Merged
Conversation
…ting Regular commits no longer start the split process on their own. When staged changes span several scopes, gitb first asks "Try to split them into atomic commits?" before any grouping work (AI call, ordering, preview); only on "y" does it group the files and ask a second time to confirm the resulting groups. Fast modes still split by default. New setting gitbasher.commit-fast-split (default true) turns that off: `fast` then asks like a regular commit, and prompt-less modes such as `ff` commit everything as one. At any split prompt (type menu or AI suggestion) `u` now undoes the split: commits the split already created are dropped (soft reset to the starting HEAD), the original index is restored exactly (read-tree of the pre-split tree, partial hunks included), and the flow continues with a single commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SfsWNhBqS9KpUcvsBuW9yE
gitbasher.commit-fast-split is now managed like the other settings: an interactive `gitb cfg fast-split` (aliases fs, fastsplit) with local/global choice, a "Fast split" row in `gitb cfg`, an entry in `gitb cfg delete`, help text, tab completion (bash/zsh/fish) and README docs. Reads go through the new get_fast_split helper, which normalizes unknown values to true. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SfsWNhBqS9KpUcvsBuW9yE
The per-group type menu now says, under its header, that the changes were split and that `u` undoes it, including how many split commits made so far it would drop. The one-time tip at the start of the split is kept only for the AI path, which has no type menu up front. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SfsWNhBqS9KpUcvsBuW9yE
|
🎉 This PR is included in version 5.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gitb commitno longer starts splitting when staged changes span several scopes. It first asksTry to split them into atomic commits? (y/N), before any grouping work (AI grouping call, ordering, preview). If you answery, it groups the files and asks a second time to confirm the resulting groups. A single scope still never prompts.gitbasher.commit-fast-split(defaulttrue), managed like the other settings throughgitb cfg fast-split(aliasesfs,fastsplit). It offers a local or global choice, and also appears in thegitb cfgsummary, ingitb cfg delete, in help and in bash/zsh/fish completion. With the setting off,fastasks like a regular commit, and modes that never prompt (ff,ffp, …) commit everything as one.uat any split prompt (the per-group type menu or the AI "Use it?" prompt) to undo the split. Commits the split already made are dropped (soft reset to the starting HEAD; unborn branch handled). The original index is restored exactly viaread-treeof the pre-split tree, including partial hunks. The flow then continues as a single commit, including after a forcedgitb commit split.no-splitis unchanged. Help text and README now describe the new flow and the setting.Linked issue
None.
Type of change
Test plan
bash tests/run_tests.sh: all commit, split, prompt, config and completion tests pass, including the new ones. The failures in this container are in log, branch listing and push tests, and the same tests fail on unmodifiedmainhere.shellcheck scripts/*.sh install.sh: not run, shellcheck isn't installed in this environmentbash dist/build.sh ./scripts/gitb.sh ./dist/gitb dev && ./dist/gitb --version;gitb cfgshows theFast splitrow andgitb cfg helplistsfast-splitNew tests:
test_commit_prompt.bats: declining the first prompt skips AI grouping and the preview;ythenndeclines at the groups; auto-yes (fast) never prompts; a single scope never prompts; an undone split returns 3; the type menu showsu.test_commit_split_integrity.bats: undo after one split commit restores HEAD and the exact index tree (with partial staging); undo from the type menu before any commit.test_config_fast_split.bats: getter default and normalization;cfg fast-splitsets the value locally, moves it to global ony, and exits unchanged on0.Compatibility
tests/bash32_compat_check.shpasses)Checklist
gitinvocations are quotedxargs -r/ GNU-only patterns🤖 Generated with Claude Code
https://claude.ai/code/session_01SfsWNhBqS9KpUcvsBuW9yE