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

Re: [PATCH] drop support for "experimental" loose objects

From
Jeff King <peff@peff.net>
Date
Nov 22, 2013, 16:15 UTC
Message-ID
<20131122161558.GA4170@sigill.intra.peff.net>
In-Reply-To
<CAP8UFD1z4NsmgzrnPmqHo7CkNRkgg24qT2SGnFjhjrzckdKoTQ@mail.gmail.com>
On Fri, Nov 22, 2013 at 03:23:31PM +0100, Christian Couder wrote:
Show 9 quoted lines
> > The only site which calls read_sha1_file_extended directly and does not
> > pass the REPLACE flag is in streaming.c. And that looks to be a case of
> > (2), since we resolve the replacement at the start in open_istream().
> 
> Yeah, you are right. Sorry for overlooking this.
> 
> But anyway it looks redundant to me to have both this REPLACE flag and
> the read_replace_refs global variable, so I think a proper solution
> would involve some significant refactoring.

I don't think it is redundant. The global variable is about "does the whole operation want the replace feature turned on" and the flag is about "does this particular callsite want the replace featured turned on". We use the feature iff both are true.

We could implement the callsite flag by tweaking the global right before the call to read_sha1_file, but then we would have to remember to turn it back on afterwards. If this were a language with dynamic scopes like Perl, that would be easy. But in C you have to remember to reset it in all code paths. :)

In some cases it does make sense to turn the feature off for a whole command (like pack-objects); using the global makes sense there. And indeed, we seem to do it already in things like fsck, index-pack, etc. So that answers my question of why I did not see more of case (1) in my previous email: they do not need per-callsite disabling, because they do it for the whole command.

> And if we decide to keep a REPLACE flag we might need to add one to
> sha1_object_info_extended() too.

Yes, but somebody needs to look at all of the callsites and decide which form they want. :)

I did a brief skim, and the ones I noticed were:
  - several spots in index-pack, pack-objects, etc. But these are
    already covered by unsetting read_replace_refs.
  - replace_object looks at both the original and new object to compare
    their types (due to your recent patches); it would obviously want to
    get the true type of the original object
  - When creating tags and trees, we care about the type of the object
    (the former for the "type" line of the tag, the latter to set the
    mode). What should they do with replace objects? As above, it is
    probably insane to switch types, so it may not matter for practical
    purposes.
  - istream_source in streaming.c would probably want to turn it off for
    the same reason it uses read_sha1_file_extended

So I think most sites would be unaffected, but due to the second and fourth item in my list above, we would need a flag for sha1_object_info_extended.

-Peff
Previous: Christian CouderNext: Junio C Hamano
Message 19 of 28 in “corrupt object memory allocation error”
  1. Joey HessNov 20, 2013
  2. Jeff KingNov 20, 2013
  3. Joey HessNov 20, 2013
  4. drop support for "experimental" loose objectsJeff King, Nov 21, 2013
  5. Jeff KingNov 21, 2013
  6. Duy NguyenNov 21, 2013
  7. Keshav KiniNov 21, 2013
  8. Jeff KingNov 21, 2013
  9. Junio C HamanoNov 21, 2013
  10. Jonathan NiederNov 23, 2013
  11. Jeff KingNov 23, 2013
  12. Jonathan NiederNov 23, 2013
  13. Joey HessNov 21, 2013
  14. Christian CouderNov 21, 2013
  15. Jeff KingNov 22, 2013
  16. Christian CouderNov 22, 2013
  17. Jeff KingNov 22, 2013
  18. Christian CouderNov 22, 2013
  19. Jeff KingNov 22, 2013
  20. Junio C HamanoNov 22, 2013
  21. Jeff KingNov 22, 2013
  22. Joey HessNov 22, 2013
  23. Jeff KingNov 24, 2013
  24. Jeff KingNov 24, 2013
  25. Junio C HamanoNov 25, 2013
  26. Jeff KingNov 27, 2013
  27. Junio C HamanoNov 27, 2013
  28. Jeff KingNov 27, 2013

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.