Skip to content

grep: align --exclude-standard and subdirectory --untracked behavior with Git #488

Description

@genedna

Summary

libra grep diverges from Git in two independently reproducible parts of the upstream scenario t7810-grep.sh test 200 (inside git repository but with --no-index):

  1. grep --no-index --exclude-standard is rejected as an unsupported option.
  2. From a subdirectory, grep --untracked searches from the repository root instead of limiting output to the current directory.

This is tracked by libra-testcases as TC-1596. Merely normalizing Git's .gitignore to Libra's .libraignore is insufficient because both differences affect behavior, not just output wording.

Versions

  • Libra: 0.22.19
  • Git control: 2.55.0.782.g1630431f32
  • Platform: macOS, case-insensitive APFS
  • Upstream source: Git commit 1630431f326e15fcde608827b5ff38422528eb59, t/t7810-grep.sh lines 1288-1328

Reproduction

Run the following with LIBRA set to the Libra binary:

set -eu

work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT

"$LIBRA" init -q --initial-branch=main "$work/repo"
mkdir -p "$work/repo/sub"
printf 'hello\n' >"$work/repo/file1"
printf 'world\n' >"$work/repo/sub/file2"
printf '.*o*\n' >"$work/repo/.libraignore"

cd "$work/repo"
"$LIBRA" grep --no-index --exclude-standard o

cd sub
"$LIBRA" grep --untracked o

The equivalent Git setup uses .gitignore with the same contents.

Actual behavior

At the repository root:

$ libra grep --no-index --exclude-standard o
error: unexpected argument '--exclude-standard' found
Error-Code: LBR-CLI-002
Usage: libra grep --no-index [PATTERN] [PATHS]...

The command exits 129 and produces no matches.

From repo/sub:

$ libra grep --untracked o
file1:hello
sub/file2:world

The command exits 0 but includes a file outside the current subdirectory and uses repository-root-relative paths.

Expected behavior

At the repository root, matching Git:

$ git grep --no-index --exclude-standard o
file1:hello
sub/file2:world

The command should exit 0. --exclude-standard should apply the product's native standard ignore rules, excluding the matching native ignore file.

From repo/sub, matching Git's current-directory scope:

$ git grep --untracked o
file2:world

The command should exit 0, omit root-level file1, and report paths relative to the current subdirectory.

Additional observations

These parts already behave equivalently after mapping the native ignore filenames:

  • grep o: both exit 1 with no output in the new repository.
  • grep --untracked o from the repository root: both output file1:hello and sub/file2:world.
  • grep --no-index o from the repository root: both output the native ignore file plus the two matching content files.
  • grep --no-index o from sub: both output only file2:world.

The original upstream-style Libra run stops earlier because --no-index also sees Libra's automatically generated .libraignore; a native-interface comparison removes that superficial difference and exposes the two behavioral gaps above.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtestvcs

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions