Skip to content

fix(reset): support git-style bare path reset#431

Merged
genedna merged 1 commit into
mainfrom
codex/reset-bare-path-git-compat
Jul 6, 2026
Merged

fix(reset): support git-style bare path reset#431
genedna merged 1 commit into
mainfrom
codex/reset-bare-path-git-compat

Conversation

@genedna

@genedna genedna commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

  • Make libra reset <path> follow Git-style disambiguation and unstage paths from HEAD when the first bare positional is a known path and not a revision.
  • Preserve libra reset -- <path> so revision-like filenames are forced to pathspecs, and reject tokens that are both revisions and tracked paths as ambiguous.
  • Update reset docs, compatibility docs, integration scenario tables, and reset tests.
  • Gate parse_stat_start_ticks to Linux/test builds to remove the non-Linux dead-code warning.

Why

Users expect libra reset web/package.json to 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 --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • LIBRA_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_section
  • LIBRA_SKIP_WEB_BUILD=1 cargo test --lib stat_start_ticks
  • Manual temp-repo checks for bare path reset, -- path reset, and revision/path ambiguity.

Signed-off-by: Quanyi Ma <eli@patch.sh>
Copilot AI review requested due to automatic review settings July 6, 2026 08:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 vs HEAD) 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_ticks behind 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 thread src/cli.rs
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 genedna marked this pull request as ready for review July 6, 2026 08:38
@genedna genedna merged commit 22c331c into main Jul 6, 2026
9 of 11 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants