Skip to content

feat(commit): ask before splitting, add undo split and fast-split setting - #82

Merged
maxbolgarin merged 3 commits into
mainfrom
claude/confident-johnson-flwbpw
Sep 30, 2026
Merged

maxbolgarin merged 3 commits into
mainfrom
claude/confident-johnson-flwbpw

Conversation

@maxbolgarin

@maxbolgarin maxbolgarin commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Ask before splitting. A regular gitb commit no longer starts splitting when staged changes span several scopes. It first asks Try to split them into atomic commits? (y/N), before any grouping work (AI grouping call, ordering, preview). If you answer y, it groups the files and asks a second time to confirm the resulting groups. A single scope still never prompts.
  • Fast modes still split by default. New setting gitbasher.commit-fast-split (default true), managed like the other settings through gitb cfg fast-split (aliases fs, fastsplit). It offers a local or global choice, and also appears in the gitb cfg summary, in gitb cfg delete, in help and in bash/zsh/fish completion. With the setting off, fast asks like a regular commit, and modes that never prompt (ff, ffp, …) commit everything as one.
  • Undo split. Press u at 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 via read-tree of the pre-split tree, including partial hunks. The flow then continues as a single commit, including after a forced gitb commit split.
  • no-split is unchanged. Help text and README now describe the new flow and the setting.

Linked issue

None.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that changes existing behavior): regular commits now ask one extra question before splitting
  • Refactor (no behavior change)
  • Documentation only

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 unmodified main here.
  • shellcheck scripts/*.sh install.sh: not run, shellcheck isn't installed in this environment
  • Built bundle runs: bash dist/build.sh ./scripts/gitb.sh ./dist/gitb dev && ./dist/gitb --version; gitb cfg shows the Fast split row and gitb cfg help lists fast-split
  • Manually tested the affected command(s): covered only by BATS and the bundle check above

New tests:

  • test_commit_prompt.bats: declining the first prompt skips AI grouping and the preview; y then n declines at the groups; auto-yes (fast) never prompts; a single scope never prompts; an undone split returns 3; the type menu shows u.
  • 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-split sets the value locally, moves it to global on y, and exits unchanged on 0.

Compatibility

  • Works on macOS (BSD userland): not tested
  • Works on Linux (GNU userland)
  • Bash 3.2 compatible (tests/bash32_compat_check.sh passes)

Checklist

  • Commit messages follow Conventional Commits
  • Variables in git invocations are quoted
  • No new xargs -r / GNU-only patterns
  • BATS tests added for non-trivial behavior changes
  • README updated

🤖 Generated with Claude Code

https://claude.ai/code/session_01SfsWNhBqS9KpUcvsBuW9yE

…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
@maxbolgarin
maxbolgarin merged commit 520e66a into main Sep 30, 2026
8 checks passed
@maxbolgarin
maxbolgarin deleted the claude/confident-johnson-flwbpw branch September 30, 2026 13:11
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 5.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants