git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Alejandro Colomar <alx@nginx.com>
Subject: diff -w when removing nested braces (thus unindenting)
Date: Tue, 4 Apr 2023 22:26:27 +0200	[thread overview]
Message-ID: <27551992-99d0-e0e4-a9c6-bebca729d78e@gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1889 bytes --]

Hi,

When removing nested braces, it would be nice if the diff algorithm
could try to remove the brace in a way that it fits semantically.
Considering the following diff:

> diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c
> index 9f3233c8..0e8de7c5 100644
> --- a/src/nxt_http_parse.c
> +++ b/src/nxt_http_parse.c
> @@ -351,29 +351,30 @@ nxt_http_parse_request_line(nxt_http_request_parse_t *rp, u_char **pos,
>  
>          } while (*p == ' ');
>  
> -        if (memcmp(p, "HTTP/", nxt_min(end - p, 5)) == 0) {
> +        if (memcmp(p, "HTTP/", nxt_min(end - p, 5)) != 0) {
> +            return NXT_HTTP_PARSE_INVALID;
> +        }
>  
>          switch (end - p) {
>          case 8:
>              if (p[7] < '0' || p[7] > '9') {
> -                    break;
> +                return NXT_HTTP_PARSE_INVALID;
>              }
>              /* Fall through. */
>          case 7:
>              if (p[6] != '.') {
> -                    break;
> +                return NXT_HTTP_PARSE_INVALID;
>              }
>              /* Fall through. */
>          case 6:
>              if (p[5] < '0' || p[5] > '9') {
> -                    break;
> +                return NXT_HTTP_PARSE_INVALID;
>              }
>              /* Fall through. */
>          default:
>              return NXT_AGAIN;
>          }
>      }
> -    }

This brace removal looks like it would be an unmatching brace.
It would be nicer if the diff showed this:


          }
 -    }
      }

Although I'm conscious that this might be a wild wish impossible
to implement; so I'd just like you to know this little itch of
mine in case you consider it doable.

Cheers,

Alex

>  
>      /* " HTTP/1.1\r\n" or " HTTP/1.1\n" */
>  



-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

                 reply	other threads:[~2023-04-04 20:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=27551992-99d0-e0e4-a9c6-bebca729d78e@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=alx@nginx.com \
    --cc=git@vger.kernel.org \
    /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).