* git difftool: No such file or directory
@ 2021-06-30 9:38 Alan Blotz
2021-07-01 0:35 ` Đoàn Trần Công Danh
0 siblings, 1 reply; 3+ messages in thread
From: Alan Blotz @ 2021-06-30 9:38 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: git-bugreport-2021-06-30-1117.txt --]
[-- Type: text/plain, Size: 1136 bytes --]
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.
What did you do before the bug happened? (Steps to reproduce your issue)
mkdir broken-diff
cd broken-diff
git init
mkdir dir1
mkdir dir2
touch dir1/orig
cd dir2/
ln -s ../dir1/orig sym
cd ..
git add dir*
git ci -m "init"
git checkout -b b
git rm dir2/sym
git ci -m "remove"
git difftool -d master HEAD
What did you expect to happen? (Expected behavior)
git difftool shall compare both branches.
What happened instead? (Actual behavior)
git difftool prints an error:
fatal: could not open '/tmp/git-difftool.l4UM7e/left/dir2/sym' for writing: No such file or directory
Please review the rest of the bug report below.
You can delete any lines you don't wish to share.
[System Info]
git version:
git version 2.31.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 5.12.12-300.fc34.x86_64 #1 SMP Fri Jun 18 14:30:51 UTC 2021 x86_64
compiler info: gnuc: 11.0
libc info: glibc: 2.33
$SHELL (typically, interactive shell): /bin/bash
[Enabled Hooks]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git difftool: No such file or directory
2021-06-30 9:38 git difftool: No such file or directory Alan Blotz
@ 2021-07-01 0:35 ` Đoàn Trần Công Danh
2021-08-30 0:32 ` David Aguilar
0 siblings, 1 reply; 3+ messages in thread
From: Đoàn Trần Công Danh @ 2021-07-01 0:35 UTC (permalink / raw)
To: Alan Blotz; +Cc: git, Johannes Schindelin
On 2021-06-30 11:38:21+0200, Alan Blotz <work@blotz.org> wrote:
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
>
> mkdir broken-diff
> cd broken-diff
> git init
> mkdir dir1
> mkdir dir2
> touch dir1/orig
> cd dir2/
> ln -s ../dir1/orig sym
> cd ..
> git add dir*
> git ci -m "init"
> git checkout -b b
> git rm dir2/sym
> git ci -m "remove"
> git difftool -d master HEAD
>
> What did you expect to happen? (Expected behavior)
>
> git difftool shall compare both branches.
>
> What happened instead? (Actual behavior)
>
> git difftool prints an error:
>
> fatal: could not open '/tmp/git-difftool.l4UM7e/left/dir2/sym' for writing: No such file or directory
It looks like this behaviour was there from the time difftool was
re-written in C in 03831ef7b5, (difftool: implement the functionality
in the builtin, 2017-01-19). The perl version didn't have this
problem.
The perl version create a file in place of that symlink and write the
symlink's target into that file. The C version tries to write (and
follow?) the symlink.
This hack can fix the problem but I'm not sure it's correct:
----8<---
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 2115e548a5..737ebb5b1a 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -492,12 +492,14 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
if (*entry->left) {
add_path(&ldir, ldir_len, entry->path);
ensure_leading_directories(ldir.buf);
- write_file(ldir.buf, "%s", entry->left);
+ unlink(ldir.buf);
+ write_file_buf(ldir.buf, entry->left, strlen(entry->left));
}
if (*entry->right) {
add_path(&rdir, rdir_len, entry->path);
ensure_leading_directories(rdir.buf);
- write_file(rdir.buf, "%s", entry->right);
+ unlink(rdir.buf);
+ write_file_buf(rdir.buf, entry->right, strlen(entry->right));
}
}
---->8-----
+Cc: Dscho, who wrote the C version.
--
Danh
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: git difftool: No such file or directory
2021-07-01 0:35 ` Đoàn Trần Công Danh
@ 2021-08-30 0:32 ` David Aguilar
0 siblings, 0 replies; 3+ messages in thread
From: David Aguilar @ 2021-08-30 0:32 UTC (permalink / raw)
To: Đoàn Trần Công Danh
Cc: Alan Blotz, Git Mailing List, Johannes Schindelin
On Wed, Jun 30, 2021 at 5:38 PM Đoàn Trần Công Danh
<congdanhqx@gmail.com> wrote:
>
> On 2021-06-30 11:38:21+0200, Alan Blotz <work@blotz.org> wrote:
>
> > Thank you for filling out a Git bug report!
> > Please answer the following questions to help us understand your issue.
> >
> > What did you do before the bug happened? (Steps to reproduce your issue)
> >
> > mkdir broken-diff
> > cd broken-diff
> > git init
> > mkdir dir1
> > mkdir dir2
> > touch dir1/orig
> > cd dir2/
> > ln -s ../dir1/orig sym
> > cd ..
> > git add dir*
> > git ci -m "init"
> > git checkout -b b
> > git rm dir2/sym
> > git ci -m "remove"
> > git difftool -d master HEAD
> >
> > What did you expect to happen? (Expected behavior)
> >
> > git difftool shall compare both branches.
> >
> > What happened instead? (Actual behavior)
> >
> > git difftool prints an error:
> >
> > fatal: could not open '/tmp/git-difftool.l4UM7e/left/dir2/sym' for writing: No such file or directory
>
> It looks like this behaviour was there from the time difftool was
> re-written in C in 03831ef7b5, (difftool: implement the functionality
> in the builtin, 2017-01-19). The perl version didn't have this
> problem.
>
> The perl version create a file in place of that symlink and write the
> symlink's target into that file. The C version tries to write (and
> follow?) the symlink.
>
> This hack can fix the problem but I'm not sure it's correct:
> ----8<---
>
> diff --git a/builtin/difftool.c b/builtin/difftool.c
> index 2115e548a5..737ebb5b1a 100644
> --- a/builtin/difftool.c
> +++ b/builtin/difftool.c
> @@ -492,12 +492,14 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix,
> if (*entry->left) {
> add_path(&ldir, ldir_len, entry->path);
> ensure_leading_directories(ldir.buf);
> - write_file(ldir.buf, "%s", entry->left);
> + unlink(ldir.buf);
> + write_file_buf(ldir.buf, entry->left, strlen(entry->left));
> }
> if (*entry->right) {
> add_path(&rdir, rdir_len, entry->path);
> ensure_leading_directories(rdir.buf);
> - write_file(rdir.buf, "%s", entry->right);
> + unlink(rdir.buf);
> + write_file_buf(rdir.buf, entry->right, strlen(entry->right));
> }
> }
> ---->8-----
>
> +Cc: Dscho, who wrote the C version.
Thank you for tracking this down!
I re-read the original perl version and this indeed looks like it
should do the trick since it's doing the same thing we did in perl.
I'm a little ashamed that we didn't have a test case to cover this use
case but the reproduction recipe you included looks like a great
start. We already have a few tests that use the SYMLINKS test prereq
so this would slot in well there.
--
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-30 0:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 9:38 git difftool: No such file or directory Alan Blotz
2021-07-01 0:35 ` Đoàn Trần Công Danh
2021-08-30 0:32 ` David Aguilar
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).