Subject: Re: [wishlist] git-archive -L

From: René Scharfe <[email-masked]>
Date: Thu, 05 Feb 2009 00:00:18 +0100

René Scharfe schrieb:
> Anyway, I'll try to resurrect my old, incomplete symlink following code,
> but I don't have much time, either. :-/

After a second and a third look I don't see any salvageable parts in the
old code any more.  It was a just prototype that taught me something I
should have been able to find out by thinking alone: that to follow
links within tracked content we can't simply jump to the target, but we
have to walk the whole path step by step.

E.g., consider a repository with these four entries:

	Type	Name	Target
	-------	-------	------
	file	a/f
	symlink	a/x	f
	symlink a/y	../b/f
	symlink	b	a

Let's say our goal is to follow symlinks pointing to tracked content.

We can easily follow "a/x" to get to its target "f" by concatenating the
directory part of the symlink's path ("a/") with the target ("f"), i.e.
we only need to do a simple string operation.

If we do the same for "a/y", we'd arrive at "b/f", which is not a
tracked file by itself, though.  We need to look up each path element
one by one and follow symlinks at each step.  That can't be done with
our existing tree walkers, AFAICS, so we'd need to write a new one.

The decision to follow a link can be made by the callback and passed to
read_tree_recursive() as a return value, with, e.g., READ_TREE_FOLLOW
and READ_TREE_FOLLOW_NON_MATCHES meaning to follow all internal symlinks
and to follow only those whose target doesn't match the specified paths,
respectively.

René