After rgit stage --hunk, check the index before committing
Statement#
rgit stage,unstageanddiscardtake several paths, folders and globs, likegit addandgit restore(rgit3699e76and later). Older builds took one path per call:stagerefused a folder withcannot create blob ... it is a directory, anddiscardwith two paths failed witherror: unexpected argument '<second path>' found. On an older build, loop:for f in a b; do rgit discard "$f"; done.--hunktakes several new-side start lines, comma-separated (--hunk 10,42, rgit8d37a5dand later). Take them fromrgit diff --patch; they can differ by a line fromgit diff.- Before rgit
5d47390, a--hunknumber that matched no hunk still reported "staged part" and exited 0 while staging nothing. From5d47390it fails and lists the valid start lines. On an older build, rungit diff --cached --statafter a hunk stage and beforergit 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.