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

Re: [RFC] get_sha1(): :path and :[0-3]:path to extract from index.

From
Uwe Zeisberger <zeisberg@informatik.uni-freiburg.de>
Date
Apr 25, 2006, 08:37 UTC
Message-ID
<20060425083724.GA1663@informatik.uni-freiburg.de>
In-Reply-To
<7v7j5iph7f.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 10 quoted lines
> [ NOTE! The reason I put "RFC" in the subject rather than "PATCH" is that 
>   I'm not 100% sure this isn't just a "shiny object" of mine rather than a 
>   really useful thing to do. What do people think? Have you ever wanted to 
>   access individual files in some random revision? Do you think this is 
>   useful? I think it's cool and _may_ be useful, but I'm not going to 
>   really push this patch. Consider it a throw-away patch unless somebody 
>   else finds it intriguing enough.. ]
> 
> This is a fairly straightforward patch to allow "get_sha1()" to
> also have shorthands for blob objects in the current index.
I sometimes want to have something like that:
	uzeisberger@io:~/gsrc/linux-2.6$ git cat-file blob v2.6.16:Makefile

That is not a shortcut for objects in the current index, but for blobs in written trees.

It's easy to hack a script that does that.  Something like that[1]:
	#! /bin/sh
	eval `echo ${1} | sed 's/\\(.*\\):\\(.*\\)/commit=\"\\1^{}\"; file=\"\\2\"/'`
	tree=`git cat-file commit ${commit} | sed -n 's/tree //p'`
	blob=`git ls-tree -r ${tree} | awk "\\\$4 == \\"${file}\\" { print \\\$3 }"`
	git cat-file blob ${blob}

But if the rev-parser could handle that, that would be much finer. Or is there already a way to do this that I don't know?

Best regards Uwe

[1] It's not tested and probably fails if there are some "bad" characters in ${1} and could be implemented in a much cleverer way.

-- 
Uwe Zeisberger

http://www.google.com/search?q=0+degree+Celsius+in+kelvin
Previous: Junio C HamanoNext: Junio C Hamano
Message 23 of 24 in “[RFC] get_sha1() shorthands for blob/tree objects”
  1. Linus TorvaldsApr 18, 2006
  2. Martin LanghoffApr 19, 2006
  3. Shawn PearceApr 19, 2006
  4. Ray LehtiniemiApr 19, 2006
  5. Junio C HamanoApr 19, 2006
  6. Linus TorvaldsApr 19, 2006
  7. Linus TorvaldsApr 19, 2006
  8. Andreas EricssonApr 19, 2006
  9. Linus TorvaldsApr 19, 2006
  10. Junio C HamanoApr 19, 2006
  11. Linus TorvaldsApr 19, 2006
  12. Linus TorvaldsApr 19, 2006
  13. Junio C HamanoApr 19, 2006
  14. Linus TorvaldsApr 19, 2006
  15. Junio C HamanoApr 19, 2006
  16. Linus TorvaldsApr 19, 2006
  17. Junio C HamanoApr 19, 2006
  18. Linus TorvaldsApr 19, 2006
  19. Martin LanghoffApr 19, 2006
  20. Linus TorvaldsApr 19, 2006
  21. Linus TorvaldsApr 19, 2006
  22. [RFC] get_sha1(): :path and :[0-3]:path to extract from index.Junio C Hamano, Apr 22, 2006
  23. Uwe ZeisbergerApr 25, 2006
  24. Junio C HamanoApr 25, 2006

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.