On Mon, Nov 18, 2024 at 11:02:06AM -0800, Jonathan Tan wrote: > Currently, Git uses "index-pack --promisor" only when fetching into > a repo, so it could be argued that we should teach "index-pack" a new > argument (say, "--fetching-mode") instead of tying --promisor to a > generic argument like "--stdin". However, this --promisor feature could > conceivably be used whenever we have a packfile that is known to come > from the promisor remote (whether obtained through Git's fetch protocol > or through other means) so it seems reasonable to use --stdin here - > one could envision a user-made script obtaining a packfile and then > running "index-pack --promisor --stdin", for example. In fact, it might > be possible to relax the restriction further (say, by also allowing > --promisor when indexing a packfile that is in the object DB), but > relaxing the restriction is backwards-compatible so we can revisit that > later. Yeah, I agree with this summary. > This change requires the change to t5300 by 1f52cdfacb (index-pack: > document and test the --promisor option, 2022-03-09) to be undone. > (--promisor is already tested indirectly, so we don't need the explicit > test here any more.) OK, I think this is reasonable. > Looking into it further, I think that we also need to require no > packfile name to be given (so that we are writing the file to the > repository). Therefore, I've added that requirement both in the code and > in the documentation. Hmm. I didn't realize that you could specify a pack name _and_ --stdin, but I guess it makes sense if you wanted to write the result to a non-standard location (though curiously --stdin requires a repo, which feels overly restrictive if you give a pack name). But I think that makes the --stdin check redundant. I.e., here: > diff --git a/builtin/index-pack.c b/builtin/index-pack.c > index 08b340552f..c46b6e4061 100644 > --- a/builtin/index-pack.c > +++ b/builtin/index-pack.c > @@ -1970,6 +1970,10 @@ int cmd_index_pack(int argc, > usage(index_pack_usage); > if (fix_thin_pack && !from_stdin) > die(_("the option '%s' requires '%s'"), "--fix-thin", "--stdin"); > + if (promisor_msg && !from_stdin) > + die(_("the option '%s' requires '%s'"), "--promisor", "--stdin"); > + if (promisor_msg && pack_name) > + die(_("--promisor cannot be used with a pack name")); ...just the second one would be sufficient, because the context just above this has: if (!pack_name && !from_stdin) usage(index_pack_usage); So if there isn't a pack name then from_stdin must be set anyway. What you've written won't behave incorrectly, but I wonder if this means we can explain the rule in a more simple way: - the --promisor option requires that we be indexing a pack in the object database - when not given a pack name on the command line, we know this is true (because we generate the name ourselves internally) - when given a pack name on the command line, we _could_ check that it is inside the object directory, but we don't currently do so and just bail. That could be changed in the future. And then there is no mention of --stdin at all (though of course it is an implication of the second point, since we have to get input somehow). -Peff