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

Git segfaults with diff.external and comparing files with different permissions

From
WHWilfred Hughes <me@wilfred.me.uk>
Date
Jan 28, 2024, 20:24 UTC
Message-ID
<CAFXAjY7XcL1APhLRXU8TO96z=f7957f2ieK56dHVsXUay55vpg@mail.gmail.com>
Hi folks

It looks like git crashes if diff.external is set and the user compares files that have different permissions. Here's a repro:

$ mkdir demo $ cd demo $ git init . Initialized empty Git repository in /tmp/demo/.git/

$ git config diff.external /bin/echo $ touch foo bar $ chmod 755 foo $ git diff --no-ext-diff --no-index foo bar

diff --git 1/foo 2/bar
old mode 100755
new mode 100644

$ git diff --no-index foo bar
zsh: segmentation fault (core dumped)  git diff --no-index foo bar

This was originally reported as a difftastic bug[1] but it seems to
occur regardless of the value of diff.external, hence my repro with
/bin/echo.

[1] https://github.com/Wilfred/difftastic/issues/615

[System Info]
git version:
git version 2.43.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 6.7.0-zen3-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Sat, 13 Jan
2024 14:36:54 +0000 x86_64
compiler info: gnuc: 13.2
libc info: glibc: 2.38
$SHELL (typically, interactive shell): /bin/zsh

Thanks
Wilfred
Next: Jeff King
Message 1 of 5 in “Git segfaults with diff.external and comparing files with different permissions”
  1. Wilfred HughesJan 28, 2024
  2. diff: handle NULL meta-info when spawning external diffJeff King, Jan 29, 2024
  3. Junio C HamanoJan 29, 2024
  4. Jeff KingJan 30, 2024
  5. Junio C HamanoJan 30, 2024

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.