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

Re: [PATCH] Change "refs/" references to symbolic constants

From
APAndy Parkins <andyparkins@gmail.com>
Date
Oct 3, 2007, 07:37 UTC
Message-ID
<200710030837.25689.andyparkins@gmail.com>
In-Reply-To
<20071002204848.GA8284@coredump.intra.peff.net>
On Tuesday 2007 October 02, Jeff King wrote:
> Perhaps a better quest would be to eliminate all of those counts
> entirely with code that is obviously correct. I think it is much more
> readable to replace:

I've got a patch replacing every appropriate memcmp() with prefixcmp(), but it goes on top of this one, so wanted to get this through review to save constantly spamming the list with the same patch slightly modified because of changes in a different patch.

Show 7 quoted lines
>   url = xmalloc(strlen(repo->base) + 64);
>   sprintf(url, "%s/objects/pack/pack-%s.idx", repo->base, hex);
>
> with something like:
>
>   strbuf_init(&url);
>   strbuf_addf(&url, "%s/objects/pack/pack-%s.idx", repo->base, hex);

I've not been following the strbuf() changes, so have missed the appearance of these handy new functions. They would appear to be an improvement for cases just like this.

> > constants in CAPITAL_LETTERS_WITH_UNDERSCORE shout too loudly to
>
> Part of the problem is also that they're long. Perhaps REFS_HEADS, while
> being less unique in the C namespace, would look better?

I completely agree with the length and loudness concerns, but my worry was polluting the namespace while maintaining some sort of rationality between PATH_REFS_HEADS and STRLEN_PATH_REFS_HEADS. My reasoning was that

 "refs/heads" -> PATH_REFS_HEADS
is only three extra characters, and
 strlen("refs/heads/") -> STRLEN_PATH_REFS_HEADS
is only one extra character.
However I have no strong feelings about changing them.
Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Previous: Andreas EricssonNext: Andy Parkins
Message 15 of 19 in “Change "refs/" references to symbolic constants”
  1. 1/2 Change "refs/" references to symbolic constantsAndy Parkins, Sep 29, 2007
  2. Andy ParkinsOct 1, 2007
  3. Jeff KingOct 2, 2007
  4. Andy ParkinsOct 2, 2007
  5. Jeff KingOct 2, 2007
  6. Change "refs/" references to symbolic constantsAndy Parkins, Oct 2, 2007
  7. Jeff KingOct 2, 2007
  8. Junio C HamanoOct 2, 2007
  9. Jeff KingOct 2, 2007
  10. Junio C HamanoOct 3, 2007
  11. Jeff KingOct 3, 2007
  12. Johannes SchindelinOct 3, 2007
  13. Jeff KingOct 3, 2007
  14. Andreas EricssonOct 3, 2007
  15. Andy ParkinsOct 3, 2007
  16. Andy ParkinsOct 3, 2007
  17. Andy ParkinsOct 3, 2007
  18. Junio C HamanoOct 2, 2007
  19. Andy ParkinsOct 3, 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.