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

Re: [PATCH 2/4] completion: normalize increment/decrement style

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 22, 2012, 22:05 UTC
Message-ID
<7vvcmy8qxu.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1329901093-24106-3-git-send-email-philip@foolip.org>
Philip Jägenstedt <philip@foolip.org> writes:
Show 6 quoted lines
> The style used for incrementing and decrementing variables was fairly
> inconsistenty and was normalized to use x++, or ((x++)) in contexts
> where the former would otherwise be interpreted as a command. This is a
> bash-ism, but for obvious reasons this script is already bash-specific.
>
> Signed-off-by: Philip Jägenstedt <philip@foolip.org>

I am not sure if the kind of changes seen in the following hunks are necessary but I do not care too deeply about it. Assuming that the change does not make the emulation by zsh unhappy, will apply.

Please stop me if somebody has issues with this rewrite.
Thanks.
Show 26 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index c63a408..1903bc9 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -178,10 +178,8 @@ __git_ps1_show_upstream ()
>  			for commit in $commits
>  			do
>  				case "$commit" in
> -				"<"*) let ++behind
> -					;;
> -				*)    let ++ahead
> -					;;
> +				"<"*) ((behind++)) ;;
> +				*)    ((ahead++))  ;;
>  				esac
>  			done
>  			count="$behind	$ahead"
> @@ -739,7 +737,7 @@ __git_complete_remote_or_refspec ()
>  	local cur_="$cur" cmd="${words[1]}"
>  	local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
>  	if [ "$cmd" = "remote" ]; then
> -		c=$((++c))
> +		((c++))
>  	fi
>  	while [ $c -lt $cword ]; do
>  		i="${words[c]}"
Previous: Philip JägenstedtNext: Philip Jägenstedt
Message 9 of 14 in “completion: remote set-* <name> and <branch>”
  1. completion: remote set-* <name> and <branch>Philip Jägenstedt, Feb 18, 2012
  2. Junio C HamanoFeb 20, 2012
  3. Philip JägenstedtFeb 21, 2012
  4. completion: remote set-* <name> and <branch>Philip Jägenstedt, Feb 21, 2012
  5. SZEDER GáborFeb 22, 2012
  6. completion: remote set-* <name> and <branch>Philip Jägenstedt, Feb 22, 2012
  7. 1/4 completion: remote set-* <name> and <branch>Philip Jägenstedt, Feb 22, 2012
  8. 2/4 completion: normalize increment/decrement stylePhilip Jägenstedt, Feb 22, 2012
  9. Junio C HamanoFeb 22, 2012
  10. 3/4 completion: remove stale "to submit patches" documentationPhilip Jägenstedt, Feb 22, 2012
  11. 4/4 completion: use tabs for indentationPhilip Jägenstedt, Feb 22, 2012
  12. Thomas RastFeb 22, 2012
  13. Junio C HamanoFeb 21, 2012
  14. SZEDER GáborFeb 22, 2012

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.