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 DFB763857036 for ; Tue, 19 Jul 2022 14:26:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DFB763857036 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176-PyTC-H1TOIO2-1CX1edJ4g-1; Tue, 19 Jul 2022 10:26:41 -0400 X-MC-Unique: PyTC-H1TOIO2-1CX1edJ4g-1 Received: by mail-wm1-f69.google.com with SMTP id z20-20020a1c4c14000000b003a3020da654so5307217wmf.5 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=qlSmibwTA31Z9utelmqdtKH7TW0dhGsqNv885HBVKSvgx97bBkkz4Zg+M8OfjHVQKc joK350XQBQgdseu3ZUsljzoxq4fNfpzQRd6WUV5DbGg2Ik9eVsxmzV5t//5RdGqYBC+F MXitj0/+ZwNzMWgta+qtAaGUvyFDcrbTeVHaU2aFbOiYVGPhIJkurMdoVFslpvpVOe6P xvtE4m7OV7rCfzNFXCj7puHVyFnDD2IZIyZS3mmV7/Gau8idshZXyJ2S03gRW0ka8YZO ThfXHqCvi0ZUwaM6M8hGkXmBNt3l2y/TgRenxGGHhdQ/Afd5GirzBF35gyYO67aGQzrh 1z9w== X-Gm-Message-State: AJIora+VApnEvH8rqo3ruNQvUAEX/mxm9lRFBw/wSg9Fbc1tyCh5wDpf OJLHQRj/l6dCVnqzU/Oq4MosBJklvkLfzmuK32odZhnvHGSQNz1g5SX64LRwReHy3Aqmg496dd8 L/yQbbwLCjeo6EYdja8moU1Z2xBuSwMThrf6my0lZS0tasi/9wK+n0xF78Ktm5n963QDJGg== X-Received: by 2002:a05:600c:1c19:b0:3a3:181e:89e with SMTP id j25-20020a05600c1c1900b003a3181e089emr12044421wms.203.1658240800251; 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils 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