All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shourya Shukla <shouryashukla.oo@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, kaartic.sivaraam@gmail.com,
	gitster@pobox.com, liu.denton@gmail.com,
	Shourya Shukla <shouryashukla.oo@gmail.com>,
	Christian Couder <chriscool@tuxfamily.org>
Subject: [PATCH 2/2] submodule: Add 'quiet' option in subcommand 'set-branch'
Date: Thu, 14 May 2020 01:47:37 +0530	[thread overview]
Message-ID: <20200513201737.55778-2-shouryashukla.oo@gmail.com> (raw)
In-Reply-To: <20200513201737.55778-1-shouryashukla.oo@gmail.com>

The subcommand 'set-branch' had the 'quiet' option which was
introduced in b57e8119e6 by Denton Liu but was never utilised due to
not setting of the 'GIT_QUIET' variable. Add functionality to
utilise the 'quiet' function.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
---
There was an existence of the `quiet` option in the shell version of
'set-branch' but it was not used anywhere. I decided to add a utility
of the option here by setting GIT_QUIET to 1 in case of a `quiet` as
well as ensure proper functioning in the C version regarding the same.
The if-statement is inspired from what Junio suggested me in my previous
conversion of 'set-url'.

 builtin/submodule--helper.c | 6 ++++--
 git-submodule.sh            | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 5a8815b76e..36b69df5c4 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2321,7 +2321,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
 		config_name = xstrfmt("submodule.%s.branch", path);
 		config_set_in_gitmodules_file_gently(config_name, newbranch);
 
-		printf(_("Default tracking branch set to '%s' successfully\n"), newbranch);
+		if (!(quiet ? OPT_QUIET : 0))
+			printf(_("Default tracking branch set to '%s' successfully\n"), newbranch);
 		free(config_name);
 	}
 
@@ -2334,7 +2335,8 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
 		config_name = xstrfmt("submodule.%s.branch", path);
 		config_set_in_gitmodules_file_gently(config_name, NULL);
 
-		printf(_("Default tracking branch set to 'master' successfully\n"));
+		if (!(quiet ? OPT_QUIET : 0))
+			printf(_("Default tracking branch set to 'master' successfully\n"));
 		free(config_name);
 	}
 
diff --git a/git-submodule.sh b/git-submodule.sh
index 2438ef576e..0cdc77ace6 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -725,7 +725,7 @@ cmd_set_branch() {
 	do
 		case "$1" in
 		-q|--quiet)
-			# we don't do anything with this but we need to accept it
+			GIT_QUIET=1
 			;;
 		-d|--default)
 			default=1
-- 
2.26.2


  reply	other threads:[~2020-05-13 20:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 20:17 [PATCH 1/2] submodule: port subcommand 'set-branch' from shell to C Shourya Shukla
2020-05-13 20:17 ` Shourya Shukla [this message]
2020-05-14 10:15   ` [PATCH 2/2] submodule: Add 'quiet' option in subcommand 'set-branch' Denton Liu
2020-05-16  5:50     ` Shourya Shukla
2020-05-16  8:56       ` Denton Liu
2020-05-16 10:40         ` Shourya Shukla
2020-05-16 11:06           ` Denton Liu
2020-05-14  9:07 ` [PATCH 1/2] submodule: port subcommand 'set-branch' from shell to C Kaartic Sivaraam
2020-05-17 15:06   ` Junio C Hamano
2020-05-17 15:21     ` Kaartic Sivaraam
2020-05-14 10:10 ` Denton Liu
2020-05-16 10:37   ` Shourya Shukla
2020-05-16 10:55     ` Denton Liu
2020-05-17 16:11 ` Đoàn Trần Công Danh

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=20200513201737.55778-2-shouryashukla.oo@gmail.com \
    --to=shouryashukla.oo@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kaartic.sivaraam@gmail.com \
    --cc=liu.denton@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 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.