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

Re: [PATCH] Convert emailing part of hooks--update to hooks--post-receive

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Mar 24, 2007, 16:12 UTC
Message-ID
<Pine.LNX.4.64.0703240858370.6730@woody.linux-foundation.org>
In-Reply-To
<200703241550.05590.andyparkins@gmail.com>
On Sat, 24 Mar 2007, Andy Parkins wrote:
> 
> Oh dear; I had no idea that packed refs made the ref file itself 
> disappear.
Everybody should do
	git pack-refs --all --prune

occasionally to see this. In fact, I think we should probably make that part of "git gc" (which currently doesn't pack branches at all, just tags, since it omits the "--all").

Show 5 quoted lines
> Would
> 
>  git-rev-parse $refname
> 
> Be a better way of getting the revision?
That's always the correct way to get a revision, although you should use
	git-rev-parse --verify "$refname"^0

to make sure that you get a commit (of course, if you don't want a commit, but any random ref-SHA1, remove the "^0" from the end!).

HOWEVER. "git-rev-parse" will take any arbitrary SHA1-expression, which may or may not be what you want. If you actually also want to verify that it's strictly a branch name (or other ref-name), rather than just a random SHA1 expression, you should do

	git show-ref [--verify] refname

where the "--verify" again enables strict checking. HOWEVER, it will not check that it's a commit, so if you need the resulting SHA1 to be of a specific type, you need to do that separately.

Side note: those two "--verify" calls do two different kinds of strict checking, because "show-ref" and "rev-parse" are different things. In "git-rev-parse" it checks that the argument is exactly *one* SHA1 value, and not some flag or a SHA1 range. Because "git rev-parse" can take a lot of different input formats. In contrast, in "git show-ref", the stricter checking enabled by "--verify" will just force it to not do any "pattern" for the ref, but it wants an *exact* refname.

		Linus
Previous: Andy ParkinsNext: Junio C Hamano
Message 4 of 11 in “Convert emailing part of hooks--update to hooks--post-receive”
  1. Convert emailing part of hooks--update to hooks--post-receiveAndy Parkins, Mar 23, 2007
  2. Junio C HamanoMar 24, 2007
  3. Andy ParkinsMar 24, 2007
  4. Linus TorvaldsMar 24, 2007
  5. Junio C HamanoMar 25, 2007
  6. Junio C HamanoMar 25, 2007
  7. Junio C HamanoMar 25, 2007
  8. Andy ParkinsMar 25, 2007
  9. Junio C HamanoMar 25, 2007
  10. Reimplement emailing part of hooks--update in contrib/hooks/post-receive-emailAndy Parkins, Mar 30, 2007
  11. Jakub NarebskiMar 31, 2007

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.