# [PATCH 2/2] fetch: silence git-gc if --quiet is given

7 messages from 2014-08-14 to 2014-08-16. Participants: Nguyễn Thái Ngọc Duy, Jeff King, Duy Nguyen.
Thread: https://gitlist.dev/t/37347

## Nguyễn Thái Ngọc Duy, 2014-08-14 11:51

Subject: [PATCH 1/2] fetch: convert argv_gc_auto to struct argv_array
Message-ID: <1408017065-17437-1-git-send-email-pclouds@gmail.com>
URL: https://gitlist.dev/e/1408017065-17437-1-git-send-email-pclouds%40gmail.com

```
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index e8d0cca..9394194 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1110,9 +1110,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 	struct string_list list = STRING_LIST_INIT_NODUP;
 	struct remote *remote;
 	int result = 0;
-	static const char *argv_gc_auto[] = {
-		"gc", "--auto", NULL,
-	};
+	struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
 
 	packet_trace_identity("fetch");
 
@@ -1198,7 +1196,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 	list.strdup_strings = 1;
 	string_list_clear(&list, 0);
 
-	run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+	argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
+	run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
 
 	return result;
 }
-- 
2.1.0.rc0.78.gc0d8480

```

## Nguyễn Thái Ngọc Duy, 2014-08-14 11:51

Subject: [PATCH 2/2] fetch: silence git-gc if --quiet is given
Message-ID: <1408017065-17437-2-git-send-email-pclouds@gmail.com>
URL: https://gitlist.dev/e/1408017065-17437-2-git-send-email-pclouds%40gmail.com
In-Reply-To: <1408017065-17437-1-git-send-email-pclouds@gmail.com>

```
Noticed-by: Matthew Flaschen <mflaschen@wikimedia.org>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 9394194..4ff4080 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1197,6 +1197,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 	string_list_clear(&list, 0);
 
 	argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
+	if (verbosity < 0)
+		argv_array_push(&argv_gc_auto,"--quiet");
 	run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
 
 	return result;
-- 
2.1.0.rc0.78.gc0d8480

```

## Jeff King, 2014-08-14 19:53

Subject: Re: [PATCH 1/2] fetch: convert argv_gc_auto to struct argv_array
Message-ID: <20140814195320.GA19337@peff.net>
URL: https://gitlist.dev/e/20140814195320.GA19337%40peff.net
In-Reply-To: <1408017065-17437-1-git-send-email-pclouds@gmail.com>

```
On Thu, Aug 14, 2014 at 06:51:04PM +0700, Nguyễn Thái Ngọc Duy wrote:

> -	static const char *argv_gc_auto[] = {
> -		"gc", "--auto", NULL,
> -	};
> +	struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
>  
>  	packet_trace_identity("fetch");
>  
> @@ -1198,7 +1196,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
>  	list.strdup_strings = 1;
>  	string_list_clear(&list, 0);
>  
> -	run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
> +	argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
> +	run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);

argv_array_clear() here afterwards?

Not a huge deal since we are about to exit, but in the name of
good hygiene.

-Peff

```

## Jeff King, 2014-08-14 19:56

Subject: Re: [PATCH 2/2] fetch: silence git-gc if --quiet is given
Message-ID: <20140814195615.GB19337@peff.net>
URL: https://gitlist.dev/e/20140814195615.GB19337%40peff.net
In-Reply-To: <1408017065-17437-2-git-send-email-pclouds@gmail.com>

```
On Thu, Aug 14, 2014 at 06:51:05PM +0700, Nguyễn Thái Ngọc Duy wrote:

> Noticed-by: Matthew Flaschen <mflaschen@wikimedia.org>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/fetch.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 9394194..4ff4080 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -1197,6 +1197,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
>  	string_list_clear(&list, 0);
>  
>  	argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
> +	if (verbosity < 0)
> +		argv_array_push(&argv_gc_auto,"--quiet");
>  	run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);

I think this is a fine fix for this specific problem, and we should
apply it. But I do wonder if it would be simpler in the long run to
treat verbosity as a global option, and pass it around via a GIT_QUIET
(or GIT_VERBOSITY) environment variable.

I would not be surprised at all to find that there are other cases where
sub-programs do not respect the parent verbosity (I know we have had
problems with progress reporting flags carried over the transport
interface in the past, but I think we fixed all of those).

-Peff

```

## Duy Nguyen, 2014-08-15 12:09

Subject: Re: [PATCH 2/2] fetch: silence git-gc if --quiet is given
Message-ID: <CACsJy8CuiAYGA-Tkr1p+KVm=hvpKYwooJMc9-z-pR4nOBDaTug@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8CuiAYGA-Tkr1p%2BKVm%3DhvpKYwooJMc9-z-pR4nOBDaTug%40mail.gmail.com
In-Reply-To: <20140814195615.GB19337@peff.net>

```
On Fri, Aug 15, 2014 at 2:56 AM, Jeff King <peff@peff.net> wrote:
> I think this is a fine fix for this specific problem, and we should
> apply it. But I do wonder if it would be simpler in the long run to
> treat verbosity as a global option, and pass it around via a GIT_QUIET
> (or GIT_VERBOSITY) environment variable.
>
> I would not be surprised at all to find that there are other cases where
> sub-programs do not respect the parent verbosity (I know we have had
> problems with progress reporting flags carried over the transport
> interface in the past, but I think we fixed all of those).

I don't see any easy way to make everybody aware of $GIT_QUIET. But
the idea is nice.
-- 
Duy

```

## Nguyễn Thái Ngọc Duy, 2014-08-16 01:19

Subject: [PATCH v2 1/2] fetch: convert argv_gc_auto to struct argv_array
Message-ID: <1408151968-30294-1-git-send-email-pclouds@gmail.com>
URL: https://gitlist.dev/e/1408151968-30294-1-git-send-email-pclouds%40gmail.com
In-Reply-To: <1408017065-17437-1-git-send-email-pclouds@gmail.com>

```
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index e8d0cca..5f06114 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1110,9 +1110,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 	struct string_list list = STRING_LIST_INIT_NODUP;
 	struct remote *remote;
 	int result = 0;
-	static const char *argv_gc_auto[] = {
-		"gc", "--auto", NULL,
-	};
+	struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
 
 	packet_trace_identity("fetch");
 
@@ -1198,7 +1196,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 	list.strdup_strings = 1;
 	string_list_clear(&list, 0);
 
-	run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
+	argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
+	run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
+	argv_array_clear(&argv_gc_auto);
 
 	return result;
 }
-- 
2.1.0.rc0.78.gc0d8480

```

## Nguyễn Thái Ngọc Duy, 2014-08-16 01:19

Subject: [PATCH v2 2/2] fetch: silence git-gc if --quiet is given
Message-ID: <1408151968-30294-2-git-send-email-pclouds@gmail.com>
URL: https://gitlist.dev/e/1408151968-30294-2-git-send-email-pclouds%40gmail.com
In-Reply-To: <1408151968-30294-1-git-send-email-pclouds@gmail.com>

```
Noticed-by: Matthew Flaschen <mflaschen@wikimedia.org>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 5f06114..159fb7e 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1197,6 +1197,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 	string_list_clear(&list, 0);
 
 	argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
+	if (verbosity < 0)
+		argv_array_push(&argv_gc_auto, "--quiet");
 	run_command_v_opt(argv_gc_auto.argv, RUN_GIT_CMD);
 	argv_array_clear(&argv_gc_auto);
 
-- 
2.1.0.rc0.78.gc0d8480

```
