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

Re: RFC: git cat-file --follow-symlinks?

From
Jeff King <peff@peff.net>
Date
Apr 30, 2015, 01:16 UTC
Message-ID
<20150430011612.GA7530@peff.net>
In-Reply-To
<1430355983.14907.55.camel@ubuntu>
On Wed, Apr 29, 2015 at 06:06:23PM -0700, David Turner wrote:
Show 6 quoted lines
> >   HEAD^{resolve}:foo/bar
> [...]
>
> Just to clarify: if you do git rev-parse, and the result is an
> out-of-tree symlink, you see /foo or ../foo instead of a sha?  And if
> you "git show" it it says "symlink HEAD:../foo"?

I had imagined we would stop resolution and you would just get the last object peeled object. Combined with teaching cat-file to show more object context, doing:

  echo content >dest ;# actual blob
  ln -s dest link    ;# link to blob
  ln -s broken foo   ;# broken link
  ln -s out ../foo   ;# out-of-tree link
  git add . && git commit -m foo
  for i in link broken out; do
	echo HEAD^{resolve}:$i
  done |
  git cat-file --batch="%(intreemode) %(size)"
would yield:
 (1)   100644 8
       content
 (2)   040000 3
       foo
 (3)   040000 6
       ../foo
where the left-margin numbers are for reference:
  1. We dereference a real symlink, and pretend like we actually asked
     for its referent.
  2. For a broken link, we can't dereference, so we return the link
     itself. You can tell by the mode, and the content tells you what
     would have been dereferenced.
  3. Ditto for out-of-tree. Note that this would be the _raw_ symlink
     contents, not any kind of simplification (so if you asked for
     "foo/bar/baz" and it was "../../../../out", you would the full path
     with all those dots, not a simplified "../out", which I think is
     what you were trying to show in earlier examples).
-Peff
Previous: David TurnerNext: Junio C Hamano
Message 13 of 43 in “RFC: git cat-file --follow-symlinks?”
  1. David TurnerApr 29, 2015
  2. Jonathan NiederApr 29, 2015
  3. David TurnerApr 29, 2015
  4. Junio C HamanoApr 29, 2015
  5. David TurnerApr 29, 2015
  6. Jeff KingApr 29, 2015
  7. Jonathan NiederApr 29, 2015
  8. Jeff KingApr 29, 2015
  9. David TurnerApr 29, 2015
  10. Jeff KingApr 29, 2015
  11. Jeff KingApr 30, 2015
  12. David TurnerApr 30, 2015
  13. Jeff KingApr 30, 2015
  14. Junio C HamanoApr 30, 2015
  15. Jeff KingApr 30, 2015
  16. David TurnerApr 30, 2015
  17. Jeff KingApr 30, 2015
  18. Junio C HamanoApr 30, 2015
  19. Michael HaggertyApr 30, 2015
  20. David TurnerApr 30, 2015
  21. Junio C HamanoApr 30, 2015
  22. David TurnerApr 30, 2015
  23. Jeff KingApr 30, 2015
  24. David TurnerApr 30, 2015
  25. Jeff KingApr 30, 2015
  26. David TurnerApr 30, 2015
  27. Jeff KingApr 30, 2015
  28. David TurnerApr 30, 2015
  29. Andreas SchwabApr 30, 2015
  30. Jeff KingApr 30, 2015
  31. Junio C HamanoApr 30, 2015
  32. David TurnerApr 30, 2015
  33. Junio C HamanoApr 30, 2015
  34. Jeff KingApr 30, 2015
  35. Junio C HamanoApr 30, 2015
  36. David TurnerMay 1, 2015
  37. Jeff KingMay 1, 2015
  38. David TurnerMay 1, 2015
  39. Jeff KingMay 1, 2015
  40. David TurnerMay 1, 2015
  41. Junio C HamanoApr 29, 2015
  42. David TurnerApr 29, 2015
  43. Michael HaggertyApr 30, 2015

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.