All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: jrnieder@gmail.com, git@vger.kernel.org, Jens.Lehmann@web.de,
	pclouds@gmail.com
Subject: Re: [PATCH 03/15] submodule add: label submodules if asked to
Date: Tue, 26 Apr 2016 15:49:50 -0700	[thread overview]
Message-ID: <xmqq7ffkc7e9.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1461703833-10350-4-git-send-email-sbeller@google.com> (Stefan Beller's message of "Tue, 26 Apr 2016 13:50:21 -0700")

Stefan Beller <sbeller@google.com> writes:

> When adding new submodules, you can specify the
> label(s) the submodule belongs to by giving one or more
> --label arguments. This will record each label in the
> .gitmodules file as a value of the key
> "submodule.$NAME.label".
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  Documentation/git-submodule.txt |  5 ++++-
>  git-submodule.sh                | 14 +++++++++++++-
>  t/t7400-submodule-basic.sh      | 32 ++++++++++++++++++++++++++++++++
>  3 files changed, 49 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index 8c4bbe2..349ead8 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -9,7 +9,7 @@ git-submodule - Initialize, update or inspect submodules
>  SYNOPSIS
>  --------
>  [verse]
> -'git submodule' [--quiet] add [-b <branch>] [-f|--force] [--name <name>]
> +'git submodule' [--quiet] add [-b <branch>] [-f|--force] [-l|--label <label>]
>  	      [--reference <repository>] [--depth <depth>] [--] <repository> [<path>]
>  'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]
>  'git submodule' [--quiet] init [--] [<path>...]
> @@ -109,6 +109,9 @@ is the superproject and submodule repositories will be kept
>  together in the same relative location, and only the
>  superproject's URL needs to be provided: git-submodule will correctly
>  locate the submodule using the relative URL in .gitmodules.
> ++
> +If at least one label argument was given, all labels are recorded in the
> +.gitmodules file in the label fields.

I think this is better without "If ... given,".

I am not sure if it is sensible to make "label" namespace always
global to be shared with the project by updating .gitmodules,
though (it can cut both ways, so this is not an objection).

> @@ -165,6 +166,13 @@ cmd_add()
>  		--depth=*)
>  			depth=$1
>  			;;
> +		-l|--label)
> +			labels="${labels} $2"
> +			shift
> +			;;
> +		--label=*)
> +			labels="${labels} ${1#--label=}"
> +			;;
>  		--)
>  			shift
>  			break
> @@ -292,6 +300,10 @@ Use -f if you really want to add it." >&2
>  
>  	git config -f .gitmodules submodule."$sm_name".path "$sm_path" &&
>  	git config -f .gitmodules submodule."$sm_name".url "$repo" &&
> +	for label in $labels
> +	do
> +		git config --add -f .gitmodules submodule."$sm_name".label "${label}"
> +	done &&

Is the acceptable syntax for "label" defined and documented
somewhere?

I didn't see it in the documentation patch.  I am seeing that we do
not allow $IFS whitespaces in them, but are there other restrictions
we want to enforce?  Remember, starting with narrow and widening as
we discover the need is the right way to design things.  Once we
start allowing random strings, it is very hard to later reject some
to carve out namespace for ourselves.

The above implementation happens to allow users to say

	git submodule add -l "labelA labelB" -- $there $path

and give two labels to the module, and that will be something you
end up needing to support forever, unless you restrict early.

  reply	other threads:[~2016-04-26 22:49 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26 20:50 [PATCH 00/15] submodule groups (once again) Stefan Beller
2016-04-26 20:50 ` [PATCH 01/15] string_list: add string_list_duplicate Stefan Beller
2016-04-26 22:37   ` Junio C Hamano
2016-04-27 18:02     ` Stefan Beller
2016-04-27 21:11       ` Junio C Hamano
2016-04-27 21:17         ` Stefan Beller
2016-04-27 23:17           ` Junio C Hamano
2016-04-27 23:24             ` Stefan Beller
2016-04-26 20:50 ` [PATCH 02/15] submodule doc: write down what we want to achieve in this series Stefan Beller
2016-04-26 22:42   ` Junio C Hamano
2016-04-26 20:50 ` [PATCH 03/15] submodule add: label submodules if asked to Stefan Beller
2016-04-26 22:49   ` Junio C Hamano [this message]
2016-04-26 22:50   ` Jacob Keller
2016-04-26 23:19     ` Stefan Beller
2016-04-27  3:24       ` Jacob Keller
2016-04-26 20:50 ` [PATCH 04/15] submodule-config: keep labels around Stefan Beller
2016-04-26 20:50 ` [PATCH 05/15] submodule-config: check if submodule a submodule is in a group Stefan Beller
2016-04-26 22:58   ` Junio C Hamano
2016-04-26 23:17     ` Junio C Hamano
2016-04-27 23:00       ` Stefan Beller
2016-04-26 20:50 ` [PATCH 06/15] submodule init: redirect stdout to stderr Stefan Beller
2016-04-29 18:27   ` Junio C Hamano
2016-04-29 18:38     ` Stefan Beller
2016-04-26 20:50 ` [PATCH 07/15] submodule deinit: loose requirement for giving '.' Stefan Beller
2016-04-29 18:27   ` Junio C Hamano
2016-04-26 20:50 ` [PATCH 08/15] submodule--helper list: respect submodule groups Stefan Beller
2016-04-29 18:31   ` Junio C Hamano
2016-04-26 20:50 ` [PATCH 09/15] submodule--helper init: " Stefan Beller
2016-04-26 20:50 ` [PATCH 10/15] submodule--helper update_clone: " Stefan Beller
2016-04-26 20:50 ` [PATCH 11/15] diff: ignore submodules excluded by groups Stefan Beller
2016-04-29 18:37   ` Junio C Hamano
2016-04-29 19:17     ` Stefan Beller
2016-05-05 19:57       ` Stefan Beller
2016-05-05 20:19         ` Junio C Hamano
2016-05-05 21:02           ` Stefan Beller
2016-05-05 22:20             ` Junio C Hamano
2016-05-05 22:50               ` Stefan Beller
2016-05-05 23:07                 ` Junio C Hamano
2016-05-06  6:08                   ` Junio C Hamano
2016-05-06 18:23                     ` Stefan Beller
2016-05-06 18:59                       ` Junio C Hamano
2016-04-26 20:50 ` [PATCH 12/15] git submodule summary respects groups Stefan Beller
2016-04-29 18:38   ` Junio C Hamano
2016-04-26 20:50 ` [PATCH 13/15] cmd_status: respect submodule groups Stefan Beller
2016-04-26 20:50 ` [PATCH 14/15] cmd_diff: " Stefan Beller
2016-04-26 20:50 ` [PATCH 15/15] clone: allow specification of submodules to be cloned Stefan Beller
2016-04-26 22:19 ` [PATCH 00/15] submodule groups (once again) Junio C Hamano
2016-04-26 22:26 ` 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=xmqq7ffkc7e9.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=sbeller@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.