From: Stefan Beller <hidden> Date: 2016-06-16 02:19:05
Patch 1 was send outside of a series already.
Patch 2 and 3 are preparatory things for the submodule groups stuff
patches 4-9 are making the output of the submodule command consistent
(similar to patch 3, but I do not foresee a need for it yet)
Patch 10 is a controversial thing I'd assume as it breaks existing users.
We should take it for the next major release (i.e. 3.0)
I just want to put it out here now.
Thanks,
Stefan
Stefan Beller (10):
submodule deinit test: fix broken && chain in subshell
submodule deinit: lose requirement for giving '.'
submodule init: redirect stdout to stderr
shell helpers usage: always send help to stderr
submodule add: send messages to stderr
submodule deinit: send messages to stderr
submodule foreach: send messages to stderr
submodule update: send messages to stderr
submodule sync: send messages to stderr
submodule deinit: complain when given a file instead of a submodule
builtin/submodule--helper.c | 9 +++++----
git-sh-setup.sh | 2 +-
git-submodule.sh | 21 ++++++++-------------
t/t7400-submodule-basic.sh | 38 +++++++++++++++++++++++++-------------
t/t7403-submodule-sync.sh | 4 ++--
t/t7406-submodule-update.sh | 23 ++++++++++++++++-------
t/t7407-submodule-foreach.sh | 35 ++++++++++++++++++++++-------------
7 files changed, 79 insertions(+), 53 deletions(-)
--
2.8.0.32.g71f8beb.dirty
@@ -914,7 +914,7 @@ test_expect_success 'submodule deinit works on repository without submodules' 'gitinit&&>file&&gitaddfile&&-gitcommit-m"repo should not be empty"+gitcommit-m"repo should not be empty"&&gitsubmoduledeinit.)'
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:05
The discussion in [1] realized that '.' is a faulty suggestion as
there is a corner case where it fails:
"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
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 <redacted>
---
git-submodule.sh | 5 -----
t/t7400-submodule-basic.sh | 1 -
2 files changed, 6 deletions(-)
@@ -428,11 +428,6 @@ cmd_deinit()shiftdone-iftest$#=0-then-die"$(eval_gettext"Use '.' if you really want to deinitialize all submodules")"-fi-gitsubmodule--helperlist--prefix"$wt_prefix""$@"|whilereadmodesha1stagesm_pathdo
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:05
`git submodule asdf` would trigger displaying the usage of the submodule
command on stderr, however `git submodule -h` would display the usage on
stdout. Unify displaying help for shell commands on stderr.
Signed-off-by: Stefan Beller <redacted>
---
git-sh-setup.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:05
Reroute the output of stdout to stderr as it is just informative
messages, not to be consumed by machines.
This should not regress any scripts that try to parse the
current output, as the output is already internationalized
and therefore unstable.
Signed-off-by: Stefan Beller <redacted>
---
git-submodule.sh | 2 +-
t/t7406-submodule-update.sh | 23 ++++++++++-------------
2 files changed, 11 insertions(+), 14 deletions(-)
@@ -156,8 +153,8 @@ test_expect_success 'submodule update does not fetch already present commits' '(cdsuper&&gitsubmoduleupdate>../actual2>../actual.err)&&-test_i18ncmpexpectedactual&&-!test-sactual.err+test_must_be_emptyactual&&+test_i18ncmpexpectedactual.err' test_expect_success'submodule update should fail due to local changes''
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:05
Reroute the output of stdout to stderr as it is just informative
messages, not to be consumed by machines.
We want to init submodules from the helper for `submodule update`
in a later patch and the stdout output of said helper is consumed
by the parts of `submodule update` which are still written in shell.
So we have to be careful which messages are on stdout.
Signed-off-by: Stefan Beller <redacted>
---
builtin/submodule--helper.c | 3 ++-
t/t7406-submodule-update.sh | 24 ++++++++++++++++++------
2 files changed, 20 insertions(+), 7 deletions(-)
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:05
This also improves performance for listing submodules, because
S_ISGITLINK is both faster as match_pathspec as well as expected to
be true in fewer cases, so putting it first in the condition will speed
up the loop to compute all submodules.
As this partially reverts 84ba959bbdf0 (submodule: fix regression for
deinit without submodules, 2016-03-22), this also disallows the use
of `git submodule deinit .` to deinit all submodules, when no
submodules are present. `deinit .` continues to work on repositories,
which have at least one submodule.
CC: Per Cederqvist <redacted>
Signed-off-by: Stefan Beller <redacted>
---
Patch 10 is a controversial thing I'd assume as it breaks existing users.
We should take it for the next major release (i.e. 3.0)
I just want to put it out here now.
@@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '>file&&gitaddfile&&gitcommit-m"repo should not be empty"&&-gitsubmoduledeinit.+gitsubmoduledeinit+)+'++test_expect_success'submodule deinit refuses to deinit a file''+test_when_finished"rm -rf newdirectory"&&+mkdirnewdirectory&&+(+cdnewdirectory&&+gitinit&&+>file&&+gitaddfile&&+gitcommit-m"repo should not be empty"&&+test_must_failgitsubmoduledeinitfile)'
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:06
Reroute the output of stdout to stderr as it is just informative
messages, not to be consumed by machines.
This should not regress any scripts that try to parse the
current output, as the output is already internationalized
and therefore unstable.
Signed-off-by: Stefan Beller <redacted>
---
git-submodule.sh | 2 +-
t/t7407-submodule-foreach.sh | 35 ++++++++++++++++++++++-------------
2 files changed, 23 insertions(+), 14 deletions(-)
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:06
Reroute the output of stdout to stderr as it is just informative
messages, not to be consumed by machines.
This should not regress any scripts that try to parse the
current output, as the output is already internationalized
and therefore unstable.
Signed-off-by: Stefan Beller <redacted>
---
git-submodule.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -271,7 +271,7 @@ Use -f if you really want to add it." >&2echo>&2"$(eval_gettext"use the '--force' option. If the local git directory is not the correct repo")"die"$(eval_gettext"or you are unsure what this means choose another name with the '--name' option.")"else-echo"$(eval_gettext"Reactivating local git directory for submodule '\$sm_name'.")"+echo>&2"$(eval_gettext"Reactivating local git directory for submodule '\$sm_name'.")"fifigitsubmodule--helperclone${GIT_QUIET:+--quiet}--prefix"$wt_prefix"--path"$sm_path"--name"$sm_name"--url"$realrepo""$reference""$depth"||exit
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:06
Reroute the output of stdout to stderr as it is just informative
messages, not to be consumed by machines.
This should not regress any scripts that try to parse the
current output, as the output is already internationalized
and therefore unstable.
Signed-off-by: Stefan Beller <redacted>
---
git-submodule.sh | 8 ++++----
t/t7400-submodule-basic.sh | 20 ++++++++++----------
2 files changed, 14 insertions(+), 14 deletions(-)
@@ -452,11 +452,11 @@ cmd_deinit()die"$(eval_gettext"Submodule work tree '\$displaypath' contains local modifications; use '-f' to discard them")"firm-rf"$sm_path"&&-say"$(eval_gettext"Cleared directory '\$displaypath'")"||-say"$(eval_gettext"Could not remove submodule work tree '\$displaypath'")"+say>&2"$(eval_gettext"Cleared directory '\$displaypath'")"||+say>&2"$(eval_gettext"Could not remove submodule work tree '\$displaypath'")"fi-mkdir"$sm_path"||say"$(eval_gettext"Could not create empty submodule directory '\$displaypath'")"+mkdir"$sm_path"||say>&2"$(eval_gettext"Could not create empty submodule directory '\$displaypath'")"# Remove the .git/config entries (unless the user already did it)iftest-n"$(gitconfig--get-regexpsubmodule."$name\.")"
@@ -465,7 +465,7 @@ cmd_deinit()# the user later decides to init this submodule againurl=$(gitconfigsubmodule."$name".url)gitconfig--remove-sectionsubmodule."$name"2>/dev/null&&-say"$(eval_gettext"Submodule '\$name' (\$url) unregistered for path '\$displaypath'")"+say>&2"$(eval_gettext"Submodule '\$name' (\$url) unregistered for path '\$displaypath'")"fidone}
@@ -959,7 +959,7 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' ' test_expect_success'submodule deinit deinits a submodule when its work tree is missing or empty''gitsubmoduleupdate--init&&rm-rfinitexample2/*example2/.git&&-gitsubmoduledeinitinitexample2>actual&&+gitsubmoduledeinitinitexample22>actual&&test-z"$(gitconfig--get-regexp"submodule\.example\.")"&&test-z"$(gitconfig--get-regexp"submodule\.example2\.")"&&test_i18ngrep!"Cleared directory .init"actual&&
@@ -973,7 +973,7 @@ test_expect_success 'submodule deinit fails when the submodule contains modificatest_must_failgitsubmoduledeinitinit&&test-n"$(gitconfig--get-regexp"submodule\.example\.")"&&test-fexample2/.git&&-gitsubmoduledeinit-finit>actual&&+gitsubmoduledeinit-finit2>actual&&test-z"$(gitconfig--get-regexp"submodule\.example\.")"&&test_i18ngrep"Cleared directory .init"actual&&rmdirinit
@@ -985,7 +985,7 @@ test_expect_success 'submodule deinit fails when the submodule contains untracketest_must_failgitsubmoduledeinitinit&&test-n"$(gitconfig--get-regexp"submodule\.example\.")"&&test-fexample2/.git&&-gitsubmoduledeinit-finit>actual&&+gitsubmoduledeinit-finit2>actual&&test-z"$(gitconfig--get-regexp"submodule\.example\.")"&&test_i18ngrep"Cleared directory .init"actual&&rmdirinit
@@ -1000,7 +1000,7 @@ test_expect_success 'submodule deinit fails when the submodule HEAD does not mattest_must_failgitsubmoduledeinitinit&&test-n"$(gitconfig--get-regexp"submodule\.example\.")"&&test-fexample2/.git&&-gitsubmoduledeinit-finit>actual&&+gitsubmoduledeinit-finit2>actual&&test-z"$(gitconfig--get-regexp"submodule\.example\.")"&&test_i18ngrep"Cleared directory .init"actual&&rmdirinit
@@ -1008,17 +1008,17 @@ test_expect_success 'submodule deinit fails when the submodule HEAD does not mat test_expect_success'submodule deinit is silent when used on an uninitialized submodule''gitsubmoduleupdate--init&&-gitsubmoduledeinitinit>actual&&+gitsubmoduledeinitinit2>actual&&test_i18ngrep"Submodule .example. (.*) unregistered for path .init"actual&&test_i18ngrep"Cleared directory .init"actual&&-gitsubmoduledeinitinit>actual&&+gitsubmoduledeinitinit2>actual&&test_i18ngrep!"Submodule .example. (.*) unregistered for path .init"actual&&test_i18ngrep"Cleared directory .init"actual&&-gitsubmoduledeinit.>actual&&+gitsubmoduledeinit.2>actual&&test_i18ngrep!"Submodule .example. (.*) unregistered for path .init"actual&&test_i18ngrep"Submodule .example2. (.*) unregistered for path .example2"actual&&test_i18ngrep"Cleared directory .init"actual&&-gitsubmoduledeinit.>actual&&+gitsubmoduledeinit.2>actual&&test_i18ngrep!"Submodule .example. (.*) unregistered for path .init"actual&&test_i18ngrep!"Submodule .example2. (.*) unregistered for path .example2"actual&&test_i18ngrep"Cleared directory .init"actual&&
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:06
Reroute the output of stdout to stderr as it is just informative
messages, not to be consumed by machines.
This should not regress any scripts that try to parse the
current output, as the output is already internationalized
and therefore unstable.
Signed-off-by: Stefan Beller <redacted>
---
git-submodule.sh | 2 +-
t/t7403-submodule-sync.sh | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
From: Per Cederqvist <hidden> Date: 2016-06-16 02:19:07
After this change, what is the simplest way to programmatically
deinit any submodule that may exist, without failing if there are
none?
"git commit" by default refuses to make an empty commit, but
it has the --allow-empty option.
"git rm -r ." by default fails if there are no files in the repository,
but it has the --ignore-unmatch option.
It makes sense that "git submodule deinit ." should fail if there
are no submodules, but please add support for --ignore-unmatch
at the same time.
/ceder
On Sat, Apr 30, 2016 at 2:40 AM, Stefan Beller [off-list ref] wrote:
quoted hunk
This also improves performance for listing submodules, because
S_ISGITLINK is both faster as match_pathspec as well as expected to
be true in fewer cases, so putting it first in the condition will speed
up the loop to compute all submodules.
As this partially reverts 84ba959bbdf0 (submodule: fix regression for
deinit without submodules, 2016-03-22), this also disallows the use
of `git submodule deinit .` to deinit all submodules, when no
submodules are present. `deinit .` continues to work on repositories,
which have at least one submodule.
CC: Per Cederqvist <redacted>
Signed-off-by: Stefan Beller <redacted>
---
quoted
Patch 10 is a controversial thing I'd assume as it breaks existing users.
We should take it for the next major release (i.e. 3.0)
I just want to put it out here now.
@@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '>file&&gitaddfile&&gitcommit-m"repo should not be empty"&&-gitsubmoduledeinit.+gitsubmoduledeinit+)+'++test_expect_success'submodule deinit refuses to deinit a file''+test_when_finished"rm -rf newdirectory"&&+mkdirnewdirectory&&+(+cdnewdirectory&&+gitinit&&+>file&&+gitaddfile&&+gitcommit-m"repo should not be empty"&&+test_must_failgitsubmoduledeinitfile)'--
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:07
On Mon, May 2, 2016 at 1:26 AM, Per Cederqvist [off-list ref] wrote:
After this change, what is the simplest way to programmatically
deinit any submodule that may exist, without failing if there are
none?
"git commit" by default refuses to make an empty commit, but
it has the --allow-empty option.
"git rm -r ." by default fails if there are no files in the repository,
but it has the --ignore-unmatch option.
It makes sense that "git submodule deinit ." should fail if there
are no submodules, but please add support for --ignore-unmatch
at the same time.
Oh right. I'll add the --ignore-unmatch option when rerolling this series.
Thanks,
Stefan
/ceder
On Sat, Apr 30, 2016 at 2:40 AM, Stefan Beller [off-list ref] wrote:
quoted
This also improves performance for listing submodules, because
S_ISGITLINK is both faster as match_pathspec as well as expected to
be true in fewer cases, so putting it first in the condition will speed
up the loop to compute all submodules.
As this partially reverts 84ba959bbdf0 (submodule: fix regression for
deinit without submodules, 2016-03-22), this also disallows the use
of `git submodule deinit .` to deinit all submodules, when no
submodules are present. `deinit .` continues to work on repositories,
which have at least one submodule.
CC: Per Cederqvist <redacted>
Signed-off-by: Stefan Beller <redacted>
---
quoted
Patch 10 is a controversial thing I'd assume as it breaks existing users.
We should take it for the next major release (i.e. 3.0)
I just want to put it out here now.
@@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '>file&&gitaddfile&&gitcommit-m"repo should not be empty"&&-gitsubmoduledeinit.+gitsubmoduledeinit+)+'++test_expect_success'submodule deinit refuses to deinit a file''+test_when_finished"rm -rf newdirectory"&&+mkdirnewdirectory&&+(+cdnewdirectory&&+gitinit&&+>file&&+gitaddfile&&+gitcommit-m"repo should not be empty"&&+test_must_failgitsubmoduledeinitfile)'--
From: Stefan Beller <hidden> Date: 2016-06-16 02:19:07
On Mon, May 2, 2016 at 9:21 AM, Stefan Beller [off-list ref] wrote:
On Mon, May 2, 2016 at 1:26 AM, Per Cederqvist [off-list ref] wrote:
quoted
After this change, what is the simplest way to programmatically
deinit any submodule that may exist, without failing if there are
none?
"git commit" by default refuses to make an empty commit, but
it has the --allow-empty option.
"git rm -r ." by default fails if there are no files in the repository,
but it has the --ignore-unmatch option.
It makes sense that "git submodule deinit ." should fail if there
are no submodules, but please add support for --ignore-unmatch
at the same time.
With this patch series, you can omit the trailing dot, i.e.
"git submodule deinit" works. I just tested that and it works in
repositories with no submodules as well as in empty repositories,
but I'll add a test for that as well.
Oh right. I'll add the --ignore-unmatch option when rerolling this series.
Thanks,
Stefan
quoted
/ceder
On Sat, Apr 30, 2016 at 2:40 AM, Stefan Beller [off-list ref] wrote:
quoted
This also improves performance for listing submodules, because
S_ISGITLINK is both faster as match_pathspec as well as expected to
be true in fewer cases, so putting it first in the condition will speed
up the loop to compute all submodules.
As this partially reverts 84ba959bbdf0 (submodule: fix regression for
deinit without submodules, 2016-03-22), this also disallows the use
of `git submodule deinit .` to deinit all submodules, when no
submodules are present. `deinit .` continues to work on repositories,
which have at least one submodule.
CC: Per Cederqvist <redacted>
Signed-off-by: Stefan Beller <redacted>
---
quoted
Patch 10 is a controversial thing I'd assume as it breaks existing users.
We should take it for the next major release (i.e. 3.0)
I just want to put it out here now.
@@ -915,7 +915,20 @@ test_expect_success 'submodule deinit works on repository without submodules' '>file&&gitaddfile&&gitcommit-m"repo should not be empty"&&-gitsubmoduledeinit.+gitsubmoduledeinit+)+'++test_expect_success'submodule deinit refuses to deinit a file''+test_when_finished"rm -rf newdirectory"&&+mkdirnewdirectory&&+(+cdnewdirectory&&+gitinit&&+>file&&+gitaddfile&&+gitcommit-m"repo should not be empty"&&+test_must_failgitsubmoduledeinitfile)'--