From patchwork Mon Jul 15 09:30:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13733159 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 7D36F186E51 for ; Mon, 15 Jul 2024 09:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035854; cv=none; b=cgT5Xq7NSd7pohQJwhdU6dPdYIdMYyAcq0f/H/m6o9uDwnceKpVkwpqOT/uOzsRQt9ykxU+16GID6JHM6YDss+JnY/qK0yuMEUXrtBFHVCci3T5OsrklrXlrPKgk4dMXV9DyoEyp3oe0rWZiTyRYSGkm+UD6Mh23VzGP7wQxtgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035854; c=relaxed/simple; bh=fXYkwyyNJCLwx/1+LXMILAXgVK2bnFuuMMrPjySB8G8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OgUYJAZxmZXxyoU2uJtthfC0BEvKR89CSMYetfprED94i0vIIpyDUVNgma8yIo48xdIbfTaWMW+LwbKsMglxyw5faFDtF2t3Cafo/1NdHFwLTRlRuz8Hf4dPhCHxvPgShWiUoSimeWnVC7YKX6Q4uXg4zQ3Rgj9PMoWriE+4A9E= 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=bPAp3wec; arc=none smtp.client-ip=209.85.128.54 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="bPAp3wec" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-42797289c8bso29556065e9.0 for ; Mon, 15 Jul 2024 02:30:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721035851; x=1721640651; 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=bPAp3weccLAmlWnKsTghkQban92EeWnMAnoq2k+f28WglUcXIRhpO+F+9R6A2bOqIl pA+aIq90PairdihJ4ylxTHM87FqbVTne+KlpdDNQ/YV9W/hJqdXVpYcQP0amBiWdLJBF JLtTk+BG9bEHPJhjGZx9VIc9NuPcCbJ1WMqtEm2okTM7Q/Ny2sP7hJyBotkzm23w6Ty3 iS0HIZZ3owC9yyMkExitoRND/g4J0uuXu5nXWteSRXZ/mciL7mtTW8PZP17/+mfQXMbp UarcsuATMN/0UM36aE2EBaLeHZfgWchDmFebsVwYc6j6nvnwdLck3o5CmWCMLr2LbtJj lLYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721035851; x=1721640651; 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=Q6E342MYYsvj9ZxSSmgMlLXwcLtHp+EtQtOlC2RWXr6qIfiAO+vc+dZm8AjHC+QMc7 g1SzFdo6t+rOebl6SWIfuq6UDN/iXc8ylXXdVWkZ/gzxhCoXFnGmJeIPurD97aKvP6ie +HbCljAfItiN1dbon+n1A3x3wkekT8SeBaihNgunv3QCXHKz7RWSx7mnt3lrrGVUAwS4 I+15PMPrYDzmPLw+ScAGcq3vkYgmjXeFh3Mg3WZuevWJTNwd24duYJ8yqZBybq1RLgff rcOYhxSnzzjS6pwvIYgRj6Xnz7IVTTWMHSBSxz5mDKOGoGBPMxI7d1kSBY+PoFyFxcVM rlFQ== X-Forwarded-Encrypted: i=1; AJvYcCVmB5QheXg13DMBTo5p8O2ISHfn7kqLXWilQXH20vfHtpf1mp0dV8c/+zs7JHjwMXvXW6CfAvOmLEv+NC96Ei41L8uJ X-Gm-Message-State: AOJu0Yxct9oWua62soqXerIjQipHug/OiKbckSVdYQ2kEXKOY1AijCEc I9eH5fLjMaItR+MLwGMQ2u+itUC1GVBtrlLzjtwNX6QgEOTO7C7v X-Google-Smtp-Source: AGHT+IHAwopgnsQJjlg513Kad4P9S4YsIV+6Fa3iTCOWY0/5YrYxFJUZircO5aNZVaRaza0l3rpjvA== X-Received: by 2002:adf:f98c:0:b0:365:e76b:e908 with SMTP id ffacd0b85a97d-367cea68090mr11519822f8f.24.1721035850808; Mon, 15 Jul 2024 02:30:50 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1a3c:da7e:77ea:d1ae]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf19sm5745208f8f.68.2024.07.15.02.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 02:30:50 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com Subject: [PATCH v4 1/8] clang-format: indent preprocessor directives after hash Date: Mon, 15 Jul 2024 11:30:40 +0200 Message-ID: <20240715093047.49321-2-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715093047.49321-1-karthik.188@gmail.com> References: <20240713134518.773053-1-karthik.188@gmail.com> <20240715093047.49321-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 Mon Jul 15 09:30:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13733160 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.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 8F546186E3D for ; Mon, 15 Jul 2024 09:30:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035855; cv=none; b=hzssex4GCe9Elwtr2NJQa5M5vaflSqjD0aAimjWYJH7CvVpJyRLDcka206C8FF/mIGvEg19UpW/iJpZztCU9Efg2Ye7HBZUlV0yimld0OHcSP8316InIgjh2FX1kt//omArPn+j1UZ+9caul0UjG3MOVYFQ0TUkS/eem/6cg+lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035855; c=relaxed/simple; bh=c57a5FZo8oc1XwZXmAykTqE3C++vUFM1nNGdVk7APJg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xgde8MRKdIk0NxDXp6SV4XOWfrQetAEuwvJNkDir9Bb1ilPNEDxpC1teZpM9PSfnCdPwbBYrGONYD3+BnMSHh59qtbW8j4YpPCAre2XZ3VnzOSDWGIQP8OHPFjh/fnUIY/q97EfiBwClSwgOXfrO8gF5+BGKzVFICjHFzLLHzig= 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=QOEnVvXd; arc=none smtp.client-ip=209.85.221.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="QOEnVvXd" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-36796aee597so2428307f8f.1 for ; Mon, 15 Jul 2024 02:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721035852; x=1721640652; 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=QOEnVvXdZtp8zcmUKknrxBiaKIVmRORs2oz5+TTnh9K14o7YGFih1/Sir7hjtKmK16 8oMlFm/kkaAMELVLSETULcXT1vzdoUS2NDbUNu06RSRSST4uFvS4id2TSCH+K/vifT4r xyVGN3ibN8uG6ZS7+sSm12D4Dd5mbqx8bfThHnT3Vbkpnp9K7L6tXzsn86bEjI7Tvc3a lzn9M2HQGKWsmfI27dKXE1xhnbsnqUaquDHwcLTKZdCzIXYNresFGP1DYVDQ7YyhI36e X0SmtICVHVBvkHMeFmkOVmRTjGba5IuyClvzK/L2zEhhm2mW9WQ21LPtcKQuibUcKGvT +vdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721035852; x=1721640652; 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=KB6H4T7M6fhaqNhHO67UfnXOh+V9oJQxnGj09JnHHGdIxkt/XPIZRkiC2krWz6IUR9 F8NNHD6ImmchgCectq5p4zLfcqx9VQR94iFhvzgUdWwfvz62MyFUlOuQT6yG2zlovt9W CtO5K/Q7dZsPP3mQTCoJ/O9zRJfD45kbGXhSz+wyli0snQfRJktnDyucVgCarv0UYwLz rk/GqmjQ7hSsQtPlL/AZMdwtiadmkPSyz1cqb24DElHn8UXsJ8rvx9eHT71tKDsfxTwv cIX++t0ybrtx/XigZ6eqqYDG0HvntzyFQOyoadhnjLPhL7jRpxh4gYCbzm5vvv4NfTrS ddFA== X-Forwarded-Encrypted: i=1; AJvYcCU+cUZIXKxKyVt1j6pMqpBVFTb7YBv8qpMBj2KvslWL8iT/CnC/stpP063OgYx6SxsIfAUaeo1Dzkp/4wktBYKRC1GY X-Gm-Message-State: AOJu0YyUmnOmg2M+CJQTJ0AWNsZwGqQmB/FNYhFHYojPbfHuz4vfaSYU 0LE+gajZ49aPXxOZJB/6u9I2oFwl17F+O0UsH6k0pD/A7f83GlHG X-Google-Smtp-Source: AGHT+IH0tE0D6QGATeJzRoOh+ZISeVGAlbUi6Avt4A/j2TN0v6mXW8BqPu5+mKKkJbiyo62FIoJJ8A== X-Received: by 2002:a5d:564a:0:b0:367:8811:5e3c with SMTP id ffacd0b85a97d-367cea6b768mr11028660f8f.20.1721035851706; Mon, 15 Jul 2024 02:30:51 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1a3c:da7e:77ea:d1ae]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf19sm5745208f8f.68.2024.07.15.02.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 02:30:51 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com Subject: [PATCH v4 2/8] clang-format: avoid spacing around bitfield colon Date: Mon, 15 Jul 2024 11:30:41 +0200 Message-ID: <20240715093047.49321-3-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715093047.49321-1-karthik.188@gmail.com> References: <20240713134518.773053-1-karthik.188@gmail.com> <20240715093047.49321-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 Mon Jul 15 09:30:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13733161 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 8B55F1850B5 for ; Mon, 15 Jul 2024 09:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035856; cv=none; b=nKjpl2yrJzF1Y4JMlE+xhLTvVbJOIGI9m4pbwbQ1P/hvZXDKf0vpgO+T9YQxQem20L8nZeew4+2dh+DNgofOwhVj5vR6xeVrnRzXafzfe9V+jLuCFYh7+4bQKw3c7TwGeNwK/ERhC88gh7zuCgQcNIsSSw3bDeq63WnSY8nROeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035856; c=relaxed/simple; bh=mGKp73t1gDNv5XhEYpbWC9ylOVN74pdxUlMqwbrFvRs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rwgUQO7/6KoXZV6MbJNPdgbk2/4J52p9Hi+M60OQpp7EbTyITqIDDknTRSX/ILxuQttzXfyOo7cc/j27CKU5Z2tpFQ6+LKHfpGqx1UH9DAckTgj/XfxBg3sntagYYn2VCichi92/EkVvrQVF1vZlPexLxwWVCg6PVgXVxZPonko= 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=cIo+rX3O; arc=none smtp.client-ip=209.85.221.52 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="cIo+rX3O" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-367963ea053so3390459f8f.2 for ; Mon, 15 Jul 2024 02:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721035853; x=1721640653; 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=QEj4J1duXKauf+ZuSbER3cN37XrHK4JaDZdLoIf88LY=; b=cIo+rX3O60vAHHNmGmq6oQf9+hgW6AUCEyTQF5bm2PxOYOs2+RdtspDPlGKcYXNDva yIUQ1u12QVuCQ/8bTtRhoDfytxb7PdKDglRPETtBBDi96KUfhg+ls+x2Q6qr9NLzFGMO fReF11C+R1TGR3D+IMlZuaML6ozrO9Q0MPqHzC0nOX/6tp0aFRHPLPThkaVU97lElT6n ybXGgFu6TDWrF8roSEE5cflP8sjsVWKhnOpYznHox/Ab+6+By2aLqJMMY2TflwF3N9X7 LITmKLnJIpb9m9Qtpth8yJy7qkw/ByOmCII1eUr6qWTh0OLE6Jn7k40M46Vgz1dvpyl6 8GBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721035853; x=1721640653; 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=QEj4J1duXKauf+ZuSbER3cN37XrHK4JaDZdLoIf88LY=; b=RNRr3AZ6rSia9dSbVxLxvluEwfR8q5eTPgLbFyFlHcv9lqKSKJvpRDojmnNJSvjc/c xyudQktTcmK5+330BbYUDp8DlzWhzIZ/xIPq/EL9F38L3Qhvgo6HCXC11fNHrysj7N8g C2Wr0vISDV3drW07vWY36c9OCXDx5/cidaHhl3ug3t2y7Mbo6DAspw+MIkinS4WmREpg DxSb1v/i/3wKA3FskAFoA3dPuHz49wHdX84bHICQZf/RcjGumtUUM0wI3Sy0rV3E4l6G oRq8R7xdMEiYidk6JRRlSJItpOxZyJ4QivimDrl9jaJ90C+jjTRrkfhtoW/O/C/t8Hky uTKQ== X-Forwarded-Encrypted: i=1; AJvYcCUoW3jTAYbfo3iVGxA4vkOFOlmUTqWe2qORDN6GMz3eXv++CYC3eMEQW3QQ/JUs/JakfC9B88GvOQbOI+HTL+zIEQin X-Gm-Message-State: AOJu0YxVldpQTHt2GCggDv99o+vawYzGsrt+Du/hStTNXNg0tBlfG2XW ukBQf0ylUf+VK32ItsNd73vFY56mjrvDTI9CfKrkGD6VuqR+wKwy X-Google-Smtp-Source: AGHT+IG6uQPnzHaC8iQeboLuBmmKVP+sGWCBHlWiWpzOMXbTx+9hGET/T0v65cQic5IAaqyvAeX2zA== X-Received: by 2002:a5d:4703:0:b0:367:47e6:c7d9 with SMTP id ffacd0b85a97d-367cea95994mr15000134f8f.33.1721035852703; Mon, 15 Jul 2024 02:30:52 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1a3c:da7e:77ea:d1ae]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf19sm5745208f8f.68.2024.07.15.02.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 02:30:52 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com Subject: [PATCH v4 3/8] clang-format: ensure files end with newlines Date: Mon, 15 Jul 2024 11:30:42 +0200 Message-ID: <20240715093047.49321-4-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715093047.49321-1-karthik.188@gmail.com> References: <20240713134518.773053-1-karthik.188@gmail.com> <20240715093047.49321-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 All our source files end with a newline, let's formalize in '.clang-format'. Signed-off-by: Karthik Nayak --- .clang-format | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.clang-format b/.clang-format index 803b274dd5..4c9751a9db 100644 --- a/.clang-format +++ b/.clang-format @@ -106,6 +106,9 @@ IndentCaseLabels: false # #endif IndentPPDirectives: AfterHash +# Insert a newline at end of file if missing +InsertNewlineAtEOF: true + # Don't indent a function definition or declaration if it is wrapped after the # type IndentWrappedFunctionNames: false From patchwork Mon Jul 15 09:30:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13733162 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 88E3318733D for ; Mon, 15 Jul 2024 09:30:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035857; cv=none; b=uGG47WpuwGyAvYTg0jMdwYp6SD1JGiVdWeNro9x+3win2TEIqMm5/Vt/OWara1fpgV/CBMCKG5KGPDPWIOUgCgC+Gr9iwOOVpWmcfKIUm5ewbZeTiBRqn598IwWflBx7Jk7dsvZtbNXCs2K1S1Phm5uPtdDgQqc1bx6UgjZb8iY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035857; c=relaxed/simple; bh=S7Zo/NpUORndOH2vsbJ5V3SdVDxmqCwBMRY0KwgBPmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZJVoYZ70mMGS1kohX5/au/nIwooYxjg7VlInhL15IO1hGqTVXS0PEiPpiRhRRzFSIVHJ4ZfRfSlYhUjm9i0obichskO/DK8xwi2lF+F/0lDbr//SKVMhMEOI1d6K0i5+XadKkd0ililySSEtUUbWI5oi8Tpdfz9i5lUOBAlPygU= 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=l8i3S0Sk; arc=none smtp.client-ip=209.85.221.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="l8i3S0Sk" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-367b0cc6c65so2523498f8f.3 for ; Mon, 15 Jul 2024 02:30:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721035854; x=1721640654; 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=0wNgL1+hL+/hGwg4Th2qpdX12s/4q4BWBjTK648i1So=; b=l8i3S0SkTAy1RJOls9vQBDzxYug1Fu7XsJT+6XWQbTiHWHmQ6neYJXuGUxBnIuN1mw i1mgn3b4LeuCHtbg3Mc09eI+FbIgHYR7nPeC6B03FFueH42c6VbGjYDOlGv+scN0a57j hM37kLN92XktvmN3d4VmzxHtrXQBEjUk1Y5gFncuB5NlWd6v/3ncBiJFVXD9QVPBN213 SmPpayd/0iS5HuIUkuxIs+TJlUocjaxGW63KDEYSISkRkkUwE2J2QfqZljcvf57nFLBZ zTIgXAidQRcLoRE7cpycP3wnATQ8+9dRfzbGfJy7Q39Ykv4eu/iQNsADCZjfcrvw0gZt uEUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721035854; x=1721640654; 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=0wNgL1+hL+/hGwg4Th2qpdX12s/4q4BWBjTK648i1So=; b=mmzBg0ry8CmxDNg3uj+EJqHiC738ANHfkamjjbc2RQLKQj2cjGnTQbGbF+d0S1XtOE PXI5n+LFifGTBHsI5rlEyJzdvCi8G6zQLwfeN6lkhGrvgfd+F2nynx4ErwnB1KxS5duH PKZ+eSL9Lk5VoNwUunFKV3QPShIwxcb3NhZ6TWqrZk+pbKNVPBHDsFbhW82x3bIR0sR8 lk0zesEZtg6QRsjwsWrLvO5M422xaVjH2k7vft7IA91sGSVP59gYGG3vd7JQ9eDD2ds/ UFptgGRtCTDhq/NaEopVnmw7oOK2mkTZcmrC0umbFohquDX1IpE7zZWgWHolo6OrfAuz y/og== X-Forwarded-Encrypted: i=1; AJvYcCXx9MrK+MHq+pXYnvF6G8AUYjHpnUoKBPkbwkkoRgmwnytUpzfSxWzLboHWX7ZPEVop9YdAnCiiznWBo1U4Oy3tUIA5 X-Gm-Message-State: AOJu0YxpcXdbcW9UA/WfSum9DcD0u35R8CbyTpvZKtr562GXqZHnLzYg KEmcuJ1FhlHsMItnjIqf+530Ej3avwNpo80EHgFLneQxrVEXuCjV X-Google-Smtp-Source: AGHT+IGjV0APN8PFM5UNLr9WTbIhcfqAnsSFu0SPEyEp5W+CXVmT4rXz6DaIy7g96GEvaNsy2Ke0nA== X-Received: by 2002:a05:6000:178a:b0:367:992f:6037 with SMTP id ffacd0b85a97d-3680669d9ddmr6813046f8f.16.1721035853900; Mon, 15 Jul 2024 02:30:53 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1a3c:da7e:77ea:d1ae]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf19sm5745208f8f.68.2024.07.15.02.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 02:30:53 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com Subject: [PATCH v4 4/8] clang-format: replace deprecated option with 'SpacesInParens' Date: Mon, 15 Jul 2024 11:30:43 +0200 Message-ID: <20240715093047.49321-5-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715093047.49321-1-karthik.188@gmail.com> References: <20240713134518.773053-1-karthik.188@gmail.com> <20240715093047.49321-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Replace the deprecated options 'SpacesInParentheses' and 'SpaceInEmptyParentheses' with the newer 'SpacesInParens' option. The usage is the same. Signed-off-by: Karthik Nayak --- .clang-format | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.clang-format b/.clang-format index 4c9751a9db..914254a29b 100644 --- a/.clang-format +++ b/.clang-format @@ -134,8 +134,6 @@ SpaceBeforeAssignmentOperators: true # } SpaceBeforeParens: ControlStatements -# Don't insert spaces inside empty '()' -SpaceInEmptyParentheses: false # The number of spaces before trailing line comments (// - comments). # This does not affect trailing block comments (/* - comments). @@ -149,9 +147,10 @@ SpacesInCStyleCastParentheses: false # var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ]; SpacesInContainerLiterals: false -# Don't insert spaces after '(' or before ')' -# f(arg); not f( arg ); -SpacesInParentheses: false +SpacesInParens: Custom +SpacesInParensOptions: + # Don't insert spaces inside empty '()' + InEmptyParentheses: false # Don't insert spaces after '[' or before ']' # int a[5]; not int a[ 5 ]; From patchwork Mon Jul 15 09:30:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13733163 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 A493E18734C for ; Mon, 15 Jul 2024 09:30:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035858; cv=none; b=GE7xsgo7kkjJK5UNbILREYoyIC0V/bEOgQ/kSYKpyA9IzFQB2lfPG1FFps0yF5xpSk3/qwpyBMp0FnFJsq894Ywy5i3TPB0AHrRMhuJLfw+NDSlCVEHp1DACmkXN7vDROTpFATiyzYWRGwQLZQA60f6a+M/jKNMnfVQ4DeerJ2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035858; c=relaxed/simple; bh=NKLRjRIvuJP94W+tCj4VNJ0/Xh/FWZbhInoDE+UGwyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bMeGB3S331U/Zhsd/PJ6R2msxh4juoML4sIXfxs2/9i2+W/oJNFMZmOIvE/8Eut8+ewq2kZ1sSONtBjczIlvjLXq1kKFQGMWkqPRW2o1bvHnmQdHrkp7GutWmo1OqZmpTw8Q/AWum4HPLAdTv0//fIjDO4oEhxRL/aZWE2EiTgc= 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=kfTpuYRv; arc=none smtp.client-ip=209.85.128.54 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="kfTpuYRv" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4266ea6a412so27510615e9.1 for ; Mon, 15 Jul 2024 02:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721035855; x=1721640655; 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=KWpRRpBwnZmw3yWd0ypb6JPNeFDHxwHjwgCkp69QJus=; b=kfTpuYRv2OlTZSc2TCFvoJT678jx5AbOXi3T69yYqtpVoqdoiOpFzIKRoIOjx6ZXAi 331Fa1kE/jovK1fmyP9Jazi+hOhaWG0q2C1G2OKu9/GM6kYWitI/WSAghO8A2NSa0Fhq zYQzBoRHCCZrIzWlksM5gtkoS4JfI6yCcgHb2z3EdAQY5SFnR2Wz/4609ndK11CKa3AX dFBp8tMzVJi8BGlQftQ+UFvfyMNn4efEwQBhgGSNi5maRjgWxq+K0UoM89UiOKMi7Wxp EwMOnBivPXv5pa+sdxzjzT7qRgrEHDY3FELfa11rKZahmamvoYs4ZoweNfmi4EAU3nrC 2CTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721035855; x=1721640655; 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=KWpRRpBwnZmw3yWd0ypb6JPNeFDHxwHjwgCkp69QJus=; b=qGy1BR5KXp6saUMEX7YDFfrOQw+DR2uAcAcVasLMReP2HTPjm8N8dZF0UUsPSyaUPh nQHsjwC8pr3VNOhah4KSvcNKcXvaAbcxQIAtZwJof+iQa7+y0Y0EkgOqwKSqvLzL0ATu u64wwIR9zumiRDKpPBjn6mZcBanjNrlgL+6TqbV9pqPeYUN3Fong+VR4GuJZ0UGeragA C006vVK/NgzuIC4AFkPDTok/Iwws6qYZwNsjFrmypJxbyROn57jI/BHhhXivvrGt0AMA 5YKeuEUmve3q2O7JFUUOSEb+k7Mlz9d72Iy2t0Fh/osMknXuatirfLCWhDoGL+u8LBJq Qeww== X-Forwarded-Encrypted: i=1; AJvYcCVsDN5hkLL4maap4LEFuIR7NpP8TZawssA7g/50prNMxyAtJ84JdQW1srEMq9yNbFGjgro7XF8d7id5LkUKuXKL+LzJ X-Gm-Message-State: AOJu0Yzsga86GVC6NudHMScYkgvMCn8eVrQZ52Av0rPWmdIHfqui/FTI J6AsgbFQA/RDU1fLFctX8W9bI5wDb7UofCxkC5kWHlG6p7Js1g7e X-Google-Smtp-Source: AGHT+IF9QdwqnUr8MwH53SZgXoABka+Xwfi2roFrFiTfjShW2JjCeq0UZPQ2lrDYefFScqYl9SXz8w== X-Received: by 2002:a05:600c:2154:b0:426:602d:a246 with SMTP id 5b1f17b1804b1-426707f7e2emr136616365e9.32.1721035854921; Mon, 15 Jul 2024 02:30:54 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1a3c:da7e:77ea:d1ae]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf19sm5745208f8f.68.2024.07.15.02.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 02:30:54 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com Subject: [PATCH v4 5/8] clang-format: formalize some of the spacing rules Date: Mon, 15 Jul 2024 11:30:44 +0200 Message-ID: <20240715093047.49321-6-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715093047.49321-1-karthik.188@gmail.com> References: <20240713134518.773053-1-karthik.188@gmail.com> <20240715093047.49321-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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.clang-format b/.clang-format index 914254a29b..a0dd1f2eb9 100644 --- a/.clang-format +++ b/.clang-format @@ -121,11 +121,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,13 @@ SpaceBeforeAssignmentOperators: true # } SpaceBeforeParens: ControlStatements +# 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). From patchwork Mon Jul 15 09:30:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13733164 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 90102187355 for ; Mon, 15 Jul 2024 09:30:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035859; cv=none; b=EohVXanFdbgXSzQjchJMMYg1gjnaooiRvwVGYRTLzv1HbIms7u4kAPjwH8Prd4gKGdMxjaMHHakmzU6bQvo99VWEvdTwMEgQCxtEQIfq1LsXCaHwU5YTQDxcIQ4OjbxrxdVDIn4hotoyYUgEsqRAA1uIHHrPSmfHhDrhw7GRrU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035859; c=relaxed/simple; bh=2lgQB6I70/+c5TtA+dqO+HAj/PI7Et/DPBkRgtFdj7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dax1D8/dMGi0FBSNcTxxs4T+Z3sObiNXLfLIuEOoYQr+aAl4K59dyWUbkqBgd0p/5emRAAdWIBP2HDjs8CfFnXyS6izyd/q2DCEhVe0egoEDjPlBZUu3St2GRZ62Lq7BkMYn5u3H/JrckCCmWPod4ZXtutZGkc2EkmyvBAG8Hhw= 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=hMguqf6I; arc=none smtp.client-ip=209.85.221.45 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="hMguqf6I" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-36796aee597so2428356f8f.1 for ; Mon, 15 Jul 2024 02:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721035856; x=1721640656; 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=pDraPsAtIa+FpZu72CXLg32Cinrj7CrujYCEokX5RMM=; b=hMguqf6INY42LsInRKGAg5qhw6Wic/l0crh+/K26zvZ33+MO0Nwm+BIUIgWhu9KNA1 cinVjDJ3rPr8oJbHgbIZrgaIPNZO5rxFXN8ml+jA9LMI7qQ74AnfW+NYJdBPe6CbKWj5 Hsi29yx7A8irjnFuhZCg+uFe3cgqqTJTNU4sOOX6Qc5dSRIeskKHCQrkrhGyaD0qEdIm VNsMmpoh8J/mwgH/fIappSB7UhyO/bwxGCyBr6qkwSFQ+X53DKXHxq6uDhM35Y03AM3z JXEMhDna/ePJKBThvalYW9ngRUuU4+/JXAuFJ8yoYUg0VYeHQQLN2uHrypWWh6C7tqBl OCJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721035856; x=1721640656; 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=pDraPsAtIa+FpZu72CXLg32Cinrj7CrujYCEokX5RMM=; b=AAR+KXmm5rzqr9fOzGsziHpzoaEa4XS+OmGV2s1xez7WrHeTGgpGPvf7xipTNluKrA pusSJ34mhJvnJYe9RDSpv/k9TYcGxYDscoEgsD1OW0MGrKgs2sxgyq+X7R68+ZOWzKHf GDy6CfAcp9azzRbTlMMaO55KsGZgQddLkaZ6J1j8jtapYraMdgpQNbGBOXLODzOfSEPg P26VPPnazKlLzOaQJoRFrOAwvWFQlOTyo/OuzvkvzB4MDKNCSb0kq9U8k0bRTLsEjHGF zaUIOWuuKZ5zs5eaaCP10WVXn7nJH8oclZQkLwIkqwiZptvSZhzU07x3hpDv+mpr+uL/ lzhA== X-Forwarded-Encrypted: i=1; AJvYcCXV3fhr7YGJoUyc3oQFvXktOVIyV90rf4qkZXcyuoZY7yTfPuSlb4YOjL99FxG17iTMFSvqKcNqALMJVmIVe9ODrFER X-Gm-Message-State: AOJu0Yyr6qajrLsVQFfhnNKmhrycBXAsMIG6CumVhCnjc3fswQ2fEHys i8V3SSJ9ECeOjETse5DB3BSdNTo8EJUPKtPB+fSr3KVAfC5Iyh6+ X-Google-Smtp-Source: AGHT+IEvksIP/v5cGyZXvA0QCJIb2k0NhVcNsre7qlhZ/65x2D/un5N2JEEcTCGO5ZxYVpALOqp5WA== X-Received: by 2002:a5d:64e8:0:b0:367:9828:f42d with SMTP id ffacd0b85a97d-367ceacb446mr17094520f8f.53.1721035855820; Mon, 15 Jul 2024 02:30:55 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1a3c:da7e:77ea:d1ae]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf19sm5745208f8f.68.2024.07.15.02.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 02:30:55 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com Subject: [PATCH v4 6/8] ci: run style check on GitHub and GitLab Date: Mon, 15 Jul 2024 11:30:45 +0200 Message-ID: <20240715093047.49321-7-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715093047.49321-1-karthik.188@gmail.com> References: <20240713134518.773053-1-karthik.188@gmail.com> <20240715093047.49321-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 | 24 ++++++++++++++++++++++ ci/install-dependencies.sh | 6 +++++- ci/run-style-check.sh | 8 ++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) 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..817266226e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -123,6 +123,30 @@ 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?}} + + if test -z "$R" + then + echo "CI_MERGE_REQUEST_DIFF_BASE_SHA should always exist!" + exit 1 + fi + ./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..8b01bfb89f 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -43,7 +43,7 @@ ubuntu-*) make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \ tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \ libemail-valid-perl libio-pty-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \ - ${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE + ${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE clang-format mkdir --parents "$CUSTOM_PATH" wget --quiet --directory-prefix="$CUSTOM_PATH" \ @@ -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 Mon Jul 15 09:30:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13733165 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 77E57187540 for ; Mon, 15 Jul 2024 09:30:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035860; cv=none; b=K5P4w33T5vxWk+EJUxKnsIWP4daioWowRGie0/D96yMq4a9AQ0z6D75Pqayx2VvY1pZcJ2H6DgsapJZjvqE4SftTaiHs/RRzTOnozBx5QhSiNAwNtoPLNMhwMzF3aesfpToI+XL5bZig/KaZJM71R3AeEP2XQtMkE6Ixa3naDNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035860; c=relaxed/simple; bh=Y31aADat4fA3Usr4h81u60I1xgTliDuxKQfJoOyOVoA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RblnXxJRPuzyRb+9TAmg0Yx9BYL8TK8Yr5DT6RRl89hLCrYRE6CuuiIx+zw9u1HlP4qx6e6hhZvTX7eZ0KcuF9ISPN/g6dtOejvLU4vS2F1WavuFs2M49pRBR6jnDzr4yyraLkO1CEK7Q+RufDD1SgsfU20AJZ3shqELhmma9Fc= 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=BILrk5Bl; arc=none smtp.client-ip=209.85.221.45 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="BILrk5Bl" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3678fbf4a91so2105022f8f.1 for ; Mon, 15 Jul 2024 02:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721035857; x=1721640657; 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=GV4c1RtqvwQl2FhVDHHsZzR1lqJqJuoxbPpvwuiA6DI=; b=BILrk5BlcbMbTu105qcdtoBeb012BbODwCTwkJneuvr2Kxa2lJ5ERspJrIMOGjV/KI KsO0DropHnX/Mp/ZcqDfH5uhxXjoExteWoH5QN5T/KUndT/z1MXsPRt9suvLNC/pWUZX GHJyP5Q75aNd83KOV4QebAHyaTRWQ3sdu7z/+jEVvjs09ZjBtP6fRCDUbL+sU1K4EUue mcsYr7OqmBljeXVShYMk2jw37TetNe4laL3VlFay6FNqYziRs8gCTybGDGtVuy9hcCMf LgEOkheSfEr+fDNnHJIm4XdjN1MiFS6G5H7Ypi9y0WpuffaZqSFsHbW3xrHaeeDT4cvP zaaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721035857; x=1721640657; 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=GV4c1RtqvwQl2FhVDHHsZzR1lqJqJuoxbPpvwuiA6DI=; b=oHXRVjJFWm002yYeLIsrJnlYPfW7fEvAPDyWCEwfWXXVSb9O8uQ1oNqxPsCEUcCcFZ VvZ+mKN/+vN4mSgGr9itnI04sYYa1q7P/LRAbIatPOrx6pxL8wY+6lpldYZoVMBYTKb5 CuIoECWc9K7Cg3j89Ig0trOyxAthCEwD/kPDg+8dxoMUKsSXgJAcBGWzThSHOKSoXTIl S1HTUmzvrJNFaMYqPE+Q/R7V+9Y2e6BK4pw3/hZzaf6e2KUJkOlodu8j+3sv2lV0dlYb 6+IqzkO2EylCS6xc1MsXAyuOX5oL/vUqbJLghx852re1Or+LOh//W570DinRISgkV9n+ 6dmg== X-Forwarded-Encrypted: i=1; AJvYcCVojHrsqJuyctiJtFtyF4JhTR/R3wV1FotL0KuAhxa/k+BvZIlGLJXQQo/tZuWxoXNuUj6hcyDFN5jb9xMsUJm3akhc X-Gm-Message-State: AOJu0YyHQQFw2H7pUHs5JsyAsjIh1iYRTVFa93DOD1OOwzTUJ9MOZmNu dUgx6ixLvQ26G7lEleblTcq0KY+DMr1hEuiX8IZL1VhtWyaE0KTv X-Google-Smtp-Source: AGHT+IHkAme6Z1FWlmMgodx1ictSmyoGZfMeIGdeTU//povRwWS+IrJUvqObGtIC7nizGOWSVF0emQ== X-Received: by 2002:a05:6000:237:b0:367:9c93:f87e with SMTP id ffacd0b85a97d-367cea964d6mr13072516f8f.33.1721035856743; Mon, 15 Jul 2024 02:30:56 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1a3c:da7e:77ea:d1ae]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf19sm5745208f8f.68.2024.07.15.02.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 02:30:56 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com Subject: [PATCH v4 7/8] check-whitespace: detect if no base_commit is provided Date: Mon, 15 Jul 2024 11:30:46 +0200 Message-ID: <20240715093047.49321-8-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715093047.49321-1-karthik.188@gmail.com> References: <20240713134518.773053-1-karthik.188@gmail.com> <20240715093047.49321-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 | 13 ++++++++++++- ci/check-whitespace.sh | 10 ++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 817266226e..320b78b9ae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -118,8 +118,19 @@ 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?}} + + if test -z "$R" + then + echo "CI_MERGE_REQUEST_DIFF_BASE_SHA should always exist!" + exit 1 + fi + ./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 Mon Jul 15 09:30:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13733166 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 A6DF6187547 for ; Mon, 15 Jul 2024 09:30:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035861; cv=none; b=uI4FA7UnCSlVS1ehLjLW+VElvOjGdO4j4r6OJ09jgK2NWDaydztsn+lYXs/mqtbCqRJ3jQKhagyEkDvt1EbmZ6JtfxHT+1TKCSPW9IdHNaMxd7EzQtXM86ygyZKVDiKsHEwobKUa5add5d1HjmX1DM8FZgPBPMe0Hu9LspWim4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721035861; c=relaxed/simple; bh=VVCxXD2hxorjLBe9Co7S05O/TjJtj1HOFXn3xB6ZwhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TkNaahdk4cxI+q2aPQA1zSl7LRRITvwINDPXMPIquRra+1ATrIV5vwtzn94LYGMt1+bXRthc/kRbABe6v40vIVeugLDtEHT2ATbSRvYUE7L3jCl2wpTJYXhjoHWPitD2mdzMw7fpq+g7bRZiJpZQCj9O3qKLVB2c45qSWh2v2Q8= 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=ACe8WaF6; arc=none smtp.client-ip=209.85.221.48 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="ACe8WaF6" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-36798779d75so3609971f8f.3 for ; Mon, 15 Jul 2024 02:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721035858; x=1721640658; 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=7ZRZYfl2KGV+PSxMIaK6VpG3xzcTlVcXvPjDnYD2/PY=; b=ACe8WaF64BTQVvlGIcd0bhLyn5NV95qbYZZs4E6tl5ZEQekIz6IZiYnO4xW4fel/0Z Y9Bm3OZrK6uol7FuTuKLOHZUI+H8Ii9+9Ooujg0tieVh1f3z0iFeanSkNJMylqK5Smrr KK0YjYD+74SZqWV9tHbLbgp+K9fcKv6zrLNzmCX+h3NgXfA9bmOSBGXOQBRT/R3U9cOa lJUsA/319xt8UNm72w8llgF2SN+y+uxyGC3XseYhuuyuYIVplZnzL+jvSDKYrCWKy5RP il/GTLKVPPwfKgM2uUDABoWVHqXjLvZ7ZXPmk4ldHWXJDCzL0mM39TpVXicOfwWKqM51 ExWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721035858; x=1721640658; 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=7ZRZYfl2KGV+PSxMIaK6VpG3xzcTlVcXvPjDnYD2/PY=; b=TRXtlCx0BcMZrowpnQHBp7931NSSUTpPuGYOQVTd2yGkmHaA2bm8ARyf7iJN2LZBO/ L9i8ovGkMedVs2pV7V8i8GxtbKGe+hUdXlzHaVs4KwntesvLVy1+55PgnO0yE0Qef8ZB vO8YqaTbNQ8Lfyy3DJcNDthn8CKAxTJewflh2zPW/9tzYpzHlU2iHPg4JPHiap1Lq7DV KhV/sjxzdQRC6A9un+LPkTCpnR0/5XYmHgQKmzTSFWlr5VKKm0qJQlmmM57BdlVjYxWy zUXMQFl463NJ8ld2aYv5e7xBFA/mO4v1pP8eF+x4GMbkJrdnO8MAlNQeZm5AjaWnFbhv 9q6g== X-Forwarded-Encrypted: i=1; AJvYcCVmQJX+AHrL4k8PcZ7D/c6UNtPC+XBAbvira7MUgq2mQB28Bew2/Q2EUHzA2FyJjnsSBe7zHavUoSgsmzDXza+khNar X-Gm-Message-State: AOJu0Yx8AV8qrJZq/r1OscKcPxdubVbOZsYRZc6ljxo0/bGsaI9a86ri w8EJVgkQzsR/3+JHCGa1uSERb452ZiasXXR1GRNj0Srx4Z4b2TUapBVZJC9L X-Google-Smtp-Source: AGHT+IGHDXBioTc9AGnGVqYVHilflgc6RT/4GdTGFQhce8dliGFgIsg+Fqkeq3P1v10LrceTy50Y2A== X-Received: by 2002:adf:f803:0:b0:35f:16c9:a5bd with SMTP id ffacd0b85a97d-367cea73618mr15411425f8f.23.1721035857988; Mon, 15 Jul 2024 02:30:57 -0700 (PDT) Received: from laptop.fritz.box ([2a02:2455:826e:4900:1a3c:da7e:77ea:d1ae]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafbf19sm5745208f8f.68.2024.07.15.02.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 02:30:57 -0700 (PDT) From: Karthik Nayak To: karthik.188@gmail.com Cc: chriscool@tuxfamily.org, git@vger.kernel.org, jltobler@gmail.com, phillip.wood123@gmail.com, gitster@pobox.com Subject: [PATCH v4 8/8] ci/style-check: add `RemoveBracesLLVM` to '.clang-format' Date: Mon, 15 Jul 2024 11:30:47 +0200 Message-ID: <20240715093047.49321-9-karthik.188@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240715093047.49321-1-karthik.188@gmail.com> References: <20240713134518.773053-1-karthik.188@gmail.com> <20240715093047.49321-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. A more ideal solution would be if 'clang-format' allowed us to append rules to the existing '.clang-format' when invoked. But such an option does not exist. Since modifying the in-tree '.clang-format' is only done on the CI job for style-check and doesn't affect any other jobs and is not persisted in any ways, this hack should be okay. [1]: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm Signed-off-by: Karthik Nayak --- ci/run-style-check.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ci/run-style-check.sh b/ci/run-style-check.sh index 76dd37d22b..16b593fa1b 100755 --- a/ci/run-style-check.sh +++ b/ci/run-style-check.sh @@ -5,4 +5,17 @@ baseCommit=$1 +# 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 +echo "RemoveBracesLLVM: true" >>.clang-format + git clang-format --style file --diff --extensions c,h "$baseCommit"