bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: diff: bad treatment of symlinks


From: John Cowan
Subject: Re: diff: bad treatment of symlinks
Date: Tue, 18 Oct 2011 11:08:10 -0400
User-agent: Mutt/1.5.18 (2008-05-17)

Andries E. Brouwer scripsit:

> A symlink is a small file that contains a filename.

I disagree.  The fact that symlinks are implemented as files is an
accident.  They could be implemented as logical relations in kernel
or user memory, as is done for mounts, for example.  This is what
is done on Plan 9, where the filesystem is purely hierarchical.

> This means that diff should never use the contents of the
> symlink target. (Maybe when the two files to be compared
> are given as command parameters, depending on option flags,
> but certainly not in a recursive diff of two trees.)

To say that "diff foo1 foo2", where foo1 or foo2 are symlinks,
should report the symlink status is to say that "cat foo", where
foo is a symlink, should print the contents of the symlink.  To
take that view would make symlinks useless.

> This means that diff must report a difference when comparing
> a file to a symlink, even when the symlink points to a file
> with the same contents.

That follows from your premises, but I deny your premises.

> For example, tar will create symlinks as empty mode 0 files,
> only to fix them later. If the tar crashes, there will be
> many empty mode 0 files. A diff between the original hierarchy
> and the untarred hierarchy must not mention the contents of
> the symlink target, but just say
> 
> a/foo is an empty mode 0 file while b/foo is a symlink to bar.

That is because the implementation of tar is inadequate to the
symlink situation.  Tar could, for example, topologically sort files
before creating them, so that the target of a symlink always exists
before the symlink does.

I strongly urge retention of the status quo.

-- 
John Cowan   address@hidden    http://ccil.org/~cowan
I come from under the hill, and under the hills and over the hills my paths
led. And through the air. I am he that walks unseen.  I am the clue-finder,
the web-cutter, the stinging fly. I was chosen for the lucky number.  --Bilbo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]