On Tue, Jul 13, 2021 at 05:13:40PM -0400, Jeff King wrote: > On Tue, Jul 13, 2021 at 04:57:46PM +0800, Jiang Xin wrote: > > > > Though in my experience it is usually a static "--not --all" or "--not > > > --branches --tags" or similar in such a function. I don't think I've > > > ever seen a case quite like the code above in practice. > > > > Last week, I made a study on how gitlab wrap and execute a git > > command. I saw the following code [1]: > > > > if c.supportsEndOfOptions() { > > commandArgs = append(commandArgs, "--end-of-options") > > } > > if len(postSepArgs) > 0 { > > commandArgs = append(commandArgs, "--") > > } > > > > I was surprised to see the options "--end-of-options" and "--" used > > next to each other, and the DashDash option ("--") is not mandatory. > > I think using --end-of-options there is pointless. The "--" will always > signal the end of options (_and_ revisions). So if there is nothing > between the two, then the former cannot be doing anything. Indeed it is. I somehow missed your Cc (not used to receiving Git ML mails on my work address), but by chance I fixed this last week because I realized this was broken. We've now moved the `--end-of-options` flag between positional arguments and flags like it should've been from the beginning [1]. [snip] > > But if I move the "--end-of-options" before the revisions like this: > > > > git log --stat --pretty="%m %s" --no-decorate \ > > --end-of-options \ > > topic1 --not main release \ > > -- \ > > src/hello.c doc > > > > The generated command failed to execute with error: unknown revision "--not". > > > > It's reasonable for gitlab to construct git commands using mainly three fields: > > 1. Flags: for options like "--option", or "--key value". > > 2. Args: for args like revisions. > > 3. PostSepArgs: for pathspecs. > > > > And if the command supports these options, it's better to add > > "--end-of-options" between 1 and 2, and add "--" between 2 and 3. > > Yeah, so the problem there is that the definition of "Args" is kind of > fuzzy. Sometimes it is useful to include stuff like "--not", and > sometimes it is dangerous or unexpected. Later you say: Yeah, this is something that has been bothering me, too. It would be nice to give special treatment to pseudo-revisions in git. That's why we have now marked git-rev-list(1) to not support `--end-of-options` in Gitaly, because we do pass pseudo-revisions to it in multiple places. Patrick [1]: https://gitlab.com/gitlab-org/gitaly/-/merge_requests/3676
Attachment:
signature.asc
Description: PGP signature