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

Re: [PATCHv2] submodule deinit: require '--all' instead of '.' for all submodules

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 4, 2016, 00:47 UTC
Message-ID
<20160504004759.GB395@google.com>
In-Reply-To
<1462321992-15153-1-git-send-email-sbeller@google.com>
Stefan Beller wrote:
[...]
Show 10 quoted lines
>>        $ rungit v2.6.6 submodule deinit .
>>        error: pathspec '.' did not match any file(s) known to git.
>>        Did you forget to 'git add'?
>>        $ >file && git add file
>>        $ rungit v2.6.6 submodule deinit .
>>        $ echo $?
>>        0
>
> So instead of a path spec add a parameter '--all' to deinit all submodules
> and add a test to check for the corner case of an empty repository.
Makes sense.
[...]
> It is a fix for a corner case, but it is renaming the switch, so I would
> expect that we'd wait for a new version at least.

The bug was that the documentation and error message gave advice that didn't work.

[...]
Show 21 quoted lines
> +++ b/Documentation/git-submodule.txt
> @@ -13,7 +13,7 @@ SYNOPSIS
>  	      [--reference <repository>] [--depth <depth>] [--] <repository> [<path>]
>  'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
>  'git submodule' [--quiet] init [--] [<path>...]
> -'git submodule' [--quiet] deinit [-f|--force] [--] <path>...
> +'git submodule' [--quiet] deinit [-f|--force] [-a|--all] [--] <path>...
>  'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch]
>  	      [-f|--force] [--rebase|--merge] [--reference <repository>]
>  	      [--depth <depth>] [--recursive] [--] [<path>...]
> @@ -144,6 +144,11 @@ deinit::
>  	you really want to remove a submodule from the repository and commit
>  	that use linkgit:git-rm[1] instead.
>  +
> +	To unregister all submodules use `--all` with no path spec. In
> +	version 2.8 and prior, you were advised to give '.' to unregister
> +	all submodules. This may continue to work in the future, but as the
> +	path spec '.' may include regular files, this could stop working.
> ++
>  If `--force` is specified, the submodule's work tree will be removed even if
>  it contains local modifications.
Inconsistent indentation.  Does asciidoc format this correctly?
[...]
> +++ b/git-submodule.sh
> @@ -521,6 +521,7 @@ cmd_init()
[...]
Show 8 quoted lines
>  		shift
>  	done
>  
> -	if test $# = 0
> +	if test -n "$deinit_all" && test "$#" -ne 0
> +	then
> +		die "$(eval_gettext "'--all' is incompatible with pathspec arguments")"
> +	fi

This message is giving implementation details. Most other git commands just dump usage when passed too many arguments --- perhaps we can do something more targeted like the following:

	die "$(eval_gettext "usage: $dashless [--quiet] deinit [-f|--force] (--all | [--] <path>...)")"

Speaking of which: please also update the USAGE string at the top of git-submodule.sh.

[...]
> --- a/t/t7400-submodule-basic.sh
> +++ b/t/t7400-submodule-basic.sh
Makes sense.
Thanks for a pleasant fix.
Jonathan
Previous: Stefan BellerNext: Stefan Beller
Message 8 of 17 in “submodule deinit: require '--all' instead of '.' for all submodules”
  1. submodule deinit: require '--all' instead of '.' for all submodulesStefan Beller, May 3, 2016
  2. Junio C HamanoMay 3, 2016
  3. Junio C HamanoMay 3, 2016
  4. Stefan BellerMay 3, 2016
  5. Junio C HamanoMay 3, 2016
  6. Stefan BellerMay 3, 2016
  7. [PATCHv2] submodule deinit: require '--all' instead of '.' for all submodulesStefan Beller, May 4, 2016
  8. Jonathan NiederMay 4, 2016
  9. [PATCHv3] submodule deinit: require '--all' instead of '.' for all submodulesStefan Beller, May 4, 2016
  10. Junio C HamanoMay 4, 2016
  11. Stefan BellerMay 4, 2016
  12. Junio C HamanoMay 4, 2016
  13. Stefan BellerMay 4, 2016
  14. Junio C HamanoMay 4, 2016
  15. Junio C HamanoMay 4, 2016
  16. Stefan BellerMay 4, 2016
  17. Junio C HamanoMay 4, 2016

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.