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

Re: [PATCH 8/8] git-gc --auto: run "repack -A -d -l" as necessary.

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 18, 2007, 02:59 UTC
Message-ID
<20070918025926.GI3099@spearce.org>
In-Reply-To
<1190018716666-git-send-email-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> wrote:
Show 19 quoted lines
> +static int too_many_packs(void)
> +{
> +	struct packed_git *p;
> +	int cnt;
> +
> +	if (gc_auto_pack_limit <= 0)
> +		return 0;
> +
> +	for (cnt = 0, p = packed_git; p; p = p->next) {
> +		char *suffix;
> +		int keep;
> +		if (!p->pack_local)
> +			continue;
> +		suffix = p->pack_name + strlen(p->pack_name) - 5;
> +		if (memcmp(suffix, ".pack", 6))
> +			continue;
> +		memcpy(suffix, ".keep", 6);
> +		keep = access(p->pack_name, F_OK) && (errno == ENOENT);
> +		memcpy(suffix, ".pack", 6);

*rubs eyes* Am I reading that right? You are modifying pack_name in the middle of this function? WHY is pack_name not const char*? *sigh*. I'd NEVER consider doing that. Not in a million years. Because someday someone is going to make a change that's going to break that somehow, like by jumping out of this loop early and not fixing pack_name up first.

Yea, sure, there's no way today that this would fail. But I like to think that some poor sap is going to have to read my code after I write it and that they should not be forced to deal with stuff like this when such a time comes.

-- 
Shawn.
Previous: Junio C Hamano
Message 18 of 18 in “Export matches_pack_name() and fix its return value”
  1. 1/8 Export matches_pack_name() and fix its return valueJunio C Hamano, Sep 17, 2007
  2. 2/8 pack-objects --keep-unreachableJunio C Hamano, Sep 17, 2007
  3. 3/8 repack -A -d: use --keep-unreachable when repackingJunio C Hamano, Sep 17, 2007
  4. Johannes SchindelinSep 17, 2007
  5. Andreas EricssonSep 17, 2007
  6. Shawn O. PearceSep 18, 2007
  7. 4/8 git-gc --auto: move threshold check to need_to_gc() function.Junio C Hamano, Sep 17, 2007
  8. 5/8 git-gc --auto: add documentation.Junio C Hamano, Sep 17, 2007
  9. Johannes SchindelinSep 17, 2007
  10. Junio C HamanoSep 17, 2007
  11. 6/8 git-gc --auto: protect ourselves from accumulated cruftJunio C Hamano, Sep 17, 2007
  12. 7/8 git-gc --auto: restructure the way "repack" command line is built.Junio C Hamano, Sep 17, 2007
  13. Johannes SchindelinSep 17, 2007
  14. Junio C HamanoSep 17, 2007
  15. 8/8 git-gc --auto: run "repack -A -d -l" as necessary.Junio C Hamano, Sep 17, 2007
  16. Johannes SchindelinSep 17, 2007
  17. Junio C HamanoSep 17, 2007
  18. Shawn O. PearceSep 18, 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.