Ray's Knowledge Base

After rgit stage --hunk, check the index before committing

FactVerified 28 Sep 2026Holds anywhere
Fact. A statement and the evidence for it.

Statement#

  • rgit stage, unstage and discard take several paths, folders and globs, like git add and git restore (rgit 3699e76 and later). Older builds took one path per call: stage refused a folder with cannot create blob ... it is a directory, and discard with two paths failed with error: unexpected argument '<second path>' found. On an older build, loop: for f in a b; do rgit discard "$f"; done.
  • --hunk takes several new-side start lines, comma-separated (--hunk 10,42, rgit 8d37a5d and later). Take them from rgit diff --patch; they can differ by a line from git diff.
  • Before rgit 5d47390, a --hunk number that matched no hunk still reported "staged part" and exited 0 while staging nothing. From 5d47390 it fails and lists the valid start lines. On an older build, run git diff --cached --stat after a hunk stage and before rgit commit.

The rgit defect is in rgit stage --hunk reports success for a hunk it did not stage.

Evidence#

2026-09-27, dftracer-utils: rgit discard with 10 paths failed as above; one call per path discarded all 10.

2026-09-27: in the rkb repository a commit went in without its test hunk after --hunk 1021 (rgit's number was 1022), found by checking the index. In a scratch repository with rgit 3699e76, rgit stage d g.txt staged a folder and a file, and rgit stage f.txt --hunk 99 printed "staged part of f.txt", exited 0 and staged nothing.

2026-09-27, rgit 3699e76: rgit discard dir c.txt and rgit unstage dir c.txt worked in one call (test stage_unstage_and_discard_take_many_paths_folders_and_globs in crates/rgit-cli/tests/paths.rs). rgit 5d47390: rgit stage f.txt --hunk 99 printed no hunk at line 99 of f.txt; hunks start at: 1, 22 and exited 1.