Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFLFi-009Qs9-V2 for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Dec 2023 21:34:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rFLFg-00Ctn4-LT for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Dec 2023 21:34:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rFLFg-00Ctmv-BJ for pgsql-hackers@lists.postgresql.org; Mon, 18 Dec 2023 21:34:16 +0000 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rFLFY-00CgaX-Ph for pgsql-hackers@postgresql.org; Mon, 18 Dec 2023 21:34:15 +0000 Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b9e1a3e3f0so2700683b6e.1 for ; Mon, 18 Dec 2023 13:34:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=neon.tech; s=google; t=1702935247; x=1703540047; darn=postgresql.org; h=in-reply-to:references:cc:from:to:subject:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mqbHGTZMRU1efIkNn0S6BtJsepF7fDpd54TGbSaCDYE=; b=PnhNwO9l5/rhZsdVIwjFefkuWvjg/Dq5JymF60Vgm+0ZONdPTkmYiXkS4/CVddxjTj ioyXTgXO15bnsEvEwNgr1qDXyvbtHeXB9U0cIcfHlkVCp3X6S8fKQPXBqcFzokPW+jY3 wImeEDHG4RLEl+NLpoB/ZfQsNX9L7rf+xcdzo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702935247; x=1703540047; h=in-reply-to:references:cc:from:to:subject:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=mqbHGTZMRU1efIkNn0S6BtJsepF7fDpd54TGbSaCDYE=; b=RzHAwA7sX/kNYVe00so5ALPnQGTqoNSf/KaSddVY2j31KPaRLB04FuJ8VKFMkYChqG P2H372oylCSHifCGt9E/S7RO/+Dzw/6daLLmqWu5SnieUbLdPHpXXLSti192sW2ZusuM QL/1zPU/elKifJAgtFM3HhSn5AqYJWw0WmETT5x3w6KQNzIbj0zvH8vQNB8WQzRWDsxP xydJ8pvNhcIg6Qym35s4zME20N3DNKT8QW+Pyses5U5/EgIkmCEgyeKhZsOS/7FAHmNo SyucS62RyVLRfNFxI/R5AnYagdE8bMTtOkucpgWZypYdqq8/9DquPe+Ym/nSRLErgkeO wGtg== X-Gm-Message-State: AOJu0YxAA5zC2YTU89rlLlejnW3yTBmiHeo5Hxsw/6y/u2e9w+5k4Zrc OaUb41T/wIcgRpiOjQY21BJhwQ== X-Google-Smtp-Source: AGHT+IHB3migUkTIW9QOS82h8TTBoVM6vcAv+zokysSpotBCHdmLJiqyXlrw7kQdrBdsX/jEWSyqKg== X-Received: by 2002:a05:6808:1818:b0:3b9:de15:c507 with SMTP id bh24-20020a056808181800b003b9de15c507mr21147128oib.46.1702935246780; Mon, 18 Dec 2023 13:34:06 -0800 (PST) Received: from localhost ([2600:1700:210:c270::3b]) by smtp.gmail.com with ESMTPSA id d5-20020a05680805c500b003ae425fc9bdsm4908543oij.23.2023.12.18.13.34.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Dec 2023 13:34:06 -0800 (PST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8; format=Flowed Date: Mon, 18 Dec 2023 15:34:05 -0600 Message-Id: Subject: Re: Add --check option to pgindent To: "Jelte Fennema-Nio" From: "Tristan Partin" Cc: "Daniel Gustafsson" , "Andrew Dunstan" , "Alvaro Herrera" , "Tom Lane" , "Euler Taveira" , "Michael Banck" , "PostgreSQL Hackers" X-Mailer: aerc 0.16.0-93-gbd29700e708d References: <202312121530.7vztxm3bfyrx@alvherre.pgsql> <4b390361-484d-7598-ac13-db2dd7072ad3@dunslane.net> <46DAFBD4-0387-4F8B-96A2-A39499600C32@yesql.se> In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon Dec 18, 2023 at 11:21 AM CST, Jelte Fennema-Nio wrote: > On Mon, 18 Dec 2023 at 17:50, Tristan Partin wrote: > > I could propose something. It would help if I had an example of such > > a tool that already exists. > > Basically the same behaviour as what you're trying to add now for > --check, only instead of printing the diff it would actually change > the files just like running pgindent without a --check flag does. i.e. > allow pgindent --check to not run in "dry-run" mode > My pre-commit hook looks like this currently (removed boring cruft around= it): > > if ! src/tools/pgindent/pgindent --check $files > /dev/null; then > exit 0 > fi > echo "Running pgindent on changed files" > src/tools/pgindent/pgindent $files > echo "Commit abandoned. Rerun git commit to adopt pgindent changes" > exit 1 > > But I would like it to look like: > > if src/tools/pgindent/pgindent --check --write $files > /dev/null; then > exit 0 > fi > echo "Commit abandoned. Rerun git commit to adopt pgindent changes" > exit 1 To me, the two options seem at odds, like you either check or write. How=20 would you feel about just capturing the diffs that are printed and=20 patch(1)-ing them? --=20 Tristan Partin Neon (https://neon.tech)