git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philippe <bqobctqyemmeacqxbrsaury3l4ka@quarantine.de>
To: Git mailing list <git@vger.kernel.org>
Subject: difftool fails with dangling symlinks, writes to targets outside of the repository
Date: Fri, 22 Nov 2019 13:37:32 +0100	[thread overview]
Message-ID: <7e04799d-c03c-ac28-604d-ec4d30029d44@quarantine.de> (raw)

Hi all,


I'm using a git repository for configuration management which contains
several dangling symlinks (which only make sense on the to be deployed
system, fwiw). Now, using git 2.23, I ran into a problem regarding the
difftool, which fails when such a symlink is involved in a changeset.

The best way to describe that problem is probably to provide an example.

> #!/bin/bash
> tmp=$(mktemp -d)
> trap "rm -rf ${tmp}" 0 1 2 15
> 
> set -x
> 
> cd ${tmp}
> git init
> ln -s ../doesnot/exist myfile
> git add myfile ; git commit -m "initial checkin" myfile
> 
> git checkout -b mybranch
> rm -f myfile ; echo "foo" > myfile
> git commit -am "typechange"
> 
> git difftool -d master..mybranch

The last call fails with:

> fatal: could not open '/tmp/git-difftool.2wHaR9/left/myfile' for writing: No such file or directory

Neither specifying "--symlinks" nor "--no-symlinks" resolves that.

Playing around with this issue lead me to another strange behaviour.
Difftool might overwrite symlink targets that are not part of the
repository. Please take a look at the following script:

> #!/bin/bash
> tmp=$(mktemp -d)
> trap "rm -rf ${tmp}" 0 1 2 15
> 
> set -x
> 
> echo "hello world" > /tmp/testfile
> cat /tmp/testfile
> 
> cd ${tmp}
> git init
> ln -s /tmp/testfile myfile
> git add myfile ; git commit -m "initial checkin" myfile
> 
> git checkout -b mybranch
> rm -f myfile ; echo "foo" > myfile
> git commit -am "typechange"
> 
> git difftool -d master..mybranch
> 
> cat /tmp/testfile

Here, difftool overwrites the /tmp/testfile's content "hello world" with
"/tmp/testfile".

Did I run into a bug or is it a layer 8 problem?


Regards,

Philippe

             reply	other threads:[~2019-11-22 12:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 12:37 Philippe [this message]
2019-12-02 12:23 ` difftool fails with dangling symlinks, writes to targets outside of the repository Philippe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7e04799d-c03c-ac28-604d-ec4d30029d44@quarantine.de \
    --to=bqobctqyemmeacqxbrsaury3l4ka@quarantine.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).