Skip to content

Fix git difftool with intent-to-add files #2733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2020

Conversation

dscho
Copy link
Member

@dscho dscho commented Jul 3, 2020

This fixes #2677

clickyotomy and others added 3 commits July 3, 2020 23:36
The `diff-files' command and related commands which call the function
`cmd_diff_files()', consider the "intent-to-add" files as a part of the
index when comparing the work-tree against it. This was previously
addressed in commits [1] and [2] by turning the option
`--ita-invisible-in-index' (introduced in [3]) on by default.

For `diff-files' (and `add -p' as a consequence) to show the i-t-a
files as as new, `ita_invisible_in_index' will be enabled by default
here as well.

[1] 0231ae7 (diff: turn --ita-invisible-in-index on by default,
                2018-05-26)
[2] 425a28e (diff-lib: allow ita entries treated as "not yet exist
                in index", 2016-10-24)
[3] b42b451 (diff: add --ita-[in]visible-in-index, 2016-10-24)

Signed-off-by: Srinidhi Kaushik <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
The documented behavior of `git diff-files --raw` is to display

	[...] 0{40} if creation, unmerged or "look at work tree".

on the right hand (i.e. postimage) side. This happens for files that
have unstaged modifications, and for files that are unmodified but
stat-dirty.

For intent-to-add files, we used to show the empty blob's hash instead.
In c26022e (diff: convert diff_addremove to struct object_id,
2017-05-30), we made that worse by inadvertently changing that to the
hash of the empty tree.

Let's make the behavior consistent with files that have unstaged
modifications (which applies to intent-to-add files, too) by showing
all-zero values also for intent-to-add files.

Accordingly, this patch adjusts the expectations set by the regression
test introduced in feea694 (diff-files: treat "i-t-a" files as
"not-in-index", 2020-06-20).

Signed-off-by: Johannes Schindelin <[email protected]>
In git-for-windows#2677, a `git difftool
-d` problem was reported. The underlying cause was a bug in `git
diff-files --raw` that we just fixed: it reported intent-to-add files
with the empty _tree_ as the post-image OID, when we need to show
an all-zero (or, "null") OID instead, to indicate to the caller that
they have to look at the worktree file.

The symptom of that problem shown by `git difftool` was this:

	error: unable to read sha1 file of <path> (<empty-tree-OID>)
	error: could not write '<filename>'

Make sure that the reported `difftool` problem stays fixed.

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho
Copy link
Member Author

dscho commented Jul 7, 2020

I'll merge this even if the respective patches just hit git/git's main branch (and will therefore be in v2.28.0-rc0, due this coming Thursday), mainly for the benefit of building a new snapshot.

@dscho dscho merged commit 51f9af3 into git-for-windows:main Jul 7, 2020
@dscho dscho deleted the difftool-ita-g4w branch July 7, 2020 20:02
git-for-windows-ci pushed a commit that referenced this pull request Jul 7, 2020
Fix `git difftool` with intent-to-add files
git-for-windows-ci pushed a commit that referenced this pull request Jul 7, 2020
Fix `git difftool` with intent-to-add files
dscho added a commit that referenced this pull request Jul 8, 2020
Fix `git difftool` with intent-to-add files
git-for-windows-ci pushed a commit that referenced this pull request Jul 9, 2020
Fix `git difftool` with intent-to-add files
dscho added a commit that referenced this pull request Jul 9, 2020
Fix `git difftool` with intent-to-add files
git-for-windows-ci pushed a commit that referenced this pull request Jul 9, 2020
Fix `git difftool` with intent-to-add files
git-for-windows-ci pushed a commit that referenced this pull request Jul 9, 2020
Fix `git difftool` with intent-to-add files
git-for-windows-ci pushed a commit that referenced this pull request Jul 13, 2020
Fix `git difftool` with intent-to-add files
dscho added a commit that referenced this pull request Jul 17, 2020
Fix `git difftool` with intent-to-add files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Git for Windows crash when I try to use git difftool -d on a file added with -N option
2 participants