-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Git for Windows crash when I try to use git difftool -d on a file added with -N option #2677
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
Comments
I can reproduce, even on Linux (read: this problem is not Windows-specific): diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index e66af3682f8..731ed73f421 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -720,6 +720,14 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' '
test_cmp expect actual
'
+test_expect_success 'add -N and difftool -d' '
+ test_when_finished git reset --hard &&
+
+ test_write_lines A B C >intent-to-add &&
+ git add -N intent-to-add &&
+ git difftool --dir-diff --extcmd ls
+'
+
test_expect_success 'outside worktree' '
echo 1 >1 &&
echo 2 >2 && And this seems to fix it: diff --git a/diff.c b/diff.c
index d1ad6a3c4ad..3503dcdf0db 100644
--- a/diff.c
+++ b/diff.c
@@ -5684,6 +5684,9 @@ static void diff_flush_raw(struct diff_filepair *p, struct diff_options *opt)
int line_termination = opt->line_termination;
int inter_name_termination = line_termination ? '\t' : '\0';
+ diff_fill_oid_info(p->one, opt->repo->index);
+ diff_fill_oid_info(p->two, opt->repo->index);
+
fprintf(opt->file, "%s", diff_line_prefix(opt));
if (!(opt->output_format & DIFF_FORMAT_NAME_STATUS)) {
fprintf(opt->file, ":%06o %06o %s ", p->one->mode, p->two->mode, |
Thanks for the quick fix! :) |
It's not actually a fix because it fails the test suite, pointing out a rather big conceptual problem (I did not figure out how to distinguish between a |
In `run_diff_files()`, files that have been staged with the intention to add are queued without a valid OID in the `diff_filepair`. When the output mode is, say, `DIFF_FORMAT_PATCH`, the `diff_fill_oid_info()` function, called from `run_diff()`, will remedy that situation by reading the file contents from disk. However, when the output mode is `DIFF_FORMAT_RAW`, that does not hold true, and the output will contain a bogus OID (and the flag `M` for "modified" instead of the correct `A` for "added"). As a consequence, `git difftool -d` (which relies on `git diff-files --raw`'s output) does not work correctly. Let's fix this specifically by imitating `diff_fill_oid_info()`. Note: we can only do that for diff formats that do not actually need the file contents, such as `DIFF_FORMAT_PATCH`: `run_diff()` would try to read the blob contents, but that blob might not have been written to Git's object database. This fixes git-for-windows#2677 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. Make sure that the reported `difftool` problem stays fixed. Signed-off-by: Johannes Schindelin <[email protected]>
In `run_diff_files()`, files that have been staged with the intention to add are queued without a valid OID in the `diff_filepair`. When the output mode is, say, `DIFF_FORMAT_PATCH`, the `diff_fill_oid_info()` function, called from `run_diff()`, will remedy that situation by reading the file contents from disk. However, when the output mode is `DIFF_FORMAT_RAW`, that does not hold true, and the output will contain a bogus OID (and the flag `M` for "modified" instead of the correct `A` for "added"). As a consequence, `git difftool -d` (which relies on `git diff-files --raw`'s output) does not work correctly. Let's fix this specifically by imitating `diff_fill_oid_info()`. Note: we can only do that for diff formats that do not actually need the file contents, such as `DIFF_FORMAT_PATCH`: `run_diff()` would try to read the blob contents, but that blob might not have been written to Git's object database. This fixes git-for-windows#2677 This patch _also_ fixes 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. Make sure that the reported `difftool` problem stays fixed. Signed-off-by: Johannes Schindelin <[email protected]>
In `run_diff_files()`, files that have been staged with the intention to add are queued without a valid OID in the `diff_filepair`. When the output mode is, say, `DIFF_FORMAT_PATCH`, the `diff_fill_oid_info()` function, called from `run_diff()`, will remedy that situation by reading the file contents from disk. However, when the output mode is `DIFF_FORMAT_RAW`, that does not hold true, and the output will contain a bogus OID (and the flag `M` for "modified" instead of the correct `A` for "added"). As a consequence, `git difftool -d` (which relies on `git diff-files --raw`'s output) does not work correctly. Let's fix this specifically by imitating `diff_fill_oid_info()`. Note: we can only do that for diff formats that do not actually need the file contents, such as `DIFF_FORMAT_PATCH`: `run_diff()` would try to read the blob contents, but that blob might not have been written to Git's object database. This fixes git-for-windows#2677 This patch _also_ fixes 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]> Signed-off-by: Junio C Hamano <[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. Make sure that the reported `difftool` problem stays fixed. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
In `run_diff_files()`, files that have been staged with the intention to add are queued without a valid OID in the `diff_filepair`. When the output mode is, say, `DIFF_FORMAT_PATCH`, the `diff_fill_oid_info()` function, called from `run_diff()`, will remedy that situation by reading the file contents from disk. However, when the output mode is `DIFF_FORMAT_RAW`, that does not hold true, and the output will contain a bogus OID (and the flag `M` for "modified" instead of the correct `A` for "added"). As a consequence, `git difftool -d` (which relies on `git diff-files --raw`'s output) does not work correctly. Let's fix this specifically by imitating `diff_fill_oid_info()`. Note: we can only do that for diff formats that do not actually need the file contents, such as `DIFF_FORMAT_PATCH`: `run_diff()` would try to read the blob contents, but that blob might not have been written to Git's object database. This fixes git-for-windows#2677 This patch _also_ fixes 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. Make sure that the reported `difftool` problem stays fixed. 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. Make sure that the reported `difftool` problem stays fixed. 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. Make sure that the reported `difftool` problem stays fixed. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[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]>
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]> Signed-off-by: Junio C Hamano <[email protected]>
Just a quick update that gitgitgadget#654 made it into the |
Sounds great. Thank you for the update.
…-Sachin.
On Thu, Jul 2, 2020, 7:58 AM Johannes Schindelin ***@***.***> wrote:
Just a quick update that gitgitgadget#654
<gitgitgadget#654> made it into the next
branch and will hopefully be included in Git v2.28.0. If not, my plan is to
include it in Git *for Windows* v2.28.0, anyway.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2677 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABGY47KBMSM7SHBXMECK6TRZSODHANCNFSM4NZUPQ7A>
.
|
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]>
In #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]>
Won't mind at all.
What do I have to do?
…On Wed, Jul 8, 2020, 6:42 AM Johannes Schindelin ***@***.***> wrote:
@sachinrk <https://github.com/sachinrk> would you mind testing the latest
snapshot <https://wingit.blob.core.windows.net/files/index.html>?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2677 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABGY4376FKZKQQPD6AKI53R2RZUDANCNFSM4NZUPQ7A>
.
|
Just install the latest snapshot and re-test whether the bug you reported is fixed or not ;-) |
Can confirm the issue is resolved with the latest git for windows snapshot d:\RoutingPlane\sources\test\CAFE\NanoProxyTests>git --version d:\RoutingPlane\sources\test\CAFE\NanoProxyTests>notepad++ a.txt d:\RoutingPlane\sources\test\CAFE\NanoProxyTests>git st Untracked files: nothing added to commit but untracked files present (use "git add" to track) d:\RoutingPlane\sources\test\CAFE\NanoProxyTests>git add -N a.txt d:\RoutingPlane\sources\test\CAFE\NanoProxyTests>git st Changes not staged for commit: no changes added to commit (use "git add" and/or "git commit -a") d:\RoutingPlane\sources\test\CAFE\NanoProxyTests>git difftool -d d:\RoutingPlane\sources\test\CAFE\NanoProxyTests>git difftool -d d:\RoutingPlane\sources\test\CAFE\NanoProxyTests> |
In #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]>
Is it possible to port this fix to git used with vfs? specifically - 2.23.0.vfs.1.1 and release an update? |
@sachinrk I believe that the latest VFS release comes with this fix. |
Setup
git version 2.27.0.windows.1
64 bit.
I recently upgraded the git version, but the issue was reproducible on older versions as well.
defaults?
to the issue you're seeing?
Nothing interesting.
Details
CMD
Minimal, Complete, and Verifiable example
this will help us understand the issue.
No crash, and that git would open my difftool with the diff of the file
Crash dialog saying Git for Windows has stopped working
URL to that repository to help us with testing?
Not specific to the repository
The text was updated successfully, but these errors were encountered: