From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C41A73857005 for ; Tue, 19 Jul 2022 14:26:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C41A73857005 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-146-HPmAqPhROvyeis926FogrQ-1; Tue, 19 Jul 2022 10:26:41 -0400 X-MC-Unique: HPmAqPhROvyeis926FogrQ-1 Received: by mail-wr1-f69.google.com with SMTP id e5-20020adfa445000000b0021e45ff3413so118591wra.14 for ; Tue, 19 Jul 2022 07:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KL432Yk1k7fAvpI310muUPO5H00bPKgeHwGIQlpMBLg=; b=RjjRH00J79GwuH569ydaBXDJiVSVBUT9YuCsq9qOvhgZ1e+4GRhWZqwxlagOLQeVFD 3zUvRY2mWZ4Qz3gIotAFAyOyfchFOm5KzsJdv1lW2BXkV1BGpLQpM56YM2UH36tNrWqI 4GlhFOFwn/DVakd/Q9v5SLVgcd9PpuwaxCsqKEHnTKu6krpO0ew53GDqs4kjbVIzM9J/ OBe7JY8AduoJY3YsvZrc6aJL1FTN5NTe2UObE3alcpmCENqKuKLXsHczz6SZKAeB8uz/ QI3SK2VsmXOmfJTbuMRZwbRxt4vq5M4yNNFvr0bZ7oCm3Qvom5yvjgwRk+R/XtFOWl07 ghyw== X-Gm-Message-State: AJIora/wDFZY6MdJHwgK4DkDw1KWDfgNLOeruCOgKRaUgcH8vLqbVIVO yGgxCnwZz3X96FEUtMRKL3cxK8eTlQam6V4WWjdBNqjZEHSMXJfSNyny9KOGTdc/eEDvbTA4yU+ UwPI660AGznMarAyBcUkCfg== X-Received: by 2002:a05:600c:1c19:b0:3a3:181e:89e with SMTP id j25-20020a05600c1c1900b003a3181e089emr12044408wms.203.1658240800124; Tue, 19 Jul 2022 07:26:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1voyRH60LF8Jd4ldX6OqpG7g6u2tDsQW7tvml3EQINrNWp2sIJxXcyWYHFShens4FM4fgcK8w== X-Received: by 2002:a05:600c:1c19:b0:3a3:181e:89e with SMTP id j25-20020a05600c1c1900b003a3181e089emr12044398wms.203.1658240799924; Tue, 19 Jul 2022 07:26:39 -0700 (PDT) Received: from localhost (15.72.115.87.dyn.plus.net. [87.115.72.15]) by smtp.gmail.com with ESMTPSA id bg11-20020a05600c3c8b00b003a1980d55c4sm22874596wmb.47.2022.07.19.07.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 07:26:39 -0700 (PDT) From: Andrew Burgess To: binutils@sourceware.org Cc: gdb-patches@sourceware.org, Andrew Burgess Subject: [PATCH] binutils-gdb/git: highlight whitespace errors in source files Date: Tue, 19 Jul 2022 15:26:31 +0100 Message-Id: <20220719142631.1882613-1-aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2022 14:26:44 -0000 For a long time I've had this in my ~/.gitconfig: [core] whitespace = space-before-tab,indent-with-non-tab,trailing-space which causes git to show me if I muck up and use spaces instead of tabs, or leave in trailing whitespace. I find this really useful. I recently proposed adding something like this to the .gitattributes files for the GDB sub-directories (gdb, gdbsupport, and gdbserver)[1], however, the question was asked - couldn't this be done at the top level? So, in this commit, I propose to update the top-level .gitattributes file, after this commit, any git diff on a C, C++, Expect, or TCL source file, will highlight the following whitespace errors: (a) Use a space before a tab at the start of a line, (b) Use of spaces where a tab could be used at the start of a line, and (c) Any trailing whitespace. Errors are only highlighted in the diff on new or modified lines, so you don't get spammed for errors on context lines that you haven't modified. The only downside I see to adding this at the top level is if there are any sub-directories that don't follow the tabs/spaces indentation rules very well already, in those directories you'll end up hitting issues any time you edit a line. For GDB we're usually pretty good, so having this highlighting isn't an issue. [1] https://sourceware.org/pipermail/gdb-patches/2022-July/190843.html --- .gitattributes | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitattributes b/.gitattributes index 06d51d28a95..6f7c6d8ba52 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,3 +18,18 @@ # file gets renamed again ... ChangeLog merge=merge-changelog + +# Setup whitespace error detection. +# +# (1) Spaces before tabs, +# +# (2) Use of spaces where a tab should be used, +# +# (3) Trailing whitespace, + +*.cxx whitespace=space-before-tab,indent-with-non-tab,trailing-space +*.cc whitespace=space-before-tab,indent-with-non-tab,trailing-space +*.cpp whitespace=space-before-tab,indent-with-non-tab,trailing-space +*.[cChH] whitespace=space-before-tab,indent-with-non-tab,trailing-space +*.exp whitespace=space-before-tab,indent-with-non-tab,trailing-space +*.tcl whitespace=space-before-tab,indent-with-non-tab,trailing-space -- 2.25.4