From: Tay Ray Chuan <rctay89@gmail.com>
To: "Git Mailing List" <git@vger.kernel.org>
Subject: [PATCH 3/3] git submodule update should give notice when run without init beforehand
Date: Mon, 16 Sep 2013 01:38:23 +0800 [thread overview]
Message-ID: <1379266703-29808-3-git-send-email-rctay89@gmail.com> (raw)
In-Reply-To: <1379266703-29808-2-git-send-email-rctay89@gmail.com>
When 'update' is run with no path in a repository with uninitialized
submodules, the program terminates with no output, and zero status code.
Be more helpful to users by mentioning this.
This may be controlled by an advice.* option.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
Documentation/config.txt | 5 +++++
git-submodule.sh | 16 ++++++++++++++--
t/t7406-submodule-update.sh | 5 ++++-
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index ec57a15..79313f9 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -202,6 +202,11 @@ advice.*::
rmHints::
In case of failure in the output of linkgit:git-rm[1],
show directions on how to proceed from the current state.
+ submoduleUpdateUninit::
+ When linkgit:git-submodule[1] `update` is run with no `path`
+ arguments in a repository with uninitialized submodules,
+ mention that uninitalized submodules are indeed present, and
+ that they may be initialized with the `--init` option.
--
core.fileMode::
diff --git a/git-submodule.sh b/git-submodule.sh
index 2979197..56f3dc2 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -777,6 +777,7 @@ cmd_update()
cloned_modules=
module_list "$@" | {
err=
+ has_uninit=
while read mode sha1 stage sm_path
do
die_if_unmatched "$mode"
@@ -807,9 +808,13 @@ cmd_update()
then
# Only mention uninitialized submodules when its
# path have been specified
- test "$#" != "0" &&
- say "$(eval_gettext "Submodule path '\$displaypath' not initialized
+ if test "$#" != "0"
+ then
+ say "$(eval_gettext "Submodule path '\$displaypath' not initialized
Maybe you want to use 'update --init'?")"
+ else
+ has_uninit=1
+ fi
continue
fi
@@ -940,6 +945,13 @@ Maybe you want to use 'update --init'?")"
IFS=$OIFS
exit 1
fi
+
+ if test -n "$has_uninit" \
+ -a "$(git config --bool --get advice.submoduleUpdateUninit)" != "false"
+ then
+ say "$(eval_gettext "Uninitialized submodules were detected;
+Maybe you want to use 'update --init'?")"
+ fi
}
}
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 00475eb..8dbe410 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -76,8 +76,11 @@ test_expect_success 'submodule update <path> warns without init beforehand' '
)
'
-test_expect_success 'submodule update is silent without init beforehand' '
+test_expect_success 'submodule update warns without init beforehand' '
(cd super2 &&
+ test_must_fail git config --get advice.submoduleUpdateUninit &&
+ test -n "$(git submodule update)" &&
+ git config advice.submoduleUpdateUninit false &&
test -z "$(git submodule update)"
)
'
--
1.8.4.rc4.527.g303b16c
next prev parent reply other threads:[~2013-09-15 17:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-15 17:38 [PATCH 1/3] t7406-submodule-update: add missing && Tay Ray Chuan
2013-09-15 17:38 ` [PATCH 2/3] t7406-submodule-update: demonstrate behaviour when run without init beforehand Tay Ray Chuan
2013-09-15 17:38 ` Tay Ray Chuan [this message]
2013-09-16 17:06 ` [PATCH 3/3] git submodule update should give notice " Jens Lehmann
2013-09-18 10:12 ` Tay Ray Chuan
2013-09-18 19:13 ` Jens Lehmann
[not found] ` <CALUzUxrf+ZGX8nQ0DVqYEyWto3Cos16VLTUfjsX99qnDLa=S6w@mail.gmail.com>
2013-09-19 10:25 ` Chris Packham
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379266703-29808-3-git-send-email-rctay89@gmail.com \
--to=rctay89@gmail.com \
--cc=git@vger.kernel.org \
/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.
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 NNTP newsgroup(s).