git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Makefile: ASCII-sort += lists
Date: Thu, 8 Oct 2020 18:45:28 -0700	[thread overview]
Message-ID: <20201009014528.GA1314@generichostname> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.2010081156350.50@tvgsbejvaqbjf.bet>

Hi Dscho,

On Thu, Oct 08, 2020 at 12:06:47PM +0200, Johannes Schindelin wrote:
> Also, this strikes me as yet another task that is so automatable that we
> should really avoid bothering humans with it.

Yep, I found these changes via a similar-looking Python script. I like
the Perl version, though, since it gives a path for inclusion so that we
can automate this task.

> I gave it a quick whirl, and
> this Perl script seems to do the job for me:
> 
> 	$key = '';
> 	@to_sort = ();
> 
> 	sub flush_sorted {
> 		if ($#to_sort >= 0) {
> 			print join('', sort @to_sort);
> 			@to_sort = ();
> 		}
> 	}
> 
> 	while (<>) {
> 		if (/^(\S+) \+=/) {
> 			if ($key ne $1) {
> 				flush_sorted;
> 				$key = $1;
> 			}
> 			push @to_sort, $_;
> 		} else {
> 			flush_sorted;
> 			print $_;
> 		}
> 	}
> 	flush_sorted;
> 
> It is not the most elegant Perl script I ever wrote, but it does the job
> for me. And we could probably adapt and use it for other instances where
> we want to keep things sorted (think `commands[]` in `git.c` and the
> `cmd_*()` declarations in `builtin.h`, for example) and hook it up in
> `ci/run-static-analysis.sh` for added benefit.
> 
> My little script also finds this:
> 
> -- snip --
> @@ -1231,8 +1231,8 @@ space := $(empty) $(empty)
> 
>  ifdef SANITIZE
>  SANITIZERS := $(foreach flag,$(subst $(comma),$(space),$(SANITIZE)),$(flag))
> -BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
>  BASIC_CFLAGS += -fno-omit-frame-pointer
> +BASIC_CFLAGS += -fsanitize=$(SANITIZE) -fno-sanitize-recover=$(SANITIZE)
>  ifneq ($(filter undefined,$(SANITIZERS)),)
>  BASIC_CFLAGS += -DSHA1DC_FORCE_ALIGNED_ACCESS
>  endif
> -- snap --

I opted to exclude this hunk because it didn't seem like a list that
should be sorted. Perhaps if we include this in the static-analysis
script, we could define a whitelist of lists that we want to keep
sorted?

Thanks,
Denton

  parent reply	other threads:[~2020-10-09  1:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08  7:39 [PATCH] Makefile: ASCII-sort += lists Denton Liu
2020-10-08 10:06 ` Johannes Schindelin
2020-10-08 16:08   ` Jeff King
2020-10-09 10:49     ` Johannes Schindelin
2020-10-09  1:45   ` Denton Liu [this message]
2020-10-09 10:51     ` Johannes Schindelin
2020-10-09 16:12       ` Junio C Hamano
2020-10-08 16:03 ` Jeff King
2020-10-08 17:38 ` Junio C Hamano

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=20201009014528.GA1314@generichostname \
    --to=liu.denton@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --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).