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

Re: [PATCH] stash: Add stash.showFlag config variable

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Aug 27, 2015, 15:20 UTC
Message-ID
<1440688825-1303-1-git-send-email-szeder@ira.uka.de>
In-Reply-To
<1440683528-11725-1-git-send-email-namhyung@gmail.com>
Hi,

I haven't made up my mind about this feature yet, but have a few comments about its implementation.

Show 14 quoted lines
> diff --git a/git-stash.sh b/git-stash.sh
> index 1d5ba7a..8432435 100755
> --- a/git-stash.sh
> +++ b/git-stash.sh
> @@ -33,6 +33,12 @@ else
>         reset_color=
>  fi
>  
> +if git config --get stash.showflag > /dev/null 2> /dev/null; then
> +	show_flag=$(git config --get stash.showflag)
> +else
> +	show_flag=--stat
> +fi
> +

Forking and executing processes are costly on some important platforms we care about, so we should strive to avoid them whenever possible.

 - This hunk runs the the exact same 'git config' command twice.  Run it
   only once, perhaps something like this:
     show_flag=$(git config --get stash.showflag || echo --stat)
   (I hope there are no obscure crazy 'echo' implemtations out there
   that might barf on the unknown option '--stat'...)
 - It runs 'git config' in the main code path, i.e. even for subcommands
   other than 'show'.  Run it only for 'git stash show'.
 - This config setting is not relevant if there were options given on the
   command line.  Run it only if there are no options given, i.e. when
   $FLAGS is empty.
Show 14 quoted lines
>  no_changes () {
>  	git diff-index --quiet --cached HEAD --ignore-submodules -- &&
>  	git diff-files --quiet --ignore-submodules &&
> @@ -305,7 +311,7 @@ show_stash () {
>  	ALLOW_UNKNOWN_FLAGS=t
>  	assert_stash_like "$@"
>  
> -	git diff ${FLAGS:---stat} $b_commit $w_commit
> +	git diff ${FLAGS:-${show_flag}} $b_commit $w_commit
>  }
>  
>  show_help () {
> -- 
> 2.5.0
Previous: Namhyung KimNext: Namhyung Kim
Message 2 of 9 in “stash: Add stash.showFlag config variable”
  1. stash: Add stash.showFlag config variableNamhyung Kim, Aug 27, 2015
  2. SZEDER GáborAug 27, 2015
  3. Namhyung KimAug 27, 2015
  4. Eric SunshineAug 28, 2015
  5. Namhyung KimAug 28, 2015
  6. Junio C HamanoAug 28, 2015
  7. Namhyung KimAug 28, 2015
  8. Junio C HamanoAug 28, 2015
  9. Namhyung KimAug 29, 2015

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.