git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: R0b0t1 <r030t1@gmail.com>
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: Re: [bug] Git submodule command interprets switch as argument and switch
Date: Fri, 18 Aug 2017 13:38:58 -0700	[thread overview]
Message-ID: <20170818203858.GK13924@aiede.mtv.corp.google.com> (raw)
In-Reply-To: <CAAD4mYi24dHNhG1MFkPaeVv9P-9UN_FxSvZmX6XFHrfA7K0hoQ@mail.gmail.com>

Hi,

R0b0t1 wrote:

> 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'...

Thanks for reporting.  Confusingly, I think this is intended behavior.
"git help submodule" explains:

	add [-b <branch>] [-f|--force] [--name <name>]
		[--reference <repository>] [--depth <depth>] [--]
		<repository> [<path>]

		Add the given repository as a submodule at the given
		path [etc]

Since the -f comes after <repository>, it is a <path>.

That said, there are a few related things wrong here.

The usage string above says I can put "--" before the <repository> to
make things extra unambiguous.  But when I try that, I get the following
result:

	$ git submodule add -- https://gerrit.googlesource.com/gerrit -f
	Cloning into '/tmp/t/test/-f'...
[...]
	Resolving deltas: 100% (215796/215796), done.
	/usr/lib/git-core/git-submodule: line 261: cd: -f: invalid option
	cd: usage: cd [-L|[-P [-e]] [-@]] [dir]
	Unable to checkout submodule '-f'

If I try to put the "--" between <repository> and <path>, I get another
confusing result:

	$ git submodule add https://gerrit.googlesource.com/gerrit -- -f
	'--' already exists in the index

"git help cli" is supposed to give advice about this kind of thing as
well --- e.g., it gives some sound advice about what form of flags
scripts should use (e.g., to always use the 'stuck' form --name=<name>
instead of --name name).  But it doesn't mention this issue of flags
belonging before other arguments.

Thoughts?

Thanks,
Jonathan

  parent reply	other threads:[~2017-08-18 20:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-18  5:16 [bug] Git submodule command interprets switch as argument and switch R0b0t1
2017-08-18 19:33 ` Stefan Beller
2017-08-18 20:38 ` Jonathan Nieder [this message]
2017-08-18 21:35   ` R0b0t1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170818203858.GK13924@aiede.mtv.corp.google.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=r030t1@gmail.com \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).