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

[PATCH 2/3] submodule deinit: lose requirement for giving '.'

From
Stefan Beller <sbeller@google.com>
Date
May 2, 2016, 22:24 UTC
Message-ID
<1462227844-10624-3-git-send-email-sbeller@google.com>
In-Reply-To
<1462227844-10624-1-git-send-email-sbeller@google.com>

The discussion in [1] realized that '.' is a faulty suggestion as there is a corner case where it fails:

Show 14 quoted lines
> "submodule deinit ." may have "worked" in the sense that you would
> have at least one path in your tree and avoided this "nothing
> matches" most of the time.  It would have still failed with the
> exactly same error if run in an empty repository, i.e.
>
>        $ E=/var/tmp/x/empty && rm -fr "$E" && mkdir -p "$E" && cd "$E"
>        $ git init
>        $ 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

Allow no argument for `submodule deinit` to mean all submodules and add a test to check for the corner case of an empty repository.

There is no need to update the documentation as it did not describe the special case '.' to remove all submodules.

[1] http://news.gmane.org/gmane.comp.version-control.git/289535
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 git-submodule.sh           | 5 -----
 t/t7400-submodule-basic.sh | 5 ++++-
 2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 82e95a9..d689265 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -428,11 +428,6 @@ cmd_deinit()
 		shift
 	done
 
-	if test $# = 0
-	then
-		die "$(eval_gettext "Use '.' if you really want to deinitialize all submodules")"
-	fi
-
 	git submodule--helper list --prefix "$wt_prefix" "$@" |
 	while read mode sha1 stage sm_path
 	do
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 90d80d3..9af47b5 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -11,6 +11,10 @@ subcommands of git submodule.
 
 . ./test-lib.sh
 
+test_expect_success 'submodule deinit works on empty repository' '
+	git submodule deinit
+'
+
 test_expect_success 'setup - initial commit' '
 	>t &&
 	git add t &&
@@ -948,7 +952,6 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '
 	git submodule update --init &&
 	git config submodule.example.foo bar &&
 	git config submodule.example2.frotz nitfol &&
-	test_must_fail git submodule deinit &&
 	git submodule deinit . >actual &&
 	test -z "$(git config --get-regexp "submodule\.example\.")" &&
 	test -z "$(git config --get-regexp "submodule\.example2\.")" &&
-- 
2.8.0.37.gb114fff.dirty
Previous: Stefan BellerNext: Junio C Hamano
Message 5 of 17 in “preparatory patches for the submodule groups”
  1. 0/3 preparatory patches for the submodule groupsStefan Beller, May 2, 2016
  2. 1/3 submodule deinit test: fix broken && chain in subshellStefan Beller, May 2, 2016
  3. Junio C HamanoMay 3, 2016
  4. Stefan BellerMay 3, 2016
  5. 2/3 submodule deinit: lose requirement for giving '.'Stefan Beller, May 2, 2016
  6. Junio C HamanoMay 3, 2016
  7. Stefan BellerMay 3, 2016
  8. Junio C HamanoMay 3, 2016
  9. Stefan BellerMay 3, 2016
  10. 3/3 submodule init: redirect stdout to stderrStefan Beller, May 2, 2016
  11. Junio C HamanoMay 3, 2016
  12. Stefan BellerMay 3, 2016
  13. Junio C HamanoMay 3, 2016
  14. Stefan BellerMay 3, 2016
  15. Junio C HamanoMay 3, 2016
  16. Stefan BellerMay 3, 2016
  17. Junio C HamanoMay 3, 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.