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

interaction between git-diff-index and git-apply

From
ADAriel Davis <ariel.z.davis@icloud.com>
Date
Jan 22, 2017, 19:09 UTC
Message-ID
<C45218A3-8A81-4307-AADB-FBA4F51EAC51@icloud.com>
Hello,

I have noticed an interesting interaction between git-diff-index and git-apply. Essentially, it seems that if we start with a clean working tree, then git-apply a patch, then git-apply the reverse of that patch, git-diff-index still thinks files are modified. But then, if we git-status, git-diff-index seems to "realize" the files are actually not modified.

Below are steps to reproduce, as well as information about my machine, which I discovered this behavior on.

Reproduction instructions:

$ mkdir -p test/repo $ cd test/repo $ git init -q $ echo 1 > file $ git add file $ git commit -qm 1 $ echo 2 >> file $ git add file $ git commit -qm 2 $ git diff @~ > ../patch $ git apply --reverse ../patch $ git diff-index --name-only @ file $ git apply ../patch $ git diff-index --name-only @ file $ git status On branch master nothing to commit, working tree clean $ git diff-index --name-only @ $ echo hmm hmm

System information:
$ uname -a
Darwin azdavis-mbp 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST
2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64 i386 MacBookPro12,1 Darwin
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.12.2
BuildVersion:   16C67
$ git --version
git version 2.11.0
Thank you for your time.
Ariel Davis
Next: Junio C Hamano
Message 1 of 2 in “interaction between git-diff-index and git-apply”
  1. Ariel DavisJan 22, 2017
  2. Junio C HamanoJan 22, 2017

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.