git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git grep bug with --column and --only-matching

From
BCBrandon Chinn <brandonchinn178@gmail.com>
Date
Apr 21, 2026, 05:03 UTC
Message-ID
<CAGANf=dkRgFp+bEkB5f8QBeiR3m+3WE8sKqT9vKstkGHqbxA3A@mail.gmail.com>

I'm encountering a bug when using `git grep` with both `--column` and `--only-matching`, is this a known limitation?

Repro:

``` $ echo 'x x x' > repro.txt

$ grep -bo x repro.txt 0:x 4:x 8:x

$ git grep --no-index -o -n --column x repro.txt repro.txt:1: 1:x repro.txt:1: 2:x repro.txt:1: 6:x ```

[System Info]
git version:
git version 2.51.1
cpu: arm64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
libcurl: 8.7.1
zlib: 1.2.12
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
default-ref-format: files
default-hash: sha1
uname: Darwin 25.3.0 Darwin Kernel Version 25.3.0: Wed Jan 28 20:56:34
PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T8112 arm64
compiler info: clang: 17.0.0 (clang-1700.0.13.3)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh
Next: René Scharfe
Message 1 of 5 in “git grep bug with --column and --only-matching”
  1. Brandon ChinnApr 21, 2026
  2. René ScharfeApr 21, 2026
  3. Phillip WoodApr 23, 2026
  4. grep: fix --column --only-match for 2nd and later matchesRené Scharfe, Apr 24, 2026
  5. Phillip WoodMay 4, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.