From: Junio C Hamano <gitster@pobox•com>
To: Jens Lehmann <Jens.Lehmann@web•de>
Cc: Phil Hord <phil.hord@gmail•com>,
"W. Trevor King" <wking@tremily•us>, Git <git@vger•kernel.org>,
Heiko Voigt <hvoigt@hvoigt•net>, Jeff King <peff@peff•net>,
Shawn Pearce <spearce@spearce•org>,
Nahor <nahor.j+gmane@gmail•com>
Subject: Re: [PATCH] submodule: add 'deinit' command
Date: Sat, 01 Dec 2012 18:00:06 -0800 [thread overview]
Message-ID: <7vy5hhmcwp.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <50BA3412.60309@web.de> (Jens Lehmann's message of "Sat, 01 Dec 2012 17:45:06 +0100")
Jens Lehmann <Jens.Lehmann@web•de> writes:
> With "git submodule init" the user is able to tell git he cares about one
> or more submodules and wants to have it populated on the next call to "git
> submodule update". But currently there is no easy way he could tell git he
> does not care about a submodule anymore and wants to get rid of his local
> work tree (except he knows a lot about submodule internals and removes the
> "submodule.$name.url" setting from .git/config himself).
>
> Help those users by providing a 'deinit' command. This removes the url
> setting from .git/config either for the given submodule(s) or for all
> those which have been initialized if none were given. Complain only when
> for a submodule given on the command line the url setting can't be found
> in .git/config.
>
> Add tests and link the man pages of "git submodule deinit" and "git rm" to
> assist the user in deciding whether removing or unregistering the submodule
> is the right thing to do for him.
>
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web•de>
> ---
I fully agree with your analysis on the reason why the "url" element
is special and has to be copied to $GIT_DIR/config, but when you
deinit (or uninit) a submodule to say you are no longer interested
in it and do not want it populated in the context of the
superproject, I am not sure if removing only submodule.$name.url (so
that when you later decide to "init" it again, you will keep the
values for submodule.$name.update and other things from the previous
life) is the sane thing to do, or it is better to remove
submodule.$name.* altogether as if an earlier "init" has never
happened. Would it be worth analyzing the pros-and-cons here?
> Am 01.12.2012 16:56, schrieb Jens Lehmann:
>> Am 01.12.2012 00:52, schrieb Phil Hord:
>>> If I never 'submodule init' a submodule, it does not get visited by
>>> 'git submodule foreach', among others. I think some people use this
>>> behavior explicitly.
>>>
>>> On the other hand, I've also notice that a submodule which I have
>>> removed does not get de-inited later one. It causes my 'git submodule
>>> foreach' to emit errors. :-(
>>
>> I'm currently hacking on "git submodule deinit" which removes the 'url'
>> setting from git/config. This should do the trick for you, right?
>
> And here we go ...
>
>
> Documentation/git-rm.txt | 4 ++++
> Documentation/git-submodule.txt | 11 +++++++++
> git-submodule.sh | 50 ++++++++++++++++++++++++++++++++++++++++-
> t/t7400-submodule-basic.sh | 11 +++++++++
> 4 files changed, 75 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-rm.txt b/Documentation/git-rm.txt
> index 262436b..ec42bf5 100644
> --- a/Documentation/git-rm.txt
> +++ b/Documentation/git-rm.txt
> @@ -149,6 +149,10 @@ files that aren't ignored are present in the submodules work tree.
> Ignored files are deemed expendable and won't stop a submodule's work
> tree from being removed.
>
> +If you only want to remove the local checkout of a submodule from your
> +work tree without committing that use `git submodule deinit` instead
> +(see linkgit:git-submodule[1]).
> +
> EXAMPLES
> --------
> `git rm Documentation/\*.txt`::
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index b1de3ba..fba77f6 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -13,6 +13,7 @@ SYNOPSIS
> [--reference <repository>] [--] <repository> [<path>]
> 'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
> 'git submodule' [--quiet] init [--] [<path>...]
> +'git submodule' [--quiet] deinit [--] [<path>...]
> 'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase]
> [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
> 'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) <n>]
> @@ -134,6 +135,16 @@ init::
> the explicit 'init' step if you do not intend to customize
> any submodule locations.
>
> +deinit::
> + Unregister the submodules, i.e. remove the `submodule.$name.url`
> + setting from .git/config. Further calls to `git submodule update`,
> + `git submodule foreach` and `git submodule sync` will skip any
> + unregistered submodules until they are initialized again, so use
> + this command if you don't want to have a local checkout of the
> + submodule in your work tree anymore. If you really want to remove
> + a submodule from the repository and commit that use
> + linkgit:git-rm[1] instead.
> +
> update::
> Update the registered submodules, i.e. clone missing submodules and
> checkout the commit specified in the index of the containing repository.
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 2365149..4059a2e 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -8,6 +8,7 @@ dashless=$(basename "$0" | sed -e 's/-/ /')
> USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
> or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
> or: $dashless [--quiet] init [--] [<path>...]
> + or: $dashless [--quiet] deinit [--] [<path>...]
> or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
> or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
> or: $dashless [--quiet] foreach [--recursive] <command>
> @@ -516,6 +517,53 @@ cmd_init()
> }
>
> #
> +# Unregister submodules from .git/config
> +#
> +# $@ = requested paths (default to all)
> +#
> +cmd_deinit()
> +{
> + # parse $args after "submodule ... init".
> + while test $# -ne 0
> + do
> + case "$1" in
> + -q|--quiet)
> + GIT_QUIET=1
> + ;;
> + --)
> + shift
> + break
> + ;;
> + -*)
> + usage
> + ;;
> + *)
> + break
> + ;;
> + esac
> + shift
> + done
> +
> + module_list "$@" |
> + while read mode sha1 stage sm_path
> + do
> + die_if_unmatched "$mode"
> + name=$(module_name "$sm_path") || exit
> + url=$(git config submodule."$name".url)
> + if test -z "$url"
> + then
> + # Only mention uninitialized submodules when its
> + # path have been specified
> + test "$#" != "0" &&
> + say "$(eval_gettext "No url found for submodule path '\$sm_path' in .git/config")"
> + continue
> + fi
> + git config --unset submodule."$name".url &&
> + say "$(eval_gettext "Submodule '\$name' (\$url) unregistered")"
> + done
> +}
> +
> +#
> # Update each submodule path to correct revision, using clone and checkout as needed
> #
> # $@ = requested paths (default to all)
> @@ -1108,7 +1156,7 @@ cmd_sync()
> while test $# != 0 && test -z "$command"
> do
> case "$1" in
> - add | foreach | init | update | status | summary | sync)
> + add | foreach | init | deinit | update | status | summary | sync)
> command=$1
> ;;
> -q|--quiet)
> diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
> index de7d453..803bda7 100755
> --- a/t/t7400-submodule-basic.sh
> +++ b/t/t7400-submodule-basic.sh
> @@ -756,4 +756,15 @@ test_expect_success 'submodule add with an existing name fails unless forced' '
> )
> '
>
> +test_expect_success 'submodule deinit should unregister submodule url from .git/config' '
> + url=$(git config submodule.example.url) &&
> + git submodule deinit &&
> + test -z "$(git config submodule.example.url)"
> +'
> +
> +test_expect_success 'submodule deinit complains only when explicitly used on an uninitialized submodule' '
> + git submodule deinit &&
> + test_must_fail git submodule deinit example
> +'
> +
> test_done
next prev parent reply other threads:[~2012-12-02 2:00 UTC|newest]
Thread overview: 156+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-22 16:34 [PATCH] git-submodule add: Record branch name in .gitmodules W. Trevor King
[not found] ` <CABURp0pqg7XC6makK2OcundMabV9AtcBNGNK6Q0TMZfJbt3anw@mail.gmail.com>
2012-10-22 22:55 ` W. Trevor King
2012-10-24 18:12 ` Phil Hord
2012-10-25 1:12 ` W. Trevor King
2012-10-26 13:37 ` Jeff King
2012-10-23 19:16 ` Nahor
2012-10-23 19:44 ` W. Trevor King
2012-10-23 20:44 ` W. Trevor King
2012-10-23 21:57 ` [PATCH v2] git-submodule add: Add -r/--record option W. Trevor King
2012-10-24 19:15 ` Jens Lehmann
2012-10-25 0:53 ` W. Trevor King
2012-10-28 20:48 ` Jens Lehmann
2012-10-28 21:16 ` W. Trevor King
2012-10-28 21:59 ` Shawn Pearce
2012-10-28 22:34 ` W. Trevor King
2012-10-29 5:34 ` Jeff King
2012-10-29 10:45 ` W. Trevor King
2012-10-29 10:58 ` Jeff King
2012-10-29 11:29 ` W. Trevor King
2012-10-29 11:43 ` Jeff King
2012-10-29 17:38 ` Phil Hord
2012-10-29 21:36 ` Jeff King
2012-10-29 22:21 ` Phil Hord
2012-10-29 22:27 ` Jeff King
2012-11-09 3:35 ` [PATCH v3 0/3] " W. Trevor King
2012-11-09 3:35 ` [PATCH v3 1/3] " W. Trevor King
2012-11-09 7:34 ` Junio C Hamano
2012-11-09 16:29 ` Heiko Voigt
2012-11-10 19:02 ` W. Trevor King
2012-11-17 15:04 ` Heiko Voigt
2012-11-17 19:20 ` W. Trevor King
2012-11-17 21:31 ` Heiko Voigt
2012-11-17 22:00 ` W. Trevor King
2012-11-20 0:49 ` Junio C Hamano
2012-11-20 1:16 ` W. Trevor King
2012-11-20 5:39 ` Junio C Hamano
2012-11-20 12:19 ` W. Trevor King
2012-11-20 19:52 ` Junio C Hamano
2012-11-23 15:55 ` Heiko Voigt
2012-11-23 16:23 ` W. Trevor King
2012-11-23 16:30 ` W. Trevor King
2012-11-23 17:54 ` W. Trevor King
2012-11-26 21:00 ` [PATCH v4 0/4] git-submodule add: Add --local-branch option W. Trevor King
2012-11-26 21:00 ` [PATCH v4 1/4] " W. Trevor King
2012-11-26 21:00 ` [PATCH v4 2/4] git-submodule init: Record submodule.<name>.branch in repository config W. Trevor King
2012-11-27 23:19 ` Jens Lehmann
2012-11-28 0:40 ` W. Trevor King
2012-11-30 17:53 ` [RFC] remove/deprecate 'submodule init' and 'sync' W. Trevor King
2012-11-30 18:17 ` W. Trevor King
2012-11-30 23:52 ` Phil Hord
2012-12-01 12:48 ` W. Trevor King
2012-12-01 15:42 ` Jens Lehmann
2012-12-01 15:56 ` Jens Lehmann
2012-12-01 16:37 ` W. Trevor King
2012-12-01 16:45 ` [PATCH] submodule: add 'deinit' command Jens Lehmann
2012-12-02 2:00 ` Junio C Hamano [this message]
2012-12-02 19:55 ` Jens Lehmann
2012-12-03 7:58 ` Junio C Hamano
2012-12-04 21:48 ` [PATCH v2] " Jens Lehmann
2012-12-04 23:06 ` Junio C Hamano
2012-12-12 15:08 ` Michael J Gruber
2012-12-12 17:22 ` Jens Lehmann
2012-12-12 19:32 ` Junio C Hamano
2012-12-12 22:25 ` Jens Lehmann
2012-12-12 22:34 ` Junio C Hamano
2012-12-12 23:09 ` W. Trevor King
2012-12-12 23:35 ` Junio C Hamano
2012-12-13 0:28 ` W. Trevor King
2012-12-13 15:47 ` Marc Branchaud
2012-12-01 15:38 ` [RFC] remove/deprecate 'submodule init' and 'sync' Jens Lehmann
2012-12-01 16:30 ` W. Trevor King
2012-12-01 17:25 ` Jens Lehmann
2012-12-01 17:49 ` W. Trevor King
2012-12-01 18:04 ` Jens Lehmann
2012-12-01 18:16 ` W. Trevor King
2012-12-02 19:09 ` W. Trevor King
2012-12-02 20:29 ` Jens Lehmann
2012-12-02 21:11 ` W. Trevor King
2012-12-01 16:54 ` W. Trevor King
2012-12-03 15:38 ` W. Trevor King
2012-11-26 21:00 ` [PATCH v4 3/4] git-submodule update: Add --branch option W. Trevor King
2012-11-27 18:51 ` Heiko Voigt
2012-11-27 20:21 ` W. Trevor King
2012-11-26 21:00 ` [PATCH v4 4/4] Hack fix for 'submodule update does not fetch already present commits' W. Trevor King
2012-11-27 18:31 ` [PATCH v4 0/4] git-submodule add: Add --local-branch option Heiko Voigt
2012-11-27 19:04 ` W. Trevor King
2012-11-27 19:16 ` Heiko Voigt
2012-11-27 19:01 ` W. Trevor King
2012-11-27 21:18 ` [PATCH v4 4/4] Hack fix for 'submodule update does not fetch already present commits' W. Trevor King
2012-11-27 23:28 ` Re: [PATCH v4 0/4] git-submodule add: Add --local-branch option Heiko Voigt
2012-11-28 2:42 ` W. Trevor King
2012-11-29 18:51 ` Phil Hord
2012-11-23 17:24 ` [PATCH v3 1/3] git-submodule add: Add -r/--record option Sascha Cunz
2012-11-23 16:03 ` Heiko Voigt
2012-11-28 13:09 ` [PATCH v4 0/4] git-submodule add: Add --local-branch option (summary) W. Trevor King
2012-11-28 16:53 ` W. Trevor King
2012-11-28 19:30 ` [PATCH v5 0/2] submodule update: add --remote for submodule's upstream changes W. Trevor King
2012-11-28 19:30 ` [PATCH v5 1/2] " W. Trevor King
2012-11-28 19:30 ` [PATCH v5 2/2] submodule add: If --branch is given, record it in .gitmodules W. Trevor King
2012-11-29 16:12 ` [RFC] git-submodule update: Add --commit option W. Trevor King
2012-11-29 16:21 ` W. Trevor King
2012-11-29 16:27 ` W. Trevor King
2012-11-29 19:13 ` [PATCH v5 0/2] submodule update: add --remote for submodule's upstream changes W. Trevor King
2012-11-30 1:11 ` Phil Hord
2012-11-30 3:27 ` W. Trevor King
2012-12-02 3:17 ` [PATCH v6 0/4] " W. Trevor King
2012-12-02 3:17 ` [PATCH v6 1/4] submodule: add get_submodule_config helper funtion W. Trevor King
2012-12-03 19:30 ` Junio C Hamano
2012-12-04 0:17 ` W. Trevor King
2012-12-11 18:58 ` [PATCH v7 0/3] submodule update: add --remote for submodule's upstream changes W. Trevor King
2012-12-11 18:58 ` [PATCH v7 1/3] submodule: add get_submodule_config helper funtion W. Trevor King
2012-12-11 18:58 ` [PATCH v7 2/3] submodule update: add --remote for submodule's upstream changes W. Trevor King
2012-12-12 17:43 ` Phil Hord
2012-12-12 19:54 ` Junio C Hamano
2012-12-12 23:02 ` W. Trevor King
2012-12-19 16:03 ` [PATCH v8 0/3] " wking
2012-12-19 16:03 ` [PATCH v8 1/3] submodule: add get_submodule_config helper funtion wking
2012-12-21 8:20 ` Heiko Voigt
2012-12-21 11:04 ` W. Trevor King
2012-12-19 16:03 ` [PATCH v8 2/3] submodule update: add --remote for submodule's upstream changes wking
2012-12-19 16:03 ` [PATCH v8 3/3] submodule add: If --branch is given, record it in .gitmodules wking
2012-12-19 17:43 ` Junio C Hamano
2012-12-21 8:18 ` [PATCH v8 0/3] submodule update: add --remote for submodule's upstream changes Heiko Voigt
2012-12-11 18:58 ` [PATCH v7 3/3] submodule add: If --branch is given, record it in .gitmodules W. Trevor King
2012-12-12 5:42 ` [PATCH v7 0/3] submodule update: add --remote for submodule's upstream changes Junio C Hamano
2012-12-12 15:24 ` W. Trevor King
2012-12-12 18:19 ` Junio C Hamano
2012-12-12 22:44 ` W. Trevor King
2012-12-02 3:17 ` [PATCH v6 2/4] " W. Trevor King
2012-12-03 16:46 ` Junio C Hamano
2012-12-03 18:15 ` W. Trevor King
2012-12-03 18:38 ` W. Trevor King
2012-12-03 20:29 ` Junio C Hamano
2012-12-02 3:17 ` [PATCH v6 3/4] submodule add: If --branch is given, record it in .gitmodules W. Trevor King
2012-12-02 3:17 ` [PATCH v6 4/4] submodule update: add submodule.<name>.remote config option W. Trevor King
2012-12-02 19:32 ` [PATCH v5 0/2] submodule update: add --remote for submodule's upstream changes Jens Lehmann
2012-11-10 18:44 ` [PATCH v3 1/3] git-submodule add: Add -r/--record option W. Trevor King
2012-11-11 10:33 ` Junio C Hamano
2012-11-11 15:00 ` W. Trevor King
2012-11-17 15:30 ` Heiko Voigt
2012-11-28 19:42 ` W. Trevor King
2012-11-28 20:08 ` Junio C Hamano
[not found] ` <20121109104607.GC4406@ftbfs.org>
2012-11-10 19:11 ` W. Trevor King
2012-11-09 3:35 ` [PATCH v3 2/3] git-submodule foreach: export .gitmodules settings as variables W. Trevor King
2012-11-09 16:45 ` Heiko Voigt
2012-11-10 19:21 ` W. Trevor King
2012-11-09 3:35 ` [PATCH v3 3/3] git-submodule: Motivate --record with an example use case W. Trevor King
2012-10-25 22:14 ` [PATCH v2] git-submodule add: Add -r/--record option W. Trevor King
2012-10-26 14:00 ` Jeff King
2012-10-23 21:45 ` [PATCH] git-submodule add: Record branch name in .gitmodules Nahor
2012-10-23 20:36 ` Jens Lehmann
2012-10-23 20:55 ` W. Trevor King
2012-10-23 22:02 ` Nahor
2012-10-24 19:10 ` Jens Lehmann
-- strict thread matches above, loose matches on Subject: below --
2012-11-28 18:28 [PATCH] submodule update: document exisiting -r form for --rebase W. Trevor King
2012-11-28 19:02 ` Junio C Hamano
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=7vy5hhmcwp.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox$(echo .)com \
--cc=Jens.Lehmann@web$(echo .)de \
--cc=git@vger$(echo .)kernel.org \
--cc=hvoigt@hvoigt$(echo .)net \
--cc=nahor.j+gmane@gmail$(echo .)com \
--cc=peff@peff$(echo .)net \
--cc=phil.hord@gmail$(echo .)com \
--cc=spearce@spearce$(echo .)org \
--cc=wking@tremily$(echo .)us \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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