git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv3 3/4] submodule, repack: migrate to git-sh-setup's say()

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 16, 2009, 05:56 UTC
Message-ID
<7viqiwg1rl.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1245117905-19351-4-git-send-email-bebarino@gmail.com>
Stephen Boyd <bebarino@gmail.com> writes:
> Now that there is say() in git-sh-setup, these scripts don't need to use
> their own. Migrate them over by setting GIT_QUIET and removing their
> custom say() functions.
This is not exactly a very nice style.

The contract between the callers of say() and its implementation is that it does not matter what value is set to GIT_QUIET. The only thing that matters is if it is set to empty string or not. And ...

Show 6 quoted lines
> @@ -33,7 +33,7 @@ do
>  	-A)	all_into_one=t
>  		unpack_unreachable=--unpack-unreachable ;;
>  	-d)	remove_redundant=t ;;
> -	-q)	quiet=-q ;;
> +	-q)	GIT_QUIET=-q ;;

... this one takes advantage of it to set GIT_QUIET to -q, so that it can be directly passed to another command that happens to use -q as "quiet" option, like this ...

> -	git prune-packed $quiet
> +	git prune-packed $GIT_QUIET
>  fi

... while the other one does not have a callout to command that takes -q at all, and does this ...

>  		-q|--quiet)
> -			quiet=1
> +			GIT_QUIET=1

If the convention is "GIT_QUIET, when set to non-empty string, squelches the output", then I think the callers should be more consistent and the call to prune-packed should say something like this, which is admittedly a roundabout way:

	git prune-packed ${GIT_QUIET:+-q}

for consistency (and then what you set to GIT_QUIET in the first hunk I quoted does not matter anymore---it can even be t or 1 or whatever).

I think this does not matter too much, because I suspect that in the longer term scripted Porcelains are going away, but still...

Previous: Stephen BoydNext: Junio C Hamano
Message 8 of 18 in “[PATCHv3 0/4] Teach shell scripts to be quiet”
  1. Stephen BoydJun 16, 2009
  2. 1/4 t4150: test applying with a newline in subjectStephen Boyd, Jun 16, 2009
  3. 2/4 git-sh-setup: introduce say() for quiet optionsStephen Boyd, Jun 16, 2009
  4. 3/4 submodule, repack: migrate to git-sh-setup's say()Stephen Boyd, Jun 16, 2009
  5. 4/4 am, rebase: teach quiet optionStephen Boyd, Jun 16, 2009
  6. Junio C HamanoJun 16, 2009
  7. Stephen BoydJun 16, 2009
  8. Junio C HamanoJun 16, 2009
  9. Junio C HamanoJun 16, 2009
  10. Stephen BoydJun 16, 2009
  11. Johannes SixtJun 16, 2009
  12. 0/5 Teach shell scripts to be quietStephen Boyd, Jun 16, 2009
  13. 1/5 t4150: test applying with a newline in subjectStephen Boyd, Jun 16, 2009
  14. 2/5 am: suppress apply errors when using 3-wayStephen Boyd, Jun 16, 2009
  15. 3/5 git-sh-setup: introduce say() for quiet optionsStephen Boyd, Jun 16, 2009
  16. 4/5 submodule, repack: migrate to git-sh-setup's say()Stephen Boyd, Jun 16, 2009
  17. 5/5 am, rebase: teach quiet optionStephen Boyd, Jun 16, 2009
  18. 6/5 stash: teach quiet optionStephen Boyd, Jun 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.