git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Roy Eldar <royeldar0@gmail.com>
Cc: git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 3/3] git-submodule.sh: improve parsing of short options
Date: Sun, 08 Dec 2024 09:02:00 +0900	[thread overview]
Message-ID: <xmqqr06jrqiv.fsf@gitster.g> (raw)
In-Reply-To: <20241207135201.2536-4-royeldar0@gmail.com> (Roy Eldar's message of "Sat, 7 Dec 2024 15:52:01 +0200")

Roy Eldar <royeldar0@gmail.com> writes:

> Some command-line options have a short form which takes an argument; for
> example, "--jobs" has the form "-j", and it takes a numerical argument.
>
> When parsing short options, support the case where there is no space
> between the flag and the option argument, in order to improve
> consistency with the rest of the builtin git commands.
>
> Signed-off-by: Roy Eldar <royeldar0@gmail.com>
> ---
>  git-submodule.sh | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/git-submodule.sh b/git-submodule.sh
> index a47d2a89f3..fc85458fb1 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -77,6 +77,9 @@ cmd_add()
>  			branch=$2
>  			shift
>  			;;
> +		-b*)
> +			branch="${1#-b}"
> +			;;
>  		--branch=*)
>  			branch="${1#--branch=}"
>  			;;

OK, so we used to take "--branch foo" and assign 'foo' to $branch,
"--branch=foo" now does the same, and then we have "-b foo" doing
the same with this step.

> @@ -352,6 +355,9 @@ cmd_update()
>  			jobs="--jobs=$2"
>  			shift
>  			;;
> +		-j*)
> +			jobs="--jobs=${1#-j}"
> +			;;
>  		--jobs=*)
>  			jobs=$1
>  			;;

This is a bit curious.  If you stick the principle in 1/3, this
should assign "4", not "--jobs=4", to variable $jobs upon seeing
"-j4", and that would be consistent with how the $branch gets its
value above.

As I said in the devil's advocate section in my review for 1/3, I
often find the value of the variable spelling out the option name
as well as the option value (i.e., force="--force", not force=1;
branch="--branch=foo", not branch=foo; jobs=--jobs=4, not jobs=4)
easier to debug and drive other programs using these variables, so I
do not mind jobs=--jobs=4 at all, but if we want to be consistent in
the other direction, this would probably want to be modified in the
name of consistency?

Other than that, all three patches looked sane to me.

Thanks.


	

  reply	other threads:[~2024-12-08  0:02 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-07 13:51 [PATCH 0/3] git-submodule.sh: improve parsing of options Roy Eldar
2024-12-07 13:51 ` [PATCH 1/3] git-submodule.sh: make some variables boolean Roy Eldar
2024-12-07 23:43   ` Junio C Hamano
2024-12-08  0:06   ` Eric Sunshine
2024-12-07 13:52 ` [PATCH 2/3] git-submodule.sh: improve parsing of some long options Roy Eldar
2024-12-07 13:52 ` [PATCH 3/3] git-submodule.sh: improve parsing of short options Roy Eldar
2024-12-08  0:02   ` Junio C Hamano [this message]
2024-12-09 16:21     ` Roy E
2024-12-09 16:50 ` [PATCH v2 0/8] git-submodule.sh: improve parsing of options Roy Eldar
2024-12-09 16:50   ` [PATCH v2 1/8] git-submodule.sh: make some variables boolean Roy Eldar
2024-12-09 16:50   ` [PATCH v2 2/8] git-submodule.sh: improve parsing of some long options Roy Eldar
2024-12-09 16:50   ` [PATCH v2 3/8] git-submodule.sh: improve parsing of short options Roy Eldar
2024-12-09 16:50   ` [PATCH v2 4/8] git-submodule.sh: get rid of isnumber Roy Eldar
2024-12-09 16:50   ` [PATCH v2 5/8] git-submodule.sh: get rid of unused variable Roy Eldar
2024-12-09 16:50   ` [PATCH v2 6/8] git-submodule.sh: add some comments Roy Eldar
2024-12-09 16:50   ` [PATCH v2 7/8] git-submodule.sh: improve variables readability Roy Eldar
2024-12-09 16:50   ` [PATCH v2 8/8] git-submodule.sh: rename some variables Roy Eldar
2024-12-09 23:26   ` [PATCH v2 0/8] git-submodule.sh: improve parsing of options Junio C Hamano
2024-12-10  0:50     ` Junio C Hamano
2024-12-10 18:11     ` Roy E
2024-12-11  0:02       ` Junio C Hamano
2024-12-11  6:13         ` Roy E
2024-12-11  6:16           ` Junio C Hamano
2024-12-10 18:44   ` [PATCH v3 0/7] " Roy Eldar
2024-12-10 18:44     ` [PATCH v3 1/7] git-submodule.sh: improve parsing of some long options Roy Eldar
2024-12-10 18:44     ` [PATCH v3 2/7] git-submodule.sh: improve parsing of short options Roy Eldar
2024-12-10 18:44     ` [PATCH v3 3/7] git-submodule.sh: get rid of isnumber Roy Eldar
2024-12-10 18:44     ` [PATCH v3 4/7] git-submodule.sh: get rid of unused variable Roy Eldar
2024-12-10 18:44     ` [PATCH v3 5/7] git-submodule.sh: add some comments Roy Eldar
2024-12-10 18:44     ` [PATCH v3 6/7] git-submodule.sh: improve variables readability Roy Eldar
2024-12-11  0:14       ` Junio C Hamano
2024-12-11  6:21         ` Roy E
2024-12-11  1:56       ` Đoàn Trần Công Danh
2024-12-11  6:09         ` Junio C Hamano
2024-12-10 18:44     ` [PATCH v3 7/7] git-submodule.sh: rename some variables Roy Eldar
2024-12-11  6:32     ` [PATCH v4 0/7] git-submodule.sh: improve parsing of options Roy Eldar
2024-12-11  6:32       ` [PATCH v4 1/7] git-submodule.sh: improve parsing of some long options Roy Eldar
2024-12-11  6:32       ` [PATCH v4 2/7] git-submodule.sh: improve parsing of short options Roy Eldar
2024-12-11  6:32       ` [PATCH v4 3/7] git-submodule.sh: get rid of isnumber Roy Eldar
2024-12-11  6:32       ` [PATCH v4 4/7] git-submodule.sh: get rid of unused variable Roy Eldar
2024-12-11  6:32       ` [PATCH v4 5/7] git-submodule.sh: add some comments Roy Eldar
2024-12-11  6:32       ` [PATCH v4 6/7] git-submodule.sh: improve variables readability Roy Eldar
2024-12-11  6:32       ` [PATCH v4 7/7] git-submodule.sh: rename some variables Roy Eldar

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=xmqqr06jrqiv.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=royeldar0@gmail.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 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).