From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Philip Jägenstedt" <philip@foolip.org>,
git@vger.kernel.org, "SZEDER Gábor" <szeder@ira.uka.de>,
"Felipe Contreras" <felipe.contreras@gmail.com>,
"Teemu Likonen" <tlikonen@iki.fi>
Subject: Re: [PATCH] completion: remote set-* <name> and <branch>
Date: Wed, 22 Feb 2012 01:03:10 +0100 [thread overview]
Message-ID: <20120222000310.GA13237@goldbirke> (raw)
In-Reply-To: <7v8vjvg71s.fsf@alter.siamese.dyndns.org>
On Tue, Feb 21, 2012 at 02:23:11PM -0800, Junio C Hamano wrote:
> >>> {
> >>> local cur_="$cur" cmd="${words[1]}"
> >>> local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
> >>> + if [ "$cmd" = "remote" ]; then
> >>> + c=$((++c))
> >>> + fi
> >>
> >> I don't know about others, but auto-incrementing a variable and assigning
> >> the result to the same variable, while not wrong at all, hurts my brain.
> >>
> >> c=$(($c + 1))
> >>
> >> is far more readable and does not suggest there is any funky magic
> >> involved. Also it is a good habit to get into not to omit $ from
> >> variables inside arithmetic substitution, even though bash allows it and
> >> this script is meant to be consumed only by shells that understand this
> >> bash-ism.
> >>
> >> I do not know offhand if zsh groks it, but the point is that you do not
> >> have to worry about it if you write "$(($c+1))" instead of "$((c+1))".
This c=$((++c)) style increment is used in several completion
functions, even in the main entry function _git() itself. If zsh
didn't grok it, then completion wouldn't work at all on zsh, because
the while loop in _git() would be an endless loop.
> > CodingGuidlines suggests to follow local convention, which was
> > "c=$((++c))". This file also uses "++n", "i++" and "((i++))". I will
> > send a v2 patch that normalizes these, open to discussion of course.
>
> OK, it was my mistake to suggest $c++ in this file; it liberally uses
> dollar-less variables, and I agree that it is a good idea to stick to that
> local convention.
>
> But I think you went too far in your follow-up patch to make the increment
> and decrement uniform.
>
> "i++" is so much easier on the eye unless you must use "++i" in order to
> use the value of the incremented "i" in an expression, and the changes to
> turn existing instances of free-standing "i++" to "++i" done only for the
> side effect of incrementing the variables look totally backwards.
>
> Although I do not deeply care. Just leaving the new one as you originally
> wrote, i.e.
>
> c=$((++c))
>
> would have been easier to review for the area experts, I would think.
The issue of this weird increment came up before
http://thread.gmane.org/gmane.comp.version-control.git/87650/focus=87806
and the conclusion back then was that we kept the existing style. But
otherwise I agree, it hurts my brain, too.
Best,
Gábor
prev parent reply other threads:[~2012-02-22 0:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-18 13:32 [PATCH] completion: remote set-* <name> and <branch> Philip Jägenstedt
2012-02-20 7:58 ` Junio C Hamano
2012-02-21 21:29 ` Philip Jägenstedt
2012-02-21 21:54 ` [PATCH v2] " Philip Jägenstedt
2012-02-22 0:17 ` SZEDER Gábor
2012-02-22 8:58 ` [PATCH v3] " Philip Jägenstedt
2012-02-22 8:58 ` [PATCH 1/4] " Philip Jägenstedt
2012-02-22 8:58 ` [PATCH 2/4] completion: normalize increment/decrement style Philip Jägenstedt
2012-02-22 22:05 ` Junio C Hamano
2012-02-22 8:58 ` [PATCH 3/4] completion: remove stale "to submit patches" documentation Philip Jägenstedt
2012-02-22 8:58 ` [PATCH 4/4] completion: use tabs for indentation Philip Jägenstedt
2012-02-22 9:52 ` [PATCH v3] completion: remote set-* <name> and <branch> Thomas Rast
2012-02-21 22:23 ` [PATCH] " Junio C Hamano
2012-02-22 0:03 ` SZEDER Gábor [this message]
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=20120222000310.GA13237@goldbirke \
--to=szeder@ira.uka.de \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=philip@foolip.org \
--cc=tlikonen@iki.fi \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).