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

Re: [bug] Git submodule command interprets switch as argument and switch

From
Stefan Beller <sbeller@google.com>
Date
Aug 18, 2017, 19:33 UTC
Message-ID
<CAGZ79kb+zuUNNTUb6y9ramEChc5N+vE1mXVxFHEWv6zamEnw7w@mail.gmail.com>
In-Reply-To
<CAAD4mYi24dHNhG1MFkPaeVv9P-9UN_FxSvZmX6XFHrfA7K0hoQ@mail.gmail.com>
On Thu, Aug 17, 2017 at 10:16 PM, R0b0t1 <r030t1@gmail.com> wrote:
Show 9 quoted lines
> The issue is as follows:
>
> R0b0t1@host:~/devel/project$ git submodule add
> https://github.com/user/project -f
> Cloning into '/home/R0b0t1/devel/project/-f'...
>
> My .gitignore's first line is *, and then I explicitly allow things.
> Despite the presence of "project/" in the .gitignore the submodule
> command says it is ignored.

That might indicate that another submodule command doesn't cope with submodule names that look like a common flag.

> The "force" flag is interpreted as a flag
> and also as the destination directory.
>
> It is possible the argument parsing code for other commands exhibits this error.

Yes, though these other commands are in C, not in shell. Note that Prathamesh is currently porting the "git submodule" command to C, which would allow us to fix this bug easily.

Also note that the -f is ambigious, what if the user meant to have the submodule at path "-f" ? (This issue comes up in many other commands, for example when a path and a branch name is accepted, the path of a potentially deleted file.

To solve this git accepts a double dash, which signals git that anything after the double dash there are arguments not to be interpreted as a command line flag.

>
> R0b0t1.
Previous: R0b0t1Next: Jonathan Nieder
Message 2 of 4 in “[bug] Git submodule command interprets switch as argument and switch”
  1. R0b0t1Aug 18, 2017
  2. Stefan BellerAug 18, 2017
  3. Jonathan NiederAug 18, 2017
  4. R0b0t1Aug 18, 2017

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.