Git Mailing List Archive on lore.kernel.org
 help / color / Atom feed
* difftool fails with dangling symlinks, writes to targets outside of the repository
@ 2019-11-22 12:37 Philippe
  2019-12-02 12:23 ` Philippe
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe @ 2019-11-22 12:37 UTC (permalink / raw)
  To: Git mailing list

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: difftool fails with dangling symlinks, writes to targets outside of the repository
  2019-11-22 12:37 difftool fails with dangling symlinks, writes to targets outside of the repository Philippe
@ 2019-12-02 12:23 ` Philippe
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe @ 2019-12-02 12:23 UTC (permalink / raw)
  To: Git mailing list

Hi all,

since that "difftool overwrites files outside of the git
repository"-thingy is apparently not considered a bug, could you please
point me to the correct usage of difftool or a workaround?

To recall the situation:
- git repo contains a symlink pointing outside of the repository to a
non-existing file
- that symlink gets replaced by a regular file
- using 'git difftool -d ${oldstate}..${newstate}' overwrites the file
the symlink was pointing to (which might fail if the target is not writable)

Kind regards

Philippe

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 12:37 difftool fails with dangling symlinks, writes to targets outside of the repository Philippe
2019-12-02 12:23 ` Philippe

Git Mailing List Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/git/0 git/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 git git/ https://lore.kernel.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.git


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git