git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [wishlist] git-archive -L

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Feb 4, 2009, 23:00 UTC
Message-ID
<498A1E02.6020707@lsrfire.ath.cx>
In-Reply-To
<4987FC03.60607@lsrfire.ath.cx>
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é
Previous: René ScharfeNext: Pierre Habouzit
Message 3 of 4 in “[wishlist] git-archive -L”
  1. Pierre HabouzitFeb 2, 2009
  2. René ScharfeFeb 3, 2009
  3. René ScharfeFeb 4, 2009
  4. Pierre HabouzitFeb 5, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.