From patchwork Tue Jul 23 08:21:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13739694 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A47E14B082 for ; Tue, 23 Jul 2024 08:21:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722878; cv=none; b=NuSlV+w7dUcKFhTAapRfvmeLOz1OzqeHeBPBVaZFMQeOfrt0nm7hTNtaClvUg899z0AJHSCeCG5tSnXrOam6TJVoDS5/FISxDcbAy/vPqZlhChwdn2v4oLtwhuw1Yt2uU9XsKsbU+fL5ld6Ut8DMlaN4cBckT4vJdusBCbmy3Xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722878; c=relaxed/simple; bh=fXYkwyyNJCLwx/1+LXMILAXgVK2bnFuuMMrPjySB8G8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z3ks3FWLmf61KGpzvVFh8pGhSRc/bwuX+BeqTtn9YSXgD/8F09f6zEZW/v6SDdbo52pbCjBO7G3arrhpEJAquAlNoctovUiesmTslTkR9grrEpUTEWa5f32u5IRRsK3fntelqzJZ8BfzM/AsRcqNM/wv0Z3w3ZL9lFoQyZ1To/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YH3VOp5P; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YH3VOp5P" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-52f025bc147so2988945e87.3 for ; Tue, 23 Jul 2024 01:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721722875; x=1722327675; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IXE3MYu8CxgvrX1p6ggHUE0kt8dF7SAUpXUFx2O4fgw=; b=YH3VOp5P0170chaMqmx/WbAZ6Et7IN3e1m5R6XoIKojMvHbr7ln1bNoz3rF/iJMMKO J7Ov16uHe+boq4Ad0FntquO/g20XdpVFkCbOIUAqc8WlZ3U3tNYicNv6/gcquVfbeCAI RoiShCVe6vHcXJvEJVNFRXXEH5uwbSxjnfxOhLtEM6bHZvkTSNRJ6ODQN7WWYYvna97V hzrkunNx8n1pst24GLFFfnnjOKUzA4ZRWiUwFTlOS/XzQWAvgM/olMebDkd95Nx44wuy piYzMBF3C6T6zVDIR2aQBVAmwrlaxTpdIbsOYzGdDIZ0QWzvBuKCipTROEx4kBysM/PV gBSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721722875; x=1722327675; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IXE3MYu8CxgvrX1p6ggHUE0kt8dF7SAUpXUFx2O4fgw=; b=OfMhRSiIFyQriA4rFfuac4bf1UjVSgJz2KgDgsrWunCJtEB98zaLz0e5E2qCQVf2cZ 0Jg8gS8RjkuXpN638dYjfA9hz1qjPsLjvMCAt+BRW/tJ4kZcOBcB5XrlSjMoTD51Hljk IWhmsLf5fTd/oD0PlVCExfYRO893OZVcIpdeAAKf5gxe+uwrS1D6ZJ1g1s97xLfN5uYy kvWl6mrtRuDhQ29N7vRL1WenRZS8IHEOBrC8VjA2QxEtuWptsR0r6/yYk50ErIlG4Pve KCiiZq1WG//f9G0RBKTD0oUzaT996dIxxNj7fMTS83d1SMxj6BfBHZcbR77yOHIp4bc+ FpEg== X-Forwarded-Encrypted: i=1; AJvYcCWLLZlNIPAdDg8k8J319unuqJR8Syvb156SSiia8o2915Weh4kqpznorWi4SaOSNSPKK5mpmWzWMplzIOLuW6LqlpIN X-Gm-Message-State: AOJu0YysCYQiZbAzsRc2R2TkUcSpqGRCnHidN6Bu8uae0QIqzZoo0HRX ag4iFc5pW2OUqKfhp/7hXsDs/6KmZLS83fjtfVRxPBR5RHZb7RDN X-Google-Smtp-Source: AGHT+IFElAXfTYjUilei9DqkXyQZEX8L9asUSvF2RKzShLXmWTRaVWX//rz5Xzns2HkTAiXYF/qnzg== X-Received: by 2002:a05:6512:3402:b0:52e:9d6b:2691 with SMTP id 2adb3069b0e04-52efb63433bmr5729532e87.20.1721722874826; Tue, 23 Jul 2024 01:21:14 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:45ae:72d0:1982:e034]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9f463194sm24026266b.112.2024.07.23.01.21.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 01:21:14 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, gitster@pobox.com, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v6 1/6] clang-format: indent preprocessor directives after hash Date: Tue, 23 Jul 2024 10:21:06 +0200 Message-ID: <20240723082111.874382-2-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723082111.874382-1-karthik.188@gmail.com> References: <20240718081605.452366-1-karthik.188@gmail.com> <20240723082111.874382-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We do not have a rule around the indentation of preprocessor directives. This was also discussed on the list [1], noting how there is often inconsistency in the styling. While there was discussion, there was no conclusion around what is the preferred style here. One style being indenting after the hash: #if FOO # if BAR # include # endif #endif The other being before the hash: #if FOO #if BAR #include #endif #endif Let's pick the former and add 'IndentPPDirectives: AfterHash' value to our '.clang-format'. There is no clear reason to pick one over the other, but it would definitely be nicer to be consistent. [1]: https://lore.kernel.org/r/xmqqwmmm1bw6.fsf@gitster.g Signed-off-by: Karthik Nayak --- .clang-format | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.clang-format b/.clang-format index 3ed4fac753..5e128519bf 100644 --- a/.clang-format +++ b/.clang-format @@ -96,6 +96,12 @@ BreakStringLiterals: false # Switch statement body is always indented one level more than case labels. IndentCaseLabels: false +# Indents directives before the hash. +# #if FOO +# # include +# #endif +IndentPPDirectives: AfterHash + # Don't indent a function definition or declaration if it is wrapped after the # type IndentWrappedFunctionNames: false From patchwork Tue Jul 23 08:21:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13739695 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9804E14B094 for ; Tue, 23 Jul 2024 08:21:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722879; cv=none; b=s1EnYultb5awV9YHhtjjg5H2yte83/YXwFBgoI5Ot8ExEZZvYCNfcndf24xArZdNtP8Z8A/oQdMajt41Ub+0NBKsRx//TlHdt8d0VyQFh0xBHR//4RE8mtMhoCNPKKrB1pqOIw20lS0Xa4wCturi5Hr64dDhhMKJXQVLvwejE6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722879; c=relaxed/simple; bh=c57a5FZo8oc1XwZXmAykTqE3C++vUFM1nNGdVk7APJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fFOy285oMx5DrX0IhVGuYX/tHvBWul8gm3k2CzvrhDXjWLElGDNgRuYeLw996JstiuCvtEOuFDIPldKQg4jVe2glKlhp9kkqsFJfiOk9ilUfzSR+axo26Eyn+QVivKerWimH2nC3BGREP2QeLjwg4uz6LVVx4U0wv2rxi1brVtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B1xzti43; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B1xzti43" Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a7aa086b077so15712266b.0 for ; Tue, 23 Jul 2024 01:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721722876; x=1722327676; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dGFI5dxykS0Ye5JgwzTOfeSKS/2TqbyMZWuGeO3hO3Y=; b=B1xzti43Sn5vkfUcSoiLOVQIVTw7IR9FTO3jMCGYu7Ld50s6X+IN2YlMltE2s86yId 06gx5J3nMXn9V0ClABjjYeInQhv3FdZAxMze8ExSxLWUrYuR3oKBIdO+7zTBSeMDl0XE ITivgNgJ47DmPv3iBMrrjJ7QlFB1ZjQ+elpfeNeuWHlUpZrEKaDzBpIfMPfL1Vc2CyWj lksr4ZgTzLUy7ZXrSxtlueGguOYKA2vRYiWNPbGvFtlumwvrMSSirLiCYZLyUlHmZn6F JR8y0nFajOohnIrsvvhosU3BpSRr3EH1KERpeVH8iaAHrh2Ap/5wue2xsRMcwr2Rtry0 BeCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721722876; x=1722327676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dGFI5dxykS0Ye5JgwzTOfeSKS/2TqbyMZWuGeO3hO3Y=; b=ByCPzkycMSPtLrA1JAyZmHpM7a69KPDIwAqBVu9Cgl9u6X9b+axLr+2/93GeR95AB3 S8AqIBAQ3/dEzSWp5sNXxNBIDo2ciBICudGNi7PkQzhhYXeWLs3Zy+q/2jsDBekc5wYG vi5DHnOmrW6FyTCtJI1ZtNsa8cUOlx19tGdazSR1YKmJMq7k1jbmiE2X9KSUto7psCUq JK2pejHIxIVFXoJpS1lferFYkDKs9b97TGz83Ul6+iEcwblX6G/g4/B8i0m584xvXDCC iPuatMg2UA/blK4/LTJS1xSMVLLv+PDVJ6ZN9hHKW0NhihZBfW6JBR+lBubhwc9tiwwi vHBw== X-Forwarded-Encrypted: i=1; AJvYcCUESPOPZuq1qfFEZc3j0eZrNe7R/w4JYae5MAC0orAwF+XcVVcxy0Giv/dBbpBgkSWUgXKmzNAUy0NZEJ2QEBNB0VLz X-Gm-Message-State: AOJu0Yy3nh6wxjlzzc9bem6z2kTnU8603AjAVbJYrLS2gyd6ZzYno328 27bfRvjnJyuHLrzJL31WKdMzynCHx3WbF67mlQwLcoNzGODB+pnn X-Google-Smtp-Source: AGHT+IGn6eR1G0ifflr5Alp126/GGKm2dk1FB16ExrX39TkmK4PGK46ZNRxRIHFA3g9qR2J871nqwA== X-Received: by 2002:a17:906:7950:b0:a77:e1c2:3ab with SMTP id a640c23a62f3a-a7a4c41487dmr648638466b.50.1721722875778; Tue, 23 Jul 2024 01:21:15 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:45ae:72d0:1982:e034]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9f463194sm24026266b.112.2024.07.23.01.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 01:21:15 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, gitster@pobox.com, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v6 2/6] clang-format: avoid spacing around bitfield colon Date: Tue, 23 Jul 2024 10:21:07 +0200 Message-ID: <20240723082111.874382-3-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723082111.874382-1-karthik.188@gmail.com> References: <20240718081605.452366-1-karthik.188@gmail.com> <20240723082111.874382-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The spacing around colons is currently not standardized and as such we have the following practices in our code base: - Spacing around the colon `int bf : 1`: 146 instances - No spacing around the colon `int bf:1`: 148 instances - Spacing before the colon `int bf :1`: 6 instances - Spacing after the colon `int bf: 1`: 12 instances Let's formalize this by picking the most followed pattern and add the corresponding style to '.clang-format'. Signed-off-by: Karthik Nayak --- .clang-format | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.clang-format b/.clang-format index 5e128519bf..803b274dd5 100644 --- a/.clang-format +++ b/.clang-format @@ -72,6 +72,10 @@ AlwaysBreakAfterReturnType: None BinPackArguments: true BinPackParameters: true +# Add no space around the bit field +# unsigned bf:2; +BitFieldColonSpacing: None + # Attach braces to surrounding context except break before braces on function # definitions. # void foo() From patchwork Tue Jul 23 08:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13739696 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 042A414C586 for ; Tue, 23 Jul 2024 08:21:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722880; cv=none; b=dcOd41J9dX09Skpm3lGfYP2bVsWfDaNnOhrkKGuTaw/6PbgOnmL7cySxabEJiYoCRGjzwr+w5P1cleVGdNYCGfrERi5w914J/hqtIPu/vEK3Gpyes0amZtTONBB11UgcP8UrFdmKYxJhAvwozO3ySL2rwO0tW6hLp80qbLCBo7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722880; c=relaxed/simple; bh=f+9t1NpkVoe+I5qn36ZdOhXw0efovMxsbbnwFmTI/jE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HrV0L9JgV/PaR+ExOXoZSj4gRgQAbucgucpNPK+ZwAat7INUzChhl6RKiobIS6M2nwpGH39UTZ+dZ80rC1/MwbJSyKV8FY0S3SSpOEW6LNBBsBvTOXVY+TrR0bEmbqnJxqa2U0I4fMithwcONDkeg1dSRpBb3BtNSHV7SBWK4X0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Wp2bU0P2; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wp2bU0P2" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a797c62565aso506189766b.2 for ; Tue, 23 Jul 2024 01:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721722877; x=1722327677; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kW/pu3ynQau+YcaNh9IHKcFwebEUBcLLIFlf5rzAZnM=; b=Wp2bU0P28nUdCVgKvZ+j4KtD/rH5iABENqBA8/eGEtyCwcjW3VxcDSazgHNb3Skk7m ONhJSV//1+mcLH8U34b5szAXgIZxIFUiUtT1VICNqI8ho61iLZvxN9N4UWe5g/MCziiZ m6QX2Ed+X1LlUn+/SIWNSWeMJ5i5l3PkQwQQMGB/xG2S1U+JlKxRguun+o/7UKhANjsd aJzMBn26GmSPe92iz/kbVmqAOg4xH60tNCHfFTfFOjwWbO5L0a/0jaOZaM8DEwpM3GMh wgfIbUBEvAn+YbFMcgOJxR4CaA8beiRlVv4EYSWfKj/lsOSmBA+k+PqNJ3DP/LgFG4KU fDzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721722877; x=1722327677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kW/pu3ynQau+YcaNh9IHKcFwebEUBcLLIFlf5rzAZnM=; b=D3P/7VYsZlpUUB9XuyJSe8wkkA/PguzCxmXGsTyHHnby/MfERMkQNncnbCuX6erl/G AlQ+JLcwEzFvGnZbhGPmDmJQDlePRb3lc9V+wBX7Jw0UZ6jfXwnIkmaiHfQrxGsD4TDw i/aYRSiqVssVr/10uFC+lR49soS8uzamPR4AQkwb3+s8pe/I1kxsPgrV37cKuGLsf0YJ S/IIr7IVTxlE0KvBVJkrwTrc0j+epT/LhhjTVQPIZMHLE8AU2ZdS8DypEGuODv2IMJ0h vRGAoWNda/mjybdq6ex3L9vDcHb5yV+kVzdZ1qclpx5ijWYdXJPH2PXnExXuGvDASQkH TQlA== X-Forwarded-Encrypted: i=1; AJvYcCXBuzsI44VgchivckMsY7E7b6jHYo+d9pNbALE4ySdNv7YWoDYBCew0P+vQElURDUwi6dPirEpjsXpXyazjLTArSo2j X-Gm-Message-State: AOJu0YzhSCueYbClXJ1Vnk2+lyJY5zwAJ9ql6GFh+yLJdcBbkHCOlAue Eerpq6he3ejYEJ81y5BUAECDk6nzX5MvlNH1ds5qlbcsr3r3AknhvbovH54L X-Google-Smtp-Source: AGHT+IGJ65RLwQ0nlzO203w4QIoUjV1uk7ag4uK714v6J1taDIHGCLMZRdVqKkLuTYe7grqfDbpbTg== X-Received: by 2002:a17:907:7209:b0:a7a:a06b:eec8 with SMTP id a640c23a62f3a-a7aa06bf03dmr47532266b.37.1721722876991; Tue, 23 Jul 2024 01:21:16 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:45ae:72d0:1982:e034]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9f463194sm24026266b.112.2024.07.23.01.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 01:21:16 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, gitster@pobox.com, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v6 3/6] clang-format: formalize some of the spacing rules Date: Tue, 23 Jul 2024 10:21:08 +0200 Message-ID: <20240723082111.874382-4-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723082111.874382-1-karthik.188@gmail.com> References: <20240718081605.452366-1-karthik.188@gmail.com> <20240723082111.874382-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are some spacing rules that we follow in the project and it makes sense to formalize them: * Ensure there is no space inserted after the logical not '!' operator. * Ensure there is no space before the case statement's colon. * Ensure there is no space before the first bracket '[' of an array. * Ensure there is no space in empty blocks. Signed-off-by: Karthik Nayak --- .clang-format | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.clang-format b/.clang-format index 803b274dd5..3c8018a1dd 100644 --- a/.clang-format +++ b/.clang-format @@ -118,11 +118,18 @@ PointerAlignment: Right # x = (int32)y; not x = (int32) y; SpaceAfterCStyleCast: false +# No space is inserted after the logical not operator +SpaceAfterLogicalNot: false + # Insert spaces before and after assignment operators # int a = 5; not int a=5; # a += 42; a+=42; SpaceBeforeAssignmentOperators: true +# Spaces will be removed before case colon. +# case 1: break; not case 1 : break; +SpaceBeforeCaseColon: false + # Put a space before opening parentheses only after control statement keywords. # void f() { # if (true) { @@ -134,6 +141,14 @@ SpaceBeforeParens: ControlStatements # Don't insert spaces inside empty '()' SpaceInEmptyParentheses: false +# No space before first '[' in arrays +# int a[5][5]; not int a [5][5]; +SpaceBeforeSquareBrackets: false + +# No space will be inserted into {} +# while (true) {} not while (true) { } +SpaceInEmptyBlock: false + # The number of spaces before trailing line comments (// - comments). # This does not affect trailing block comments (/* - comments). SpacesBeforeTrailingComments: 1 From patchwork Tue Jul 23 08:21:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13739697 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B424D14C5A3 for ; Tue, 23 Jul 2024 08:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722881; cv=none; b=NnQ/ouAOW2nWpbuylFzJKHzcb4WkLucwkU6HeFloOaT1Y63rZAsL68IASngo5YyOYYLGhmyAw/LaIj5EvRQhEAxrug/C2QepgbvCQTXJnxwXqG3RciObtDsBkQqMcibtG18N4YreqyoL6BgpJ7WOH9gQLBIXqviFyxW90lFpkrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722881; c=relaxed/simple; bh=JV1siI40LndpnIDpcaC07sguvI6SKi+46aqYb3rnADo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fq8MuTNPEOR//sFzkhb0G4jtjyn99/5bL4UH+xS7Wsn6oIHb9JGMrHucrrCMsZnrpJxZEG75NIGTUOCqrsqqu7vuT3xXd2OJdrdneef7Rz1HT4vM2Y1r3O5bbjy+Iry0BAzJPW8NX31BG0qIw9WAguH/y9gPhR2grIFYqAyU0ss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Jl8Ucr7B; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jl8Ucr7B" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a7a8e73b29cso31319366b.3 for ; Tue, 23 Jul 2024 01:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721722878; x=1722327678; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OGxYvQ1YI4q+Ou8UA80fbAMtDN96R/upAdUWOi/3hmk=; b=Jl8Ucr7BGLqNBmJK97N1Lo1IzYJvy37sCOWhayh7Cn1mAoMTA9RypQ7yx4BFDcHMI5 YeEhwvpfGh3qPOf/rhodsNwwNbVoSSGE1OzgKw7o0LQhmgLJ1IFrXR8p6WlbU8mgTdW7 utGSprifYVoUhW7eJts87CDBWFVyOfIMAPeW2cYsDG9wAlRBsnXU8Ewu3zIgF9tIcL07 amu9iCJDpNo7eSbMYda0Dya6xOqIHqtVPadYUONHqid8C6kMee1HyvJUcHtE6/pn2p9G DUIGKI8fJD2tXJAbbf/W2FXdyXwOGfebPxZA7W+UoPKyQ0FUI0FINKP2v10z2CnCspFo frtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721722878; x=1722327678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OGxYvQ1YI4q+Ou8UA80fbAMtDN96R/upAdUWOi/3hmk=; b=QxSoQbRdpZmtuf71C1KehAM4uSXGp566raTw9k6mxKPDHiCaXSJSxrfnVeXPfBOIxX +uGW+xhIRSPxSCeOPqQ5GtcZTUllKESJU9bkRzjHzVcd//adlApUD5iOuc/J3MZtBejR w4ilLOojUatm/yQimmprmn2LkvCRFzzK6HiduuY+MBtHl1u/riCqOiRgEahHYOQES5Xc hSEk+y5fbAwNmn0MflLXLgBuMY2zbeMXjx79g2n5ZcwdH1XLM2jfMkcPOB9890Bha5Xy 1G0XvpqWj6L6HVCxYDDpphXx55UsszX7skAFYZivYi3fcPRG7ahHSJQWuzPxSHh9whW6 NBIw== X-Forwarded-Encrypted: i=1; AJvYcCUnkjCi85E8IQ3gzQjDPIyzRCU2UmZ3kZEZDbb4fd/p8LyoCpCdcgAM/t7XTnOp9GPa825IomPc0BoOG5UTEp4dWgH0 X-Gm-Message-State: AOJu0YysiJvTbn57zbFW/YSFW32ykVj0d6jfCfVH7f2X50Petvdy6wae ZkN9nFfBWezuLl/mo5Glfcnw7qWfB9Ut6Zm+ZcrWFpwXpNgabK3Y X-Google-Smtp-Source: AGHT+IEBj7QL76flD3I0rwcPZtRSCWU6lrUnD5Y5fq5DXO93Pa5AXMv9SVdbXnsINj57kGNBmL7OlQ== X-Received: by 2002:a17:906:c142:b0:a77:dd5c:d7f4 with SMTP id a640c23a62f3a-a7a4bf39ab2mr573074566b.15.1721722877926; Tue, 23 Jul 2024 01:21:17 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:45ae:72d0:1982:e034]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9f463194sm24026266b.112.2024.07.23.01.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 01:21:17 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, gitster@pobox.com, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v6 4/6] ci: run style check on GitHub and GitLab Date: Tue, 23 Jul 2024 10:21:09 +0200 Message-ID: <20240723082111.874382-5-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723082111.874382-1-karthik.188@gmail.com> References: <20240718081605.452366-1-karthik.188@gmail.com> <20240723082111.874382-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We don't run style checks on our CI, even though we have a '.clang-format' setup in the repository. Let's add one, the job will validate only against the new commits added and will only run on merge requests. Since we're introducing it for the first time, let's allow this job to fail, so we can validate if this is useful and eventually enforce it. For GitHub, we allow the job to pass by adding 'continue-on-error: true' to the workflow. This means the job would show as passed, even if the style check failed. To know the status of the job, users have to manually check the logs. For GitLab, we allow the job to pass by adding 'allow_failure: true', to the job. Unlike GitHub, here the job will show as failed with a yellow warning symbol, but the pipeline would still show as passed. Also for GitLab, we use the 'CI_MERGE_REQUEST_TARGET_BRANCH_SHA' variable by default to obtain the base SHA of the merged pipeline (which is only available for merged pipelines [1]). Otherwise we use the 'CI_MERGE_REQUEST_DIFF_BASE_SHA' variable. [1]: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#predefined-variables-for-merge-request-pipelines Helped-by: Junio C Hamano Signed-off-by: Karthik Nayak --- .github/workflows/check-style.yml | 34 +++++++++++++++++++++++++++++++ .gitlab-ci.yml | 18 ++++++++++++++++ ci/install-dependencies.sh | 4 ++++ ci/run-style-check.sh | 8 ++++++++ 4 files changed, 64 insertions(+) create mode 100644 .github/workflows/check-style.yml create mode 100755 ci/run-style-check.sh diff --git a/.github/workflows/check-style.yml b/.github/workflows/check-style.yml new file mode 100644 index 0000000000..c052a5df23 --- /dev/null +++ b/.github/workflows/check-style.yml @@ -0,0 +1,34 @@ +name: check-style + +# Get the repository with all commits to ensure that we can analyze +# all of the commits contributed via the Pull Request. + +on: + pull_request: + types: [opened, synchronize] + +# Avoid unnecessary builds. Unlike the main CI jobs, these are not +# ci-configurable (but could be). +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-style: + env: + CC: clang + jobname: ClangFormat + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - run: ci/install-dependencies.sh + + - name: git clang-format + continue-on-error: true + id: check_out + run: | + ./ci/run-style-check.sh \ + "${{github.event.pull_request.base.sha}}" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 37b991e080..2886f6e182 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -123,6 +123,24 @@ check-whitespace: rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' +check-style: + image: ubuntu:latest + allow_failure: true + variables: + CC: clang + jobname: ClangFormat + before_script: + - ./ci/install-dependencies.sh + # Since $CI_MERGE_REQUEST_TARGET_BRANCH_SHA is only defined for merged + # pipelines, we fallback to $CI_MERGE_REQUEST_DIFF_BASE_SHA, which should + # be defined in all pipelines. + script: + - | + R=${CI_MERGE_REQUEST_TARGET_BRANCH_SHA-${CI_MERGE_REQUEST_DIFF_BASE_SHA:?}} || exit + ./ci/run-style-check.sh "$R" + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + documentation: image: ubuntu:latest variables: diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh index 6ec0f85972..fb34ced8f0 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -87,6 +87,10 @@ macos-*) esac case "$jobname" in +ClangFormat) + sudo apt-get -q update + sudo apt-get -q -y install clang-format + ;; StaticAnalysis) sudo apt-get -q update sudo apt-get -q -y install coccinelle libcurl4-openssl-dev libssl-dev \ diff --git a/ci/run-style-check.sh b/ci/run-style-check.sh new file mode 100755 index 0000000000..76dd37d22b --- /dev/null +++ b/ci/run-style-check.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# +# Perform style check +# + +baseCommit=$1 + +git clang-format --style file --diff --extensions c,h "$baseCommit" From patchwork Tue Jul 23 08:21:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13739698 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4EF314C5BE for ; Tue, 23 Jul 2024 08:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722882; cv=none; b=m85wlGNDz39TMkej7lKc3EUhnLK5OlNNdVMyeLVIjCKuvyuSUSFKT7TJ6ymj7u2mFnodXER+WEaPklxP3JKwZKESo5gLz1G5t5IcnjGjiO6UXUcX4yqxFcWzOS/nEmZQ9Sgu9kfy2Yf+nI7vHs54vwyG3Z0SW5CeLhpfd2uFA5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722882; c=relaxed/simple; bh=Nq2gQHOt3+iv/onpyhuqMUsh0pzFBJgBgB9/8GhItd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OWhpWtYswQdCDLuEsf0hCCEwXdnbHoiZ+5C45YIizbR0i/mKf6GeoWNOkqHZNhEZR4fe3cPFNDfzf7crXFSMMPN/6hBVH4uSZ06HW5C6cn3sedkkH6x+BZROkM3buGoplqAQzzZT/5Igbzf5oKa9OQ5BgemVztAXffsKiXPzeko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XP/X1IyC; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XP/X1IyC" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-52efdf02d13so3806170e87.2 for ; Tue, 23 Jul 2024 01:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721722879; x=1722327679; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mdyhr1kzlIaak5G6Svq4JUsNhcAc9DMgdapf/v/PS4I=; b=XP/X1IyCmpyY8mbXktl4xsubKb4c3L/GHoWzyyuJIxQW4MhyAFQzbvz3mAJdv/2hQA J8mIWAnLFKrYe+hYJlggupI6HyIFdWTcwedmRamRQbJ7WDGs0T8Ni2OwexPxIl8WlOPp W9rAFrn2V8ocG2sOs9SfmxlH9xhMRzi1N7Zy4sCuh+z+c5G59CoBwJXMjXHEh9sebQIg jQEZO7DfJUfUTJmAV4Y2+j4wwIuD8OddfkxaF9/Ep6C4sHAhHeG6TMJ1UuKtMVTsEK/h QPrGKaMA4C/Obe6/OuBv2QUPQtA+lajDFXCPEMgS/dG1e4Ae57OrqMTuIyl0eqqeEViJ o4bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721722879; x=1722327679; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mdyhr1kzlIaak5G6Svq4JUsNhcAc9DMgdapf/v/PS4I=; b=mH1TTf6gnVPOIt5Dx9X6jcOYmQBOPctKburHEmFFj5zGCK8Y1f/LfITKUe2YYDeGmT UKhfPgRl+ngRxijZw8AfEfZ9yItwlFvamMhxamr7XJvaSb5BrEMLrRBQArMvmXE42QeK KaxcgEMALGgpDNQjoLS60oq5UycTP4rMPKTB34k7LKj/UA8Irjh10sVO2ltIzPI2Bl4G DTHnAd5x1OFqLK8zspjrNKOWXkeirAjTGx8zeGwaWpOwpHXWTuFSdI7B3ZecMSAeVSi8 R7OV6NNSpgduBz/i6w89Ys3yFs9FA+gsPOXs+9fCcN9zALpQY4rjZQyJ/vQXCejhACWI aPDA== X-Forwarded-Encrypted: i=1; AJvYcCVXLwqAtXUMTCh0CU3Un/fO/NR9LsFq2o2Lgu3TB9XvzNdM3+qQWY6J989Ze7B4cGp4bmNyfbLRAdhLxd2ljHz16XqF X-Gm-Message-State: AOJu0YzVEbMV1+N6akIbtQo6NiuE0T81iMszqfIzLsehWguNUm/KT8Ov tIPSgjimNcvMZdLSC+PtPBG4IGyRSmTmXRvrxEuMHDw+Hu+7cjhBOHNE7Wwq X-Google-Smtp-Source: AGHT+IFymH2VT1R+On9bfWfWUO2Mi4tyfIyxxk/ingkS4m05v717dyUnXnpvRYKSpqLtDXAZAr5pdw== X-Received: by 2002:a05:6512:1317:b0:52c:d628:c77c with SMTP id 2adb3069b0e04-52efb7ae1b9mr7395973e87.43.1721722879089; Tue, 23 Jul 2024 01:21:19 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:45ae:72d0:1982:e034]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9f463194sm24026266b.112.2024.07.23.01.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 01:21:18 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, gitster@pobox.com, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v6 5/6] check-whitespace: detect if no base_commit is provided Date: Tue, 23 Jul 2024 10:21:10 +0200 Message-ID: <20240723082111.874382-6-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723082111.874382-1-karthik.188@gmail.com> References: <20240718081605.452366-1-karthik.188@gmail.com> <20240723082111.874382-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The 'check-whitespace' CI script exits gracefully if no base commit is provided or if an invalid revision is provided. This is not good because if a particular CI provides an incorrect base_commit, it would fail successfully. This is exactly the case with the GitLab CI. The CI is using the "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" variable to get the base commit SHA, but variable is only defined for _merged_ pipelines. So it is empty for regular pipelines [1]. This should've failed the check-whitespace job. Let's fallback to 'CI_MERGE_REQUEST_DIFF_BASE_SHA' if "CI_MERGE_REQUEST_TARGET_BRANCH_SHA" isn't available in GitLab CI, similar to the previous commit. Let's also add a check for incorrect base_commit in the 'check-whitespace.sh' script. While here, fix a small typo too. [1]: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#predefined-variables-for-merge-request-pipelines Helped-by: Junio C Hamano Signed-off-by: Karthik Nayak --- .gitlab-ci.yml | 7 ++++++- ci/check-whitespace.sh | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2886f6e182..2589098eff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -118,8 +118,13 @@ check-whitespace: image: ubuntu:latest before_script: - ./ci/install-dependencies.sh + # Since $CI_MERGE_REQUEST_TARGET_BRANCH_SHA is only defined for merged + # pipelines, we fallback to $CI_MERGE_REQUEST_DIFF_BASE_SHA, which should + # be defined in all pipelines. script: - - ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" + - | + R=${CI_MERGE_REQUEST_TARGET_BRANCH_SHA-${CI_MERGE_REQUEST_DIFF_BASE_SHA:?}} || exit + ./ci/check-whitespace.sh "$R" rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' diff --git a/ci/check-whitespace.sh b/ci/check-whitespace.sh index db399097a5..c40804394c 100755 --- a/ci/check-whitespace.sh +++ b/ci/check-whitespace.sh @@ -9,7 +9,7 @@ baseCommit=$1 outputFile=$2 url=$3 -if test "$#" -ne 1 && test "$#" -ne 3 +if test "$#" -ne 1 && test "$#" -ne 3 || test -z "$1" then echo "USAGE: $0 [ ]" exit 1 @@ -21,6 +21,12 @@ commitText= commitTextmd= goodParent= +if ! git rev-parse --quiet --verify "${baseCommit}" +then + echo "Invalid '${baseCommit}'" + exit 1 +fi + while read dash sha etc do case "${dash}" in @@ -67,7 +73,7 @@ then goodParent=${baseCommit: 0:7} fi - echo "A whitespace issue was found in onen of more of the commits." + echo "A whitespace issue was found in one or more of the commits." echo "Run the following command to resolve whitespace issues:" echo "git rebase --whitespace=fix ${goodParent}" From patchwork Tue Jul 23 08:21:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13739699 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6E7D14D293 for ; Tue, 23 Jul 2024 08:21:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722883; cv=none; b=gqSiotzdIpSsYKc0hMYXUjccNrSe/WnkAEOV5Sq+VPAaVlu+DOxRLzgr9vPVjyuoFF04/4wyywpTtHuJ9gWAPTpKRhrsZ43QhzVwhXhPMBtH5QFzdtzcevJ3RG4RXxTctcROuCjX9Nz8kZi9t3veZ/N1WfPHnkPHYNYVh4NQSeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721722883; c=relaxed/simple; bh=GihmzoGpXQcJWWVBnIdVZUVKWLXaKUcn40FtEz0KU9k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V4lPL250DG/G7mjUCOocE5oJRDfXSBsch9DLXK0+VNtvJUq9yeDmjbpKI05UUGTkInXRX+iBkHz+8flLc8HJcIdzCKc3lHynnQtmJC5uQa92MJH1qNc6GmyUMjAg3v7E17MKhbwtsXcOMmPZtgWX78RwDM4Z3yqSzUYK/uHL5Qw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HrhpTFzH; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HrhpTFzH" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a77b550128dso532750766b.0 for ; Tue, 23 Jul 2024 01:21:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721722880; x=1722327680; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QdJVQPxnX2ejLWnSEXYE14wHZC6ZGRrq/+9puE7yOEs=; b=HrhpTFzH2j7ddcGK7Ag2//UUltBe98hnEv3d6Dca/MQ7Fv6e/JvxQRMmhL86HnUsvk dotuINjIzuL4ebMc8J5K3gm1kqvVGPtcJ54hsCh+bEuf+cbz4EjAdZJTYE40YxKntsln JMcXo+hUX7B61l2eqb7yDtD7zusXpDNU1kKqE+w0TbvsreOqVQqwN/+TBisPw+5pXihX 2iqdkMYcW9IQiYvhfIdEZZfxuXbCQe+FdkfCTxYuKZrLwaMk0ljt6NZgYp18XL+e1MfE BkB7VbbzkeEfWk6tcKv0Yk9nyx+a/PndQZMPU3bC/tLowIOA+atvNeznJMUYNCe5+Hqa 6JKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721722880; x=1722327680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QdJVQPxnX2ejLWnSEXYE14wHZC6ZGRrq/+9puE7yOEs=; b=vpbUOFYgNmiXGi4iZCpxzg1a+mDrIqqdxc8D0VD2o38vcnFnJsTS8ZBUrEvdevw0zJ bO+PgTDu5+wxYkiUrQnjgEQM7ia/0EQRkVDnhdaPBQdx96JKDG5kI4b0KFFPmA40r8VJ zL2q1uRX/6dhzU3637ZvdHrHGcagSSUtepCyPpfXGvkXEsqGNa7jS447lbpAKoP81AdF zYdbunvlGvrdw/vtHh7L2TEC/rz6oybZhFVdeixyDjyknZP71J02rjT+GHrWi82g3CSq dTiJ+JIFMofvBQAdm9lzZ6/YWO6cKDlPJW1+nk+Z18A8NLUuZrfaFL7fX9UAzjQPWdZI NF8g== X-Forwarded-Encrypted: i=1; AJvYcCXptyI11YfUv1Uda3RCMrwGVgVoLZq7XFdzcG1oyhFcKgC6xsyBgfvxJ2V764KiBZmP0VgDstONY+VFvtYL6kxVXWpi X-Gm-Message-State: AOJu0Yz9geF7Z8rKk78A4KHt6MC4Ztr6L3NG8OxcIQiq4zPACK+GVWoO faQnluwB8/sxtv3cvrXHxoO4PAOozlA0Me0xy91BxEx7O+sQMxJQ X-Google-Smtp-Source: AGHT+IHeh5EGTlJ6Qo/cA8des6h6VT1+GoDzUrVo2HcrkLsUGT9tFtrYHVzzbxRibsLEPQMFoyie5A== X-Received: by 2002:a17:907:2d8e:b0:a72:af8e:15af with SMTP id a640c23a62f3a-a7a4c3e3f3emr692897266b.49.1721722880011; Tue, 23 Jul 2024 01:21:20 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:45ae:72d0:1982:e034]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a9f463194sm24026266b.112.2024.07.23.01.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 01:21:19 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, gitster@pobox.com, jltobler@gmail.com, phillip.wood123@gmail.com Subject: [PATCH v6 6/6] ci/style-check: add `RemoveBracesLLVM` in CI job Date: Tue, 23 Jul 2024 10:21:11 +0200 Message-ID: <20240723082111.874382-7-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723082111.874382-1-karthik.188@gmail.com> References: <20240718081605.452366-1-karthik.188@gmail.com> <20240723082111.874382-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For 'clang-format', setting 'RemoveBracesLLVM' to 'true', adds a check to ensure we avoid curly braces for single-statement bodies in conditional blocks. However, the option does come with two warnings [1]: This option will be renamed and expanded to support other styles. and Setting this option to true could lead to incorrect code formatting due to clang-format’s lack of complete semantic information. As such, extra care should be taken to review code changes made by this option. The latter seems to be of concern. While we want to experiment with the rule, adding it to the in-tree '.clang-format' could affect end-users. Let's only add it to the CI jobs for now. With time, we can evaluate its efficacy and decide if we want to add it to '.clang-format' or retract it entirely. We do so, by adding the existing rules in '.clang-format' and this rule to a temp file outside the working tree, which is then used by 'git clang-format'. This ensures we don't murk with files in-tree. [1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm Signed-off-by: Karthik Nayak --- ci/run-style-check.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ci/run-style-check.sh b/ci/run-style-check.sh index 76dd37d22b..6cd4b1d934 100755 --- a/ci/run-style-check.sh +++ b/ci/run-style-check.sh @@ -5,4 +5,21 @@ baseCommit=$1 -git clang-format --style file --diff --extensions c,h "$baseCommit" +# Remove optional braces of control statements (if, else, for, and while) +# according to the LLVM coding style. This avoids braces on simple +# single-statement bodies of statements but keeps braces if one side of +# if/else if/.../else cascade has multi-statement body. +# +# As this rule comes with a warning [1], we want to experiment with it +# before adding it in-tree. since the CI job for the style check is allowed +# to fail, appending the rule here allows us to validate its efficacy. +# While also ensuring that end-users are not affected directly. +# +# [1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm +{ + cat .clang-format + echo "RemoveBracesLLVM: true" +} >/tmp/clang-format-rules + +git clang-format --style=file:/tmp/clang-format-rules \ + --diff --extensions c,h "$baseCommit"