git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Duy Nguyen <pclouds@gmail.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Thomas Rast <trast@student.ethz.ch>
Subject: Re: [PATCH v2] sha1_name: reorganize get_sha1_basic()
Date: Thu, 2 May 2013 14:59:29 -0500	[thread overview]
Message-ID: <CAMP44s3-TM1PW6qKAFRf=Sdojw3RNscM_VJZfBy3C7xHZst_Wg@mail.gmail.com> (raw)
In-Reply-To: <1367524078-13266-1-git-send-email-artagnon@gmail.com>

On Thu, May 2, 2013 at 2:47 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
> A small suggestion.  Squash this in if you like; optionally submit it
> as a separate part.
>
> diff --git a/sha1_name.c b/sha1_name.c
> index 6428001..109ab41 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -448,11 +448,12 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
>         if (len && str[len-1] == '}') {
>                 for (at = len-2; at >= 0; at--) {
>                         if (str[at] == '@' && str[at+1] == '{') {
> -                               if (at == 0 && str[2] == '-') {
> -                                       nth_prior = 1;
> -                                       continue;
> -                               }
> -                               if (!upstream_mark(str + at, len - at)) {
> +                               if (str[at+2] == '-') {
> +                                       if (at != 0)
> +                                               return -1;
> +                                       else
> +                                               nth_prior = 1;
> +                               } else if (!upstream_mark(str + at, len - at)) {

Generally I don't like this style, it's prone to multiple indentation levels.

                        if (str[at] == '@' && str[at+1] == '{') {
-                               if (at == 0 && str[2] == '-') {
+                               if (str[at+2] == '-') {
+                                       if (at != 0)
+                                               /* @{-N} not at start */
+                                               return -1;
                                        nth_prior = 1;
                                        continue;
                                }

Otherwise makes sense, but I would do it as a separate patch.

-- 
Felipe Contreras

      reply	other threads:[~2013-05-02 19:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-02 17:48 [PATCH v2] sha1_name: reorganize get_sha1_basic() Felipe Contreras
2013-05-02 18:02 ` Felipe Contreras
2013-05-02 18:55 ` Ramkumar Ramachandra
2013-05-02 19:10   ` Felipe Contreras
2013-05-02 19:35     ` Ramkumar Ramachandra
2013-05-02 19:47       ` Ramkumar Ramachandra
2013-05-02 19:59         ` Felipe Contreras [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='CAMP44s3-TM1PW6qKAFRf=Sdojw3RNscM_VJZfBy3C7xHZst_Wg@mail.gmail.com' \
    --to=felipe.contreras@gmail.com \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=pclouds@gmail.com \
    --cc=trast@student.ethz.ch \
    /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).