fix(reset): support git-style bare path reset#431
Merged
Conversation
Signed-off-by: Quanyi Ma <eli@patch.sh>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates libra reset to better match Git’s revision/pathspec disambiguation rules, so a bare positional that is a known path (and not a revision) is treated as a pathspec and unstaged against HEAD. It also preserves explicit -- behavior for forcing path interpretation and introduces an explicit ambiguity error when a token is both a revision and a tracked path.
Changes:
- Implement Git-style disambiguation for
libra reset <path>(unstage vsHEAD) and add an explicit “revision vs filename” ambiguity error. - Add integration tests and update docs/compatibility/integration scenario tables to reflect the new reset semantics.
- Gate
parse_stat_start_ticksbehind Linux/test cfg to eliminate non-Linux dead-code warnings.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/command/reset_test.rs | Adds coverage for bare pathspec unstage, ---forced pathspec, and revision/path ambiguity errors. |
| src/internal/ai/review/launcher.rs | Gates /proc stat parsing helper to Linux/test builds. |
| src/command/reset.rs | Implements reset request normalization/disambiguation; adds ambiguity error variant and docs/help examples. |
| src/command/cherry_pick.rs | Updates ResetArgs construction for the new target: Option<_> + pathspec_separator fields. |
| src/cli.rs | Rewrites argv for reset to preserve “user typed -- inside reset args” via an internal hidden flag and (currently) separator rewriting logic. |
| docs/development/integration/integration-scenarios/cli.restore-reset-diff.md | Updates scenario steps to use libra reset <path> for unstage behavior. |
| docs/development/integration/integration-scenarios/_parameter-tables.md | Updates parameter table entries to reflect new reset forms and ambiguity rule. |
| docs/development/commands/reset.md | Updates internal command design doc synopsis/contract around bare pathspecs and ambiguity. |
| docs/commands/zh-CN/reset.md | Updates user-facing Chinese docs with new bare pathspec behavior, ambiguity guidance, and examples. |
| docs/commands/reset.md | Updates user-facing English docs with new bare pathspec behavior, ambiguity guidance, and examples. |
| COMPATIBILITY.md | Documents Git-style bare pathspec behavior and ambiguity rejection for reset. |
Comment on lines
+1066
to
+1069
| if !has_target_before_separator && args.get(separator_index + 1).is_some() { | ||
| out.push("HEAD".to_string()); | ||
| } | ||
| out.extend(args.iter().skip(separator_index + 1).cloned()); |
genedna
added a commit
that referenced
this pull request
Jul 6, 2026
…ask C8, v0.18.20) Final Code-phase task (docs/compat/index only; no src change). Closes the C1 audit's documentation gaps and re-verifies the compat/index surface against the shipped C1-C7 behavior. - GAP-5 (run_libra_vcs allowlist): code.md + zh-CN corrected from 8 commands (and a wrong "don't use ls-files" instruction) to the authoritative 10 (status, diff, branch, log, show, show-ref, ls-files, add, commit, switch, per libra_vcs.rs ALLOWED_COMMANDS) and now recommends ls-files (incl. --others --exclude-standard), matching the tool's own guidance. - GAP-6..12 (flag/UI docs): documented --goal, --agent, --approval-ttl (overrides [approval] ttl_seconds), --kimi-stream; added the allow-all approval policy and fixed "four-tier"→"five-tier"; clarified --plan-mode (off; on for Codex, explicit =true Codex-only); synced the zh-CN browser-control route matrix to the EN doc + code_router(). - COMPATIBILITY.md: code/code-control already marked intentionally-different / Libra-only (matrix_alignment guard passes). - tests/INDEX.md: corrected 2 Code-phase rows whose source paths pointed at a non-existent agent/codex* path → src/internal/ai/codex/. - tracing code.md: updated one contract row that still asserted a web-only drift risk C2 resolved. - CHANGELOG.md: Code-phase closeout entry + a "mutating fix bridge deferred" note (review --fix / investigate fix stay read-only with LBR-AGENT-010; no agent↔code mutating collaboration yet). codex review: R1 (--approval-ttl doc named approval.ttl not ttl_seconds; --plan-mode implied non-Codex =true works), R2 (zh --plan-mode=false said "session exits" not "opts out of plan mode"), fixed EN+zh; R3 VERDICT: PASS with no findings. Gates: compat_matrix_alignment 7, compat_command_docs_examples_section 1, compat_help_examples_banner 1, compat_error_codes_doc_sync 2, fmt all green. The mandatory full cargo test --all could not complete on this machine — the parallel spawn-based command tests (fsck/shortlog) deadlock around test ~101, reproduced across C4-C8, load-independent, zero test failures, and every test passes individually; C8 is docs-only so the code is the already-C7-verified HEAD. Also recovered from a libra-CLI panic during the origin/main merge that left a spurious #431 revert staged in the shared index (restored 11 non-C8 files to HEAD). This completes the Code phase (C1-C8) and the full plan.md improvement plan (Agent A1-A9 + Code C1-C8). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Eli Ma <eli@patch.sh>
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.
What
libra reset <path>follow Git-style disambiguation and unstage paths fromHEADwhen the first bare positional is a known path and not a revision.libra reset -- <path>so revision-like filenames are forced to pathspecs, and reject tokens that are both revisions and tracked paths as ambiguous.parse_stat_start_ticksto Linux/test builds to remove the non-Linux dead-code warning.Why
Users expect
libra reset web/package.jsonto behave like Git and unstage/reset that path from the index, rather than treating the path as an invalid revision.Checks
cargo +nightly fmt --all --checkcargo clippy --all-targets --all-features -- -D warningsLIBRA_SKIP_WEB_BUILD=1 cargo test --test command_test command::reset_test::LIBRA_SKIP_WEB_BUILD=1 cargo test --test command_test reset_help_includes_examples_sectionLIBRA_SKIP_WEB_BUILD=1 cargo test --lib stat_start_ticks--path reset, and revision/path ambiguity.