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

Weird behaviour of git diff-index in container

From
TFTimo Funke <timoses@msn.com>
Date
May 9, 2022, 22:42 UTC
Message-ID
<VI1PR0402MB28779C7A41783472B2EF6823BFC69@VI1PR0402MB2877.eurprd04.prod.outlook.com>
What did you do before the bug happened? (Steps to reproduce your issue)

mkdir test cd test git init touch test git add test git commit -m 'init' podman run --rm -it -v `pwd`:/git:z --entrypoint sh docker.io/alpine

> container# apk add git
> container# cd /git
> container# git diff-index --quiet HEAD -- ; echo $?
1
> container# git diff-index --quiet HEAD -- ; echo $?
1
> container# git status

On branch master nothing to commit, working tree clean

> container# git diff-index --quiet HEAD -- ; echo $?
0

What did you expect to happen? (Expected behavior) `git diff-index --quiet HEAD -- ; echo $?` should return `0` even without executing `git status`.

What happened instead? (Actual behavior) Without executing `git status` `git diff-index --quiet HEAD -- ; echo $?` will repeatedly print `1`.

What's different between what you expected and what actually happened? It is odd that `git diff-index --quiet HEAD -- ; echo $?` prints different results depending on whether `git status` was executed.

Anything else you want to add: Perhaps this has to do with running git in a container?

[System Info] git version: git version 2.34.2 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 4.18.0-348.20.1.el8_5.x86_64 #1 SMP Thu Mar 10 20:59:28 UTC 2022 x86_64 compiler info: gnuc: 10.3 libc info: no libc information available $SHELL (typically, interactive shell): <unset>

[Enabled Hooks] not run from a git repository - no hooks to show

Next: Junio C Hamano
Message 1 of 4 in “Weird behaviour of git diff-index in container”
  1. Timo FunkeMay 9, 2022
  2. Junio C HamanoMay 9, 2022
  3. Jonathan NiederMay 10, 2022
  4. Junio C HamanoMay 10, 2022

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.