From patchwork Sat Mar 1 21:45:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleks Todorov X-Patchwork-Id: 13997690 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 AB1C2182D7 for ; Sat, 1 Mar 2025 21:47:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865646; cv=none; b=lMfFDh2GfnG7JbOtL/UITpd+yCpotqSDFQo51Yv0jDkWnbLSlFNgMcPdny9tiMmdOTObacrlN3s0I7pivmiE/J0B8Lrqr2OOFH2tiUCZmBFasLZsbXOr1hzm8vVY4TIUkny7FZQN1AkLYnVk+tbkSL5Kqnn93Fp5AbGKePJ8bVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865646; c=relaxed/simple; bh=Eejn5IB/egIlJ1JC5v7+XMEA5HrZPBcrBDiM3XeDwWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e4jU/XrPCfqy8dvoZ5kO63GMlNVUzLh6p+43XXJLJbLEySPeuPm/03RTVdAXYjuTEvdw9UoHuxoD+07idFNJST7UoWHmIkFCgNJimnliJICRsylk3J70WQWWGnScFk6gzaQf4rshJFiO54O+NVNN/3IITXkPNY+F86Z3T5EzFeo= 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=TxzJeZQs; arc=none smtp.client-ip=209.85.221.42 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="TxzJeZQs" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-390dd362848so2535731f8f.3 for ; Sat, 01 Mar 2025 13:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740865643; x=1741470443; 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=Xt63xmO/T33T1hYum8T1QdTVnZZJE+sG0fQf8ZIFaD8=; b=TxzJeZQsQ1jcpjbRMyfHQ2u5p0uCFj2uKJFlm0C5QexutJLuCS5kISwfLpmmNC54jn C146KBcXv5WQAvW7xyP45XBgqgL0NShytVZLzizoJqraIZNQdRPmv7DUPwCGhA4nGbsJ JRaGKwZHkM5gUFaCvIOBwYQcD8lGM92k5eSz7pWNaCEKe2aZ9l1IY+s0fxufHpeFUck0 KyGAD5By/8pzfL4/xLf0rcmOyH7wn3L5LN+Dy021WgwPTG5cRK0IYqriBz7UwbbYRvsG HIhuDAxArC+xitG1M86WhNhd8gF6t4JwBzK+TBlIOTL4EPPo2stqssO3rfTlXvgz8wTE dHnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740865643; x=1741470443; 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=Xt63xmO/T33T1hYum8T1QdTVnZZJE+sG0fQf8ZIFaD8=; b=sIN5gCfamr6v+cY+mMmhDX7s3ae5X8nB7s1tGeI/L8bfGSnIWh7pkiBye9P+DLPKcm yJRE7mpGgjxf33+E0PAJ0XFZQ/Xsfksgb3yIfNXnsWePy3V05nq5DzPiQuF8wdgu24fZ SWExs6VzPSR772g7QnNcxQ6tj57ZDnAGolNl+8pSq0kSim00ZTphO8JjX/cq31vSJ7+v LJX9VGtiSRZdyKT/qvw1DqfKSvvs1ZENV0rjQc/mQn1U//EHwW45CcZBMsVYFJPtLlZ7 sWjB17IkA0N/e6ikWlxJVaOu9pheNKqWhPlXiBb8B6TFFq/MZTmdD4iLU1RpIjnpWmp9 UcQA== X-Gm-Message-State: AOJu0Yxxpeq1WO0G478uKDD7sdKSC7s2tCssliSrXOwPhr02TaihPI92 VVPj6Y8afeTn90ZFJEw12u6mv2aouh/DW5UIP1QGYKtMwd2Esm/g8YdIfIKz X-Gm-Gg: ASbGncuMts8ZBqnjSbQyl5slQHxoesjyo9CAYSQPC10KQRutWQF6vWJAGg1x7mGa6+y CT4KxfK4ThZaiR5L+aE871TxPauYNb/5g+OB3uO5stHHmYb5u/15qu00GulWuZTJ1U4WuSJJuwj SZw6GGMk7lJ5MYBP9mixbBn6FiBzt0hGc8cGGq1HJmoaW8PMKDy3UIaHmfVszISciqA8yOanqjV +VmUYIK5SVe5klPggMbSp/cMCoENghHk0rPW5/Zurcsl0Rj4KC/NLtRkALMBPzWbFxZl/RNEzr3 3jQS7GF5oGcM7804F9dnTdIQt14Wx8hnVed31giGUg80ZhhOacCp3zMPmS60F3eGjIGIFgZkhTQ xBZHR X-Google-Smtp-Source: AGHT+IFeW+GNTkGqamBUNNjppjOjTRejeFB8jzfCOVbzpBSsA5c2ZVwZT0L/9BNgSZ4Xc51sC1aGuw== X-Received: by 2002:a05:6000:4104:b0:391:5f:fa3d with SMTP id ffacd0b85a97d-391005ffe87mr741677f8f.31.1740865642738; Sat, 01 Mar 2025 13:47:22 -0800 (PST) Received: from aleksbgbg.communityfibre.co.uk ([103.205.25.90]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47a72d5sm9603474f8f.31.2025.03.01.13.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 13:47:21 -0800 (PST) From: Aleks Todorov To: git@vger.kernel.org Cc: Aleks Todorov Subject: [PATCH 1/7] builtin/blame: Accept a user-specified format Date: Sat, 1 Mar 2025 21:45:00 +0000 Message-ID: <20250301214652.536439-2-aleks.todorov.1337@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> References: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a --format / -F option to `git-blame` which allows the user to provide a string with placeholders which will be expanded to include custom information in the blame output. Signed-off-by: Aleks Todorov --- builtin/blame.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/blame.c b/builtin/blame.c index c470654c7e..437ac8bd73 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -66,6 +66,7 @@ static int xdl_opts; static int abbrev = -1; static int no_whole_file_rename; static int show_progress; +static char *format = NULL; static char repeated_meta_color[COLOR_MAXLEN]; static int coloring_mode; static struct string_list ignore_revs_file_list = STRING_LIST_INIT_DUP; @@ -905,6 +906,7 @@ int cmd_blame(int argc, OPT_BIT('t', NULL, &output_option, N_("show raw timestamp (Default: off)"), OUTPUT_RAW_TIMESTAMP), OPT_BIT('l', NULL, &output_option, N_("show long commit SHA1 (Default: off)"), OUTPUT_LONG_OBJECT_NAME), OPT_BIT('s', NULL, &output_option, N_("suppress author name and timestamp (Default: off)"), OUTPUT_NO_AUTHOR), + OPT_STRING('F', "format", &format, N_("format"), N_("print blame entries in the given ")), OPT_BIT('e', "show-email", &output_option, N_("show author email instead of name (Default: off)"), OUTPUT_SHOW_EMAIL), OPT_BIT('w', NULL, &xdl_opts, N_("ignore whitespace differences"), XDF_IGNORE_WHITESPACE), OPT_STRING_LIST(0, "ignore-rev", &ignore_rev_list, N_("rev"), N_("ignore when blaming")), From patchwork Sat Mar 1 21:45:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleks Todorov X-Patchwork-Id: 13997691 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 9DE1D1E9904 for ; Sat, 1 Mar 2025 21:47:26 +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=1740865648; cv=none; b=cwNRCbg2v1hA+XBcXWJlWPKqQrfuhpUj7XdNuEEQxWXYrOo8tBfRQMsHaEgBz8OkBFpwvPnDenGI+9hgrn/f68EBCZYAioFgiOHXf6VfTWSBg2pO8azjR6+pd3jIJihiuPYhs5OjrjhvvW8bE2u75f+Dw6VASYdPadqm3EL6O3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865648; c=relaxed/simple; bh=Rrwwea3bc3Uf5j4WAMLA2Zh4c4SXs8yrSaq4gG5c5Rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tKMGX3yvTdFivOXeeIq4KcuynHrfw82CjuwgATwE3Wp/0CZ67isVawAFdE5bZPYibBcUzQVU0FJIBrXXSkbeA+Q5/KjlCy37lARgSwe3G3HrsR96KGRKx+IrWq8xQPQuJMA045rDMOR5uXR6ozzYo5WcFBI5IwXtvbIV/HEt7Ws= 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=XJqq2KUg; 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="XJqq2KUg" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-390effd3e85so1825126f8f.0 for ; Sat, 01 Mar 2025 13:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740865645; x=1741470445; 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=NHVTwt8xqBKWjUuDEEuRV045NoLIJDOfZRpRkG6vKZQ=; b=XJqq2KUgs0zcomFtMSDWdRtQcU6jTAkaRQ2P2TKuXHDHGCu0oU+2zOjTbcVuGMLKXf QfMog4FuEgbDQ5dqq2zesmQfjtrqFozUUv4UnHYoGE86ellsTm1zucBJIgq1RFjECZyO l5LXtsRuV7JPzZyO3pQNMJVmWlvG2+qaaHyDuah1/vTdphAuWfy6kAvvqN8RAwx6p78z YC7SV2wuVLayE9t9Dlv4btAiQdBFv3TB2ItGQLkQ11xZ4Ht8FB97DQ2y2c5F3zxXeC+T VG0A8soFj91MR0B6I293M/9W6oQhZGcgPg0ux/9SO8WjiOGOgbftUTBmILdgxkYiyDRC zJ1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740865645; x=1741470445; 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=NHVTwt8xqBKWjUuDEEuRV045NoLIJDOfZRpRkG6vKZQ=; b=ID4yWp6sACVUHBbSKu55gaBsDC61VCR5C1Uee4RYdLivmoaW25hN0XtoKEXhHZPsEB eX3aijsnPIeiNjNowe4U8t1/Wm0Y8Lesci3+9VgwG3t4093hP53E+GPz1za6p8GImDGj T8nxkpkCg8+2/uN848rVZu8+z4Y9jQ/AcA6+78v4BJ8YJYCrNw+xQdoHmuM593kmEv0d yHCUx0OKJGA3iY8XGgxKHYpZTkuR1SgO75vweCwREgOgqAtAb/qMnVYRl4gY3q8w8GQN tORkd80TDGyMwJ9QJnB+lZtVKF6WqAatQymt6hMe93k7LqBVsvsBlEh3dc4QP9qn+uNs qkJg== X-Gm-Message-State: AOJu0YwH31TMALzWhZ8ML4e3hKFjRS6ZqqelfS6gNdK9KM6GKwv7YNAp 5ZofshVQ4OkYK75g7PoNzALPeq3+mJ6MXgHLlp09sfnLOmNdwfCpy0rEaeGu X-Gm-Gg: ASbGncsO6DtqD02Pzapu7E/ROlklKNI8kRSybPs0S6zGAph5LXM/NnVaWYr175WGE+n 7FHd69zq5ShcPLw66knKuxVcTTo2ypHBJDi3RpPkpEErZ2gxwH3cVn2ksMvxj7Fsp09iZGLdsl5 Mx2+gpjLwN3hFNLh43O9XB5Onktirzh01tDq+3SLpoeTHTiug35+ZcRpuVxV7Bq2HYD4sqwXTEP zQ5ZH/UdgHnhtnRqeY3QOSBeAFiLie2TYzrKlcOpqr6Eit4+VlHNQ8CRuHDqtWnYVEYM+vbLj2p Y7lOBYMTea85jKFketWCa/C+xg94Yy3lwf1AVc+aqpbVagfyxANbQFDeSMqYAyLH7+JQM9r4YPZ sq9Nf X-Google-Smtp-Source: AGHT+IHtogQCRzC91VurAExjo6FtIGXsj0tH3+MqKutSNA7sUtU6593HIBx8Hu9rHVbwyRSkko72CQ== X-Received: by 2002:a05:6000:1848:b0:390:ed05:aa26 with SMTP id ffacd0b85a97d-390ed05acf2mr5946169f8f.5.1740865644612; Sat, 01 Mar 2025 13:47:24 -0800 (PST) Received: from aleksbgbg.communityfibre.co.uk ([103.205.25.90]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47a72d5sm9603474f8f.31.2025.03.01.13.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 13:47:23 -0800 (PST) From: Aleks Todorov To: git@vger.kernel.org Cc: Aleks Todorov Subject: [PATCH 2/7] builtin/blame: Add blame.format config option Date: Sat, 1 Mar 2025 21:45:01 +0000 Message-ID: <20250301214652.536439-3-aleks.todorov.1337@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> References: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Source the format string from the user's configuration for convenience, in place of the "-F" option. Signed-off-by: Aleks Todorov --- builtin/blame.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builtin/blame.c b/builtin/blame.c index 437ac8bd73..891ac017f7 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -772,6 +772,11 @@ static int git_blame_config(const char *var, const char *value, } } + if (!strcmp(var, "blame.format")) { + git_config_string(&format, var, value); + return 0; + } + if (git_diff_heuristic_config(var, value, cb) < 0) return -1; if (userdiff_config(var, value) < 0) From patchwork Sat Mar 1 21:45:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleks Todorov X-Patchwork-Id: 13997692 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 C50811E991C for ; Sat, 1 Mar 2025 21:47:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865650; cv=none; b=a+nZmgZTV7wPqDwFZo9zZGvz8PK/yv9VAzI5fKi5JhRAMCzuHBmbsZZYHkOpOk/vsyPspAxN8KbJeI1QLpeTkxvXW16XIhsnPlt4uEUxgvaWWS+nIdx2GzDokFsZRyF+9ZORKVdUTegxRIy9oSn35JUp5JPUgpQe8cW1kByllMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865650; c=relaxed/simple; bh=3p3CjtTAA9Tyll1U8MG8IX6QmrC0iBIV+FCZXB6bduU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H1PsdnMVNuHYKSCgYSP9z8+hqczRhgYObCmqCY2TTsEjz+3ACnASnMmDWfTNcrMkmMBPuuwCVQ7BV4OeTf5zodubyfFzsuKRtkb4hXmfsZ+wsDDdMU+eWR5gY6LhfzPcHBJ24H5h6T66+18caxDHfyt0qaUuzzuDJxWfbPIP8Do= 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=FycFI8nY; arc=none smtp.client-ip=209.85.128.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="FycFI8nY" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4399deda4bfso20683905e9.0 for ; Sat, 01 Mar 2025 13:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740865646; x=1741470446; 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=SRmau5uUyHk6jNgM0jPab9HfShG255P/19UzAucOb4Y=; b=FycFI8nYj7OqyscZ0G5MsVszMRn2gQsi1zPMEGknbnKsxSBoUDeKXxYIvn7xKrBf81 oQ8IAlNJs5TlgwO4xpSF27vkS0WIYXU3FC1sYkb+6tqlyjsw/R+DYXpXiP+vyNDdOVKt Z5ryNwv4lBfgWwpW+CIIkbEWuxfkS7g0LJ7rfLGiWpBdy/a9+6Xf8jWnIIsLRLFeepKK Aredz5tckjbmwsoHXhzqLiUz00Q8gAaUX0042uLhl81Rn0avRWNGDVhKwRNLt0Ql1fab kWcuy9HTegBreOmCgMOkNiPwVwM8DdVmjHwQofcO9Hs33XlWOfhe97t1B2aRKOYEtlH+ JoWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740865646; x=1741470446; 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=SRmau5uUyHk6jNgM0jPab9HfShG255P/19UzAucOb4Y=; b=k/JMgMyHPUFUrwrSGcTpwnUR0HaqgzzrEPNmw/vs2ECEJeTVVWxlOy/RKQqz81QN4N NBiXTESmfZRWebbSavwzIYgRhbNoUNrphRfvF7rttNzjQa1XYbovyKxSw6xtNzXA7ywa 1e1pXG0su4qPgpdqLGeX044J41ctUykJIdB1o/tZNgQXzVPjzzZ9ECboju1SSevf/N5b 59Rumnbyfi3IMa73WT3785CFr6Y7uwnTvF/j75nE6JXpf8GhYC25XHQoI7DdvvWABhGW bUh+0S32ajpCOqJV9KsjC3yx7ZW3k6pZflCtukj+BHKrcxMLJgdydf3V6+hCK3zJqcpg BHHA== X-Gm-Message-State: AOJu0YzbGyhtc3qNIQ+5VNgTrqaNACpFqYS95OEcYmsVdPwsx/yqFX6X XDWu+k42SzvbnvS6GcNbj93T8Q2rnxbj7cQvU6VPvynWkUfOa0GXmnexz+u+ X-Gm-Gg: ASbGncv3HO9wxERmXABPC7UuQFRL4QoOPpjNDKTi2d2ShpsCwXCabwwoMjV/0E2TQ7A nR8x+WbpG02WVMLunudq9OrCJJcJh4CQ8B392BH/40A4Qy4Uc0kfi1Zos7OkCrFvcdZDu7eRtcx TOcE0hlWreRnlh/NBfGsw8oQLevojEHatyJME4tSGVSHc5mAruivZ/l4PKnijtIS2uSiQvxVzM2 UXpkGbkHanVMumggN8d4CPBhDH6Bkz3OKkpunnw8pF5tEe6YM9jjfMw3PIgG0Gj03Bo4C1jKk9B B0NPBFb1Hw2CFVEWCqpeV36G3PZ0GsWp/D5EGgiR2w5vaqQk4skK62Q42d9Z/G+dLFd05xq7EP6 OrIpk X-Google-Smtp-Source: AGHT+IEoDKyV8U94UTAwuvgcbbrF6vO8KNH0a81w/zDqXwCHyvItScMYsjc87Gi0qRYlpiPg6Pny6w== X-Received: by 2002:a5d:6da3:0:b0:390:e76f:163 with SMTP id ffacd0b85a97d-390eca52819mr7643482f8f.45.1740865645860; Sat, 01 Mar 2025 13:47:25 -0800 (PST) Received: from aleksbgbg.communityfibre.co.uk ([103.205.25.90]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47a72d5sm9603474f8f.31.2025.03.01.13.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 13:47:24 -0800 (PST) From: Aleks Todorov To: git@vger.kernel.org Cc: Aleks Todorov Subject: [PATCH 3/7] pretty: Add F and L format specifiers Date: Sat, 1 Mar 2025 21:45:02 +0000 Message-ID: <20250301214652.536439-4-aleks.todorov.1337@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> References: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add the F (filename) and L (line number) format specifiers. These are to be used with blame only and therefore only work with blame. Signed-off-by: Aleks Todorov --- pretty.c | 14 ++++++++++++++ pretty.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/pretty.c b/pretty.c index 0bc8ad8a9a..d2b7284854 100644 --- a/pretty.c +++ b/pretty.c @@ -1446,6 +1446,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ const char *arg, *eol; size_t res; char **slot; + char line_number[16]; /* these are independent of the commit */ res = strbuf_expand_literal(sb, placeholder); @@ -1549,6 +1550,19 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */ if (!commit->object.parsed) parse_object(the_repository, &commit->object.oid); + if (c->pretty_ctx->is_blame) { + switch (placeholder[0]) { + case 'F': /* filename */ + strbuf_addstr(sb, c->pretty_ctx->filename); + return 1; + case 'L': /* line number */ + snprintf(line_number, sizeof(line_number), "%zu", + c->pretty_ctx->line); + strbuf_addstr(sb, line_number); + return 1; + } + } + switch (placeholder[0]) { case 'H': /* commit hash */ strbuf_addstr(sb, diff_get_color(c->auto_color, DIFF_COMMIT)); diff --git a/pretty.h b/pretty.h index df267afe4a..eb54070ecb 100644 --- a/pretty.h +++ b/pretty.h @@ -51,6 +51,11 @@ struct pretty_print_context { unsigned encode_email_headers:1; struct pretty_print_describe_status *describe_status; + /* Blame fields */ + bool is_blame; + const char *filename; + size_t line; + /* * Fields below here are manipulated internally by pp_* functions and * should not be counted on by callers. From patchwork Sat Mar 1 21:45:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleks Todorov X-Patchwork-Id: 13997693 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 0307A1E9B0A for ; Sat, 1 Mar 2025 21:47:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865651; cv=none; b=mb/GW6hUZ+HotbOxlq6XjEJxk138OvFBHkfWYSpUM+1zcXVNXPK3rsz+ZRtnHgu5GvWcCNq75ASdW3Edk4gvE3CKU8go/AUsJfVumaNTxJufCSuXkcA2mdRydFW11pdtY+3yZWPY62m6qfUo2RclgUrQL5QHZMiVwXfKv3Z7+RI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865651; c=relaxed/simple; bh=DSA4WwIXRUon4Zi9zyI/wwj9nfPK72Nj07VWd+h2ewQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t2rMNiLydq3kMDU6hmkrk7UzdoRexAXXx+SSfGgv9SciCT8hHYffEQ197PgnZXWrieyLZUpjwuk/zaMNifyQ8dz8Lza5fQ0LswC3lW4VsU5clNdtsaZbrucN98FQwP0KeOLg4fmlZG6JwmH4s1NJq+Bul+18cPVOgI+jCd3yK60= 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=SlzsAwf/; arc=none smtp.client-ip=209.85.221.41 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="SlzsAwf/" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-38dcac27bcbso2959308f8f.0 for ; Sat, 01 Mar 2025 13:47:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740865647; x=1741470447; 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=tqcG+CP2VMCuVXsQ/1qF7Np/3463d9uxBk/J52K9WGM=; b=SlzsAwf/Bh0EGCzDt36p0enK3QtKXnbvge3kYJE9IKwNusFd/sxy6w+AE5fR/i+hd3 XgMIt3+v11eMFRnCrLIy2ecpuDARmzHaWPBNgTcZbGBVp8tV245VMTuwDyVPkHDjdlhD 6oRNlnr2zoYgrnNYB0aKtuwQ/HBR0dmWvLyMMuXr1uP+KiLBfsULQnOOfB3rsQBpabIC +soRbhU3AqOHOf9eoLLDdxyZ83bNWDuvEQcyMwIf27H1S/2h78nMFUF3zbxgSPhKLUK4 h/gZCHnipB3ih6PC4/WNeJCaYfOYRsr8dTfu84OzM81Viw0IK8UdNWYE45IBvQ6IS6X5 Rddg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740865647; x=1741470447; 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=tqcG+CP2VMCuVXsQ/1qF7Np/3463d9uxBk/J52K9WGM=; b=C94BIC8NsqhGUFylQKOx02bYxZRrshC4XYMy2ze3wQzEJBdE1x98dEGOLMmnIlgCLk ATvIOytZ2lPDYss+GLLfF/1xjY84gj+pzoC7g9H96LN6pbJw20uzILsGhz2Cf3qDsmj0 DTeBjHqIGqB3rBXwrazKpXegVZcR1D4udA+WTVkpHwYFt3gMZA9VzdM0G3J+hhtUUb/u hxE0AeryybKGAG0tXNMGrNFeYejOi7dNytfSAc13TzyjlPhTzR5oUtxlicv79lnXIfg+ YRC6wmGDZ6ssRZCnyAshi4Mw713oYr6XRu/d9SkgmLobNB88oDNTQui4JxtLasPQdWye hUPQ== X-Gm-Message-State: AOJu0Yy411cMvpVaVj8EwVrPM3W6d+15GYnRcC/DFB6xlTfY7jfepM6m lrpB94s4SdqRR/zrjSk9q37DglzpE6t55UzLOrCt5dXqp0NcO2/1nwvrV7QF X-Gm-Gg: ASbGncsJvXKts+lJnckldCWn7O45+dHfmjVcbwOJQPHF8as0BcP+KmwReSayw48088y BhSPkVMBnltpDsbHfRcQz2RwLknd1ZEAubpIrf+gkhtCp9+CJP4ANbv3uqsU+FOdOS8cdU+T/Q+ ilIKsDHC674GLPf+0LCISiIEVIPmvsnibkDGkF1D4UUtgXI3r1ex2SDfUFAiKyKyr3Sv2jHiO8g 96fnoX8mXu/YBoamAyOothrjxbiED8uvuYA3xGNAVd/jkEo4R1Y6La7C11KuiKTYIyHL+GaGnH3 3vdE4JefvZLCC6XmoUSuXFXHg56Aj+Em/k15WrXOJJdVVMiVjSPqfY4nCRwA2/xE6UEbzlsia9v u9Ga3 X-Google-Smtp-Source: AGHT+IHsO8S1OFC95cwSFaXK7Avm3rsUkSHvC0NNAZEkLz5hZ132f00QlRr1PXU43w9DyqeqUfoLrg== X-Received: by 2002:a5d:64cf:0:b0:390:e535:8750 with SMTP id ffacd0b85a97d-390ec12eff3mr7530319f8f.9.1740865647064; Sat, 01 Mar 2025 13:47:27 -0800 (PST) Received: from aleksbgbg.communityfibre.co.uk ([103.205.25.90]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47a72d5sm9603474f8f.31.2025.03.01.13.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 13:47:26 -0800 (PST) From: Aleks Todorov To: git@vger.kernel.org Cc: Aleks Todorov Subject: [PATCH 4/7] builtin/blame: Expand format when available Date: Sat, 1 Mar 2025 21:45:03 +0000 Message-ID: <20250301214652.536439-5-aleks.todorov.1337@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> References: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When the user-specified format string is available, expand the string by filling in the details and emit. We can therefore now emulate the default format with the following command: git blame builtin/blame.c -F '%h %<(17,trunc)%F (%<(20,trunc)%an %ai %>(4)%L) ' Signed-off-by: Aleks Todorov --- builtin/blame.c | 112 ++++++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 47 deletions(-) diff --git a/builtin/blame.c b/builtin/blame.c index 891ac017f7..d2b605f7a9 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -489,63 +489,81 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int if (color) fputs(color, stdout); - if (suspect->commit->object.flags & UNINTERESTING) { - if (blank_boundary) { - memset(hex, ' ', strlen(hex)); - } else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) { - length--; - putchar('^'); - } - } - - if (mark_unblamable_lines && ent->unblamable) { - length--; - putchar('*'); - } - if (mark_ignored_lines && ent->ignored) { - length--; - putchar('?'); - } - - printf("%.*s", (int)(length < GIT_MAX_HEXSZ ? length : GIT_MAX_HEXSZ), hex); - if (opt & OUTPUT_ANNOTATE_COMPAT) { - const char *name; - if (opt & OUTPUT_SHOW_EMAIL) - name = ci.author_mail.buf; - else - name = ci.author.buf; - printf("\t(%10s\t%10s\t%d)", name, - format_time(ci.author_time, ci.author_tz.buf, - show_raw_time), - ent->lno + 1 + cnt); + if (format) { + struct strbuf sb = STRBUF_INIT; + struct pretty_print_context context = { + .fmt = CMIT_FMT_USERFORMAT, + .abbrev = abbrev, + .is_blame = true, + .filename = suspect->path, + .line = ent->lno + 1 + cnt, + }; + repo_format_commit_message(the_repository, + suspect->commit, format, &sb, + &context); + printf("%s", sb.buf); + strbuf_release(&sb); } else { - if (opt & OUTPUT_SHOW_SCORE) - printf(" %*d %02d", - max_score_digits, ent->score, - ent->suspect->refcnt); - if (opt & OUTPUT_SHOW_NAME) - printf(" %-*.*s", longest_file, longest_file, - suspect->path); - if (opt & OUTPUT_SHOW_NUMBER) - printf(" %*d", max_orig_digits, - ent->s_lno + 1 + cnt); + if (suspect->commit->object.flags & UNINTERESTING) { + if (blank_boundary) { + memset(hex, ' ', strlen(hex)); + } else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) { + length--; + putchar('^'); + } + } - if (!(opt & OUTPUT_NO_AUTHOR)) { + if (mark_unblamable_lines && ent->unblamable) { + length--; + putchar('*'); + } + if (mark_ignored_lines && ent->ignored) { + length--; + putchar('?'); + } + + printf("%.*s", + (int)(length < GIT_MAX_HEXSZ ? length : + GIT_MAX_HEXSZ), + hex); + if (opt & OUTPUT_ANNOTATE_COMPAT) { const char *name; - int pad; if (opt & OUTPUT_SHOW_EMAIL) name = ci.author_mail.buf; else name = ci.author.buf; - pad = longest_author - utf8_strwidth(name); - printf(" (%s%*s %10s", - name, pad, "", + printf("\t(%10s\t%10s\t%d)", name, format_time(ci.author_time, ci.author_tz.buf, - show_raw_time)); + show_raw_time), + ent->lno + 1 + cnt); + } else { + if (opt & OUTPUT_SHOW_SCORE) + printf(" %*d %02d", max_score_digits, + ent->score, ent->suspect->refcnt); + if (opt & OUTPUT_SHOW_NAME) + printf(" %-*.*s", longest_file, + longest_file, suspect->path); + if (opt & OUTPUT_SHOW_NUMBER) + printf(" %*d", max_orig_digits, + ent->s_lno + 1 + cnt); + + if (!(opt & OUTPUT_NO_AUTHOR)) { + const char *name; + int pad; + if (opt & OUTPUT_SHOW_EMAIL) + name = ci.author_mail.buf; + else + name = ci.author.buf; + pad = longest_author - + utf8_strwidth(name); + printf(" (%s%*s %10s", name, pad, "", + format_time(ci.author_time, + ci.author_tz.buf, + show_raw_time)); + } + printf(" %*d) ", max_digits, ent->lno + 1 + cnt); } - printf(" %*d) ", - max_digits, ent->lno + 1 + cnt); } if (reset) fputs(reset, stdout); From patchwork Sat Mar 1 21:45:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleks Todorov X-Patchwork-Id: 13997694 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.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 53C441DDC11 for ; Sat, 1 Mar 2025 21:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865652; cv=none; b=Pt+8iTaU6O7FXHmGfwDDUP/SVGuGjmGsCYrs/FfL9HS8HDn+UitKLYdUJx8l/LI0lH9uVncoCKSU4UDUmfGCjv42zBwhXNQ0/12eL/MS1Ko953gxDws2JflHXwWmWHtpYV/+FSH3xcmLPnlRSL0TLgss/KQWBHqHeVbOJ6bQrRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865652; c=relaxed/simple; bh=fMoHu+AnZ0z5NdU9dr+UNA1zvtQ3lMbAEVfz5y1p25g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LA3LnGgMK9BkxhCDNiS540ThRzzPh5Iji1+lmmuAb1RNaM+qD9wizXd9XaVym4R9gEx2pvE6AbY62mH5lDEbKD3QUlry07DAF0EZw0B3Dshj/z7G23IGj8I2vGrYV4is+zzmTaaOB74MXKdootffM57F95IOWuDr3o7rx8/rqCQ= 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=HTjg5Aje; arc=none smtp.client-ip=209.85.221.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="HTjg5Aje" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-390ec7c2cd8so1268660f8f.1 for ; Sat, 01 Mar 2025 13:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740865648; x=1741470448; 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=nANSXsbnMVSPgk9DqfnzIonZ3gmkSlKLzQIs0eyq1Qw=; b=HTjg5AjeKgNSFUnxZ7tSHH8bgrhR+9j+yRu1FSkS+k26jXXUGVNp6wP8PWOmZFafbk oXSV8YPtbqvMfJ/QrgkOXiF4f1hZ7odm+4rdGmcdK34BwAeQq0PUbHfm80CiQ/QvJcsh p5PdGnSyPAlbvwDBtMhSI3nUtvLINp3MElQp3JdJuPm+0DBe/Q3gaGjSPWQfHjmVlRBE RkFxss1FCgV4igFOvjIyxuY4nHQAM5O38uJr1iTEk5VTaA2Byf0s2XXeHxG6CNwcBsGT sNCBH0nzTEmZuscxDl9IE2MnNrvgfVzygp1OSZZ2afZyhieoRFjiRE3lH3LxUjZ5vbmi Iv+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740865648; x=1741470448; 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=nANSXsbnMVSPgk9DqfnzIonZ3gmkSlKLzQIs0eyq1Qw=; b=YwseRk8z0E/MmMiLq4XNXafN+WiG1XbpbzBpLJvHKUlAbn00Hpzh0I/bn6+TLazvQF iC8d9EbJUYfaCqO4obAalti6iPiFngcC+R7sM5qCubGq6+3Z1uto1tyAjOcN+6qoOFMp yBNCyrPNwNPYFocTPbsznoKOsUxP4NA9O3KOm0MZ1gNrM7XZVKQXkFNGF+78yMrS5/O6 dq6bhtI/GQsiFEj2psgUDsJx6kr+4FiAMXYG6TNZA8GCzrb7kgDzMtOQhnvqw9ldiypE Vd4ubkHbdkf+qOqWmanbhnsWQY7WhS6mHPTdb2qFxhRbXvncTweRuZ8S2KMLQe93sUz/ hLAQ== X-Gm-Message-State: AOJu0Yxf4hDbLhdoByalp+NFvSp5LPcizF+g/+tvwdYlLTg3SAPjnu3O WUaY8GatZKsb7YpIkq2QIw2g1e5mp2z9tmyapa0NzRzCZXYIq+11FjX9L2xt X-Gm-Gg: ASbGncu7oc0L7WEdtT9UjSga40bDCtfWreaX9+SdlfYMANpY/uYQfXPMN0yoxX2qaZq 5qQPrh8Xu89GLaxnGR4sM5/xu6I/LVvtPIIZYBoyZw2JHh/J/LNh9NaVTx44K5BWxrkTF9LO+og xRJnF5ry4KHSIan6h8KEzGIyEB5Tr7J959jc1ZrnguoXXCSfJKp8AyXfLn4Reywrwswn0Wwa+zh WzUkaPjhV/ARHcT+jHGdYEMW48peAyx+jYcGwGXX938qUFVeLfJyGxHvs0RL/AYkePwXMlXJjxm CgjKgclwwvvDmGNjnYBNijoyrIJzkPMGDI8qZc3ezVdTsLQyD5PH+1SBEqsJ97y1Pi6ocxf+iMm iFFO6 X-Google-Smtp-Source: AGHT+IGSp0eETs5ntIxahot1h7SuKuc5JxxVaGBjVf9X645GhMEmK/UOVHP1i23YI+jGWuET5eDzpQ== X-Received: by 2002:a5d:64a6:0:b0:390:df6c:592a with SMTP id ffacd0b85a97d-390ec9bc813mr6082513f8f.29.1740865648295; Sat, 01 Mar 2025 13:47:28 -0800 (PST) Received: from aleksbgbg.communityfibre.co.uk ([103.205.25.90]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47a72d5sm9603474f8f.31.2025.03.01.13.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 13:47:28 -0800 (PST) From: Aleks Todorov To: git@vger.kernel.org Cc: Aleks Todorov Subject: [PATCH 5/7] t8015: Add tests for git blame -F Date: Sat, 1 Mar 2025 21:45:04 +0000 Message-ID: <20250301214652.536439-6-aleks.todorov.1337@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> References: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Include three tests, testing each facet of the implementation: - an empty format test to confirm that the flag is available and correctly hooked into git (respects empty format and does not emit any blame metadata) - a default format test to confirm that both the existing log specifiers and the new blame-specific specifiers %F and %L are expanded as expected - a config test to confirm that the blame.format config is available under the correct name and used by the program Signed-off-by: Aleks Todorov --- t/meson.build | 1 + t/t8015-blame-format.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 t/t8015-blame-format.sh diff --git a/t/meson.build b/t/meson.build index 780939d49f..da798fbc88 100644 --- a/t/meson.build +++ b/t/meson.build @@ -958,6 +958,7 @@ integration_tests = [ 't8012-blame-colors.sh', 't8013-blame-ignore-revs.sh', 't8014-blame-ignore-fuzzy.sh', + 't8015-blame-format.sh', 't9001-send-email.sh', 't9002-column.sh', 't9003-help-autocorrect.sh', diff --git a/t/t8015-blame-format.sh b/t/t8015-blame-format.sh new file mode 100755 index 0000000000..8d05310d5d --- /dev/null +++ b/t/t8015-blame-format.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +test_description='git blame -F option' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo line1 >file && + git add file && + git commit -m commit1 && + echo line2 >>file && + git add file && + git commit -m commit2 && + shortId1=$(git rev-parse HEAD^ | cut -c 1-8) && + shortId2=$(git rev-parse HEAD | cut -c 1-8) +' + +test_expect_success 'empty format' ' + echo "line1\nline2" >expect && + git blame file -F "" >actual && + test_cmp expect actual +' + +test_expect_success 'default format' ' + echo "$shortId1 file (A U Thor 2005-04-01 13:14:15 +0200 1) line1" >expect && + echo "$shortId2 file (A U Thor 2005-04-01 13:14:15 +0200 2) line2" >>expect && + git blame file -F "%h %F (%an %ai %L) " >/tmp/actual && + test_cmp expect /tmp/actual +' + +test_expect_success 'blame.format config' ' + echo "$shortId1 file (A U Thor 2005-04-01 13:14:15 +0200 1) line1" >expect && + echo "$shortId2 file (A U Thor 2005-04-01 13:14:15 +0200 2) line2" >>expect && + git config blame.format "%h %F (%an %ai %L) " && + git blame file >/tmp/actual && + test_cmp expect /tmp/actual +' + +test_done From patchwork Sat Mar 1 21:45:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleks Todorov X-Patchwork-Id: 13997695 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 EA0C11E9B25 for ; Sat, 1 Mar 2025 21:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865654; cv=none; b=ZJ0TeFp+YEFhRpIYJf2RoStUu6b1EzSq8chBlhvCyllEe5UOoujnST044a/Qx2Fk5sDB6iETgKkF3SvOA8vT4S5n1greZgoo6e+3IddfXUpnvraerUdmubblpvHQuwoHt0DZK3WK8RN0jWoTQzOSOj9S3mOaY9CBbWVhX7yyoQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865654; c=relaxed/simple; bh=QV07DhJIMHxtWRq1CGFNNT9rjGGofi0HiskOrHvY828=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CxgUNXKbw3TVKgsTMBXShsB+X5SvH/bYyTJP1YlRGW0A44rmcwKTDMPgyIz4CLHdvJsaGXSO5AnAjac2oLFefLVcOqqTr/yxNZ+ldome4tVIq4GIUDhp5/qT/ZIaHuK4MW8WtheTOpXM+6wglG7GnN0XwTUq46d778HmD8bxHAw= 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=mRZBfuhO; arc=none smtp.client-ip=209.85.128.50 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="mRZBfuhO" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4397e5d5d99so20747425e9.1 for ; Sat, 01 Mar 2025 13:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740865650; x=1741470450; 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=R0rEahlvEtGF93YYTHC3INBotz2Tk0t9NarOhMgL+pQ=; b=mRZBfuhOt5ptTPYjRUpfoTxvlK73eqW3IpEkGzuzhML6QhTvw/15rTqu/LmWVmvjBw D8flCaUTYvy6OjqVfaeq7LqlO+74clFHqVnafrl8+4mTe3YK1hFUezeMb56oOZAG3cxl z0vVYYl/nurwQECuyCOMZ16svqy8WRTWMBiAcnpcl4nCTDjxH4Ghk7THudZKgMWL24tc U96ICkV6jBhGz9sGmGB3bncu7k4WaFSIB4jOPcO1Ku1HRg9ZTkDEGboLMELpb9lnicYL 4lYOrZ8s0PQ88+SvImsYEFLU2mo9iwZFVks7fTK3T9Mwp35ON9bpa0bAsesDCybQucTp ODBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740865650; x=1741470450; 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=R0rEahlvEtGF93YYTHC3INBotz2Tk0t9NarOhMgL+pQ=; b=M0Ex4HCNVzG70iT8F/wMUyIeFqFrTYKjoa1//N0HJyvccKxDgURXYQfqNrOIj0Xvtk GbHAdVc7B0Sw5XQwHNqeceo56K6mvNBI/Nk4gzIBTRn0GFJyzLhY2qxmfyVqfEnf7fSV pslckl72HSzXOMICfCAZkaJwhIgkji8rAqvCDOjBHhWOL4cUrY/nt7HNBn8bwI/tLMdF 9yLn9kW5/zGcGQLhCPO/T0dpXWEe+SPARiB0+/gqYF+YmnTiU9Ygw4DKBfIBNb/zwL7c YAGmL6yPm2ldCTC6xrnbd2pxyPJ8Gn7+NSxxKBBCYOYu2fFHdRPyu4P+0yQE3wAH4912 Dl9g== X-Gm-Message-State: AOJu0YzfrCwRaGs8Df36pSrjJyjUsnf321HPQR6fp1j9mf/CQWk1AP+2 rJ4dbMlxharXrxb2ZhOv2uC6wHktcHlRD0R5oNX5eFnZBOVxJVk41mqZocH9 X-Gm-Gg: ASbGncsyfMtjgXDC7koquZCBxtPY7cYmdJShz9yeKz+dnoTOS2pcYYaNGxNRHdVdp9U BkoOAqeQcGK9pohwLdZyK4vuABRNHP/z5+P/wu4FjSoR13ZuLmWwHcdGIv1iczv8MxORIlThQ77 z6VPu6JMYcXE47agfIbLTBJ13noPOzcKQ+ud/gZeUXT8ipkWHkhOJshvRqYtdfZGitLXgQUX2gX dGmO6muUiDpktpBi3gK9ZQvTZ/v8YZBwDmiAGZ1mzuinMX1GYxnKAIjviZUNPdgY1g1acRLqEm5 20YkdM5GvVqHXbWlZWg3TBVaT0fe54tX2NsKH4hxptZd7bniLbqyZLEn2yPUZmqv+Lu2q0VLtKI E3dET X-Google-Smtp-Source: AGHT+IHWcBD/jCjgxfX48SOcUBpL/71l/thzCBVhPUkjNP8cosmBfNgwDP0zZ5DiGeptj38dHx8ImQ== X-Received: by 2002:a5d:6486:0:b0:38d:e420:3984 with SMTP id ffacd0b85a97d-390eca0ee3cmr7958145f8f.39.1740865649663; Sat, 01 Mar 2025 13:47:29 -0800 (PST) Received: from aleksbgbg.communityfibre.co.uk ([103.205.25.90]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47a72d5sm9603474f8f.31.2025.03.01.13.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 13:47:29 -0800 (PST) From: Aleks Todorov To: git@vger.kernel.org Cc: Aleks Todorov Subject: [PATCH 6/7] Documentation: Move placeholders to separate file Date: Sat, 1 Mar 2025 21:45:05 +0000 Message-ID: <20250301214652.536439-7-aleks.todorov.1337@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> References: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move formatting placeholders to a separate file so they can be included by multiple commands. In particular, git-blame will also need to include the placeholder docs for the new --format option. Signed-off-by: Aleks Todorov --- Documentation/placeholders.adoc | 238 +++++++++++++++++++++++++++++ Documentation/pretty-formats.adoc | 239 +----------------------------- 2 files changed, 239 insertions(+), 238 deletions(-) create mode 100644 Documentation/placeholders.adoc diff --git a/Documentation/placeholders.adoc b/Documentation/placeholders.adoc new file mode 100644 index 0000000000..7f4d0b59c7 --- /dev/null +++ b/Documentation/placeholders.adoc @@ -0,0 +1,238 @@ +The placeholders are: + +- Placeholders that expand to a single literal character: +'%n':: newline +'%%':: a raw '%' +'%x00':: '%x' followed by two hexadecimal digits is replaced with a + byte with the hexadecimal digits' value (we will call this + "literal formatting code" in the rest of this document). + +- Placeholders that affect formatting of later placeholders: +'%Cred':: switch color to red +'%Cgreen':: switch color to green +'%Cblue':: switch color to blue +'%Creset':: reset color +'%C(...)':: color specification, as described under Values in the + "CONFIGURATION FILE" section of linkgit:git-config[1]. By + default, colors are shown only when enabled for log output + (by `color.diff`, `color.ui`, or `--color`, and respecting + the `auto` settings of the former if we are going to a + terminal). `%C(auto,...)` is accepted as a historical + synonym for the default (e.g., `%C(auto,red)`). Specifying + `%C(always,...)` will show the colors even when color is + not otherwise enabled (though consider just using + `--color=always` to enable color for the whole output, + including this format and anything else git might color). + `auto` alone (i.e. `%C(auto)`) will turn on auto coloring + on the next placeholders until the color is switched + again. +'%m':: left (`<`), right (`>`) or boundary (`-`) mark +'%w([[,[,]]])':: switch line wrapping, like the -w option of + linkgit:git-shortlog[1]. +'%<( [,trunc|ltrunc|mtrunc])':: make the next placeholder take at + least N column widths, padding spaces on + the right if necessary. Optionally + truncate (with ellipsis '..') at the left (ltrunc) `..ft`, + the middle (mtrunc) `mi..le`, or the end + (trunc) `rig..`, if the output is longer than + N columns. + Note 1: that truncating + only works correctly with N >= 2. + Note 2: spaces around the N and M (see below) + values are optional. + Note 3: Emojis and other wide characters + will take two display columns, which may + over-run column boundaries. + Note 4: decomposed character combining marks + may be misplaced at padding boundaries. +'%<|( )':: make the next placeholder take at least until Mth + display column, padding spaces on the right if necessary. + Use negative M values for column positions measured + from the right hand edge of the terminal window. +'%>( )', '%>|( )':: similar to '%<( )', '%<|( )' respectively, + but padding spaces on the left +'%>>( )', '%>>|( )':: similar to '%>( )', '%>|( )' + respectively, except that if the next + placeholder takes more spaces than given and + there are spaces on its left, use those + spaces +'%><( )', '%><|( )':: similar to '%<( )', '%<|( )' + respectively, but padding both sides + (i.e. the text is centered) + +- Placeholders that expand to information extracted from the commit: +'%H':: commit hash +'%h':: abbreviated commit hash +'%T':: tree hash +'%t':: abbreviated tree hash +'%P':: parent hashes +'%p':: abbreviated parent hashes +'%an':: author name +'%aN':: author name (respecting .mailmap, see linkgit:git-shortlog[1] + or linkgit:git-blame[1]) +'%ae':: author email +'%aE':: author email (respecting .mailmap, see linkgit:git-shortlog[1] + or linkgit:git-blame[1]) +'%al':: author email local-part (the part before the '@' sign) +'%aL':: author local-part (see '%al') respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) +'%ad':: author date (format respects --date= option) +'%aD':: author date, RFC2822 style +'%ar':: author date, relative +'%at':: author date, UNIX timestamp +'%ai':: author date, ISO 8601-like format +'%aI':: author date, strict ISO 8601 format +'%as':: author date, short format (`YYYY-MM-DD`) +'%ah':: author date, human style (like the `--date=human` option of + linkgit:git-rev-list[1]) +'%cn':: committer name +'%cN':: committer name (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) +'%ce':: committer email +'%cE':: committer email (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) +'%cl':: committer email local-part (the part before the '@' sign) +'%cL':: committer local-part (see '%cl') respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) +'%cd':: committer date (format respects --date= option) +'%cD':: committer date, RFC2822 style +'%cr':: committer date, relative +'%ct':: committer date, UNIX timestamp +'%ci':: committer date, ISO 8601-like format +'%cI':: committer date, strict ISO 8601 format +'%cs':: committer date, short format (`YYYY-MM-DD`) +'%ch':: committer date, human style (like the `--date=human` option of + linkgit:git-rev-list[1]) +'%d':: ref names, like the --decorate option of linkgit:git-log[1] +'%D':: ref names without the " (", ")" wrapping. +'%(decorate[:])':: +ref names with custom decorations. The `decorate` string may be followed by a +colon and zero or more comma-separated options. Option values may contain +literal formatting codes. These must be used for commas (`%x2C`) and closing +parentheses (`%x29`), due to their role in the option syntax. ++ +** 'prefix=': Shown before the list of ref names. Defaults to "{nbsp}`(`". +** 'suffix=': Shown after the list of ref names. Defaults to "`)`". +** 'separator=': Shown between ref names. Defaults to "`,`{nbsp}". +** 'pointer=': Shown between HEAD and the branch it points to, if any. + Defaults to "{nbsp}`->`{nbsp}". +** 'tag=': Shown before tag names. Defaults to "`tag:`{nbsp}". + ++ +For example, to produce decorations with no wrapping +or tag annotations, and spaces as separators: ++ +`%(decorate:prefix=,suffix=,tag=,separator= )` + +'%(describe[:])':: +human-readable name, like linkgit:git-describe[1]; empty string for +undescribable commits. The `describe` string may be followed by a colon and +zero or more comma-separated options. Descriptions can be inconsistent when +tags are added or removed at the same time. ++ +** 'tags[=]': Instead of only considering annotated tags, + consider lightweight tags as well. +** 'abbrev=': Instead of using the default number of hexadecimal digits + (which will vary according to the number of objects in the repository with a + default of 7) of the abbreviated object name, use digits, or as many + digits as needed to form a unique object name. +** 'match=': Only consider tags matching the given + `glob(7)` pattern, excluding the "refs/tags/" prefix. +** 'exclude=': Do not consider tags matching the given + `glob(7)` pattern, excluding the "refs/tags/" prefix. + +'%S':: ref name given on the command line by which the commit was reached + (like `git log --source`), only works with `git log` +'%e':: encoding +'%s':: subject +'%f':: sanitized subject line, suitable for a filename +'%b':: body +'%B':: raw body (unwrapped subject and body) +ifndef::git-rev-list[] +'%N':: commit notes +endif::git-rev-list[] +'%GG':: raw verification message from GPG for a signed commit +'%G?':: show "G" for a good (valid) signature, + "B" for a bad signature, + "U" for a good signature with unknown validity, + "X" for a good signature that has expired, + "Y" for a good signature made by an expired key, + "R" for a good signature made by a revoked key, + "E" if the signature cannot be checked (e.g. missing key) + and "N" for no signature +'%GS':: show the name of the signer for a signed commit +'%GK':: show the key used to sign a signed commit +'%GF':: show the fingerprint of the key used to sign a signed commit +'%GP':: show the fingerprint of the primary key whose subkey was used + to sign a signed commit +'%GT':: show the trust level for the key used to sign a signed commit +'%gD':: reflog selector, e.g., `refs/stash@{1}` or `refs/stash@{2 + minutes ago}`; the format follows the rules described for the + `-g` option. The portion before the `@` is the refname as + given on the command line (so `git log -g refs/heads/master` + would yield `refs/heads/master@{0}`). +'%gd':: shortened reflog selector; same as `%gD`, but the refname + portion is shortened for human readability (so + `refs/heads/master` becomes just `master`). +'%gn':: reflog identity name +'%gN':: reflog identity name (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) +'%ge':: reflog identity email +'%gE':: reflog identity email (respecting .mailmap, see + linkgit:git-shortlog[1] or linkgit:git-blame[1]) +'%gs':: reflog subject +'%(trailers[:])':: +display the trailers of the body as interpreted by +linkgit:git-interpret-trailers[1]. The `trailers` string may be followed by +a colon and zero or more comma-separated options. If any option is provided +multiple times, the last occurrence wins. ++ +** 'key=': only show trailers with specified . Matching is done + case-insensitively and trailing colon is optional. If option is + given multiple times trailer lines matching any of the keys are + shown. This option automatically enables the `only` option so that + non-trailer lines in the trailer block are hidden. If that is not + desired it can be disabled with `only=false`. E.g., + `%(trailers:key=Reviewed-by)` shows trailer lines with key + `Reviewed-by`. +** 'only[=]': select whether non-trailer lines from the trailer + block should be included. +** 'separator=': specify the separator inserted between trailer + lines. Defaults to a line feed character. The string may contain + the literal formatting codes described above. To use comma as + separator one must use `%x2C` as it would otherwise be parsed as + next option. E.g., `%(trailers:key=Ticket,separator=%x2C )` + shows all trailer lines whose key is "Ticket" separated by a comma + and a space. +** 'unfold[=]': make it behave as if interpret-trailer's `--unfold` + option was given. E.g., + `%(trailers:only,unfold=true)` unfolds and shows all trailer lines. +** 'keyonly[=]': only show the key part of the trailer. +** 'valueonly[=]': only show the value part of the trailer. +** 'key_value_separator=': specify the separator inserted between + the key and value of each trailer. Defaults to ": ". Otherwise it + shares the same semantics as 'separator=' above. + +NOTE: Some placeholders may depend on other options given to the +revision traversal engine. For example, the `%g*` reflog options will +insert an empty string unless we are traversing reflog entries (e.g., by +`git log -g`). The `%d` and `%D` placeholders will use the "short" +decoration format if `--decorate` was not already provided on the command +line. + +The boolean options accept an optional value `[=]`. The +values taken by `--type=bool` git-config[1], like `yes` and `off`, +are all accepted. Giving a boolean option without `=` is +equivalent to giving it with `=true`. + +If you add a `+` (plus sign) after '%' of a placeholder, a line-feed +is inserted immediately before the expansion if and only if the +placeholder expands to a non-empty string. + +If you add a `-` (minus sign) after '%' of a placeholder, all consecutive +line-feeds immediately preceding the expansion are deleted if and only if the +placeholder expands to an empty string. + +If you add a ` ` (space) after '%' of a placeholder, a space +is inserted immediately before the expansion if and only if the +placeholder expands to a non-empty string. diff --git a/Documentation/pretty-formats.adoc b/Documentation/pretty-formats.adoc index 07475de8c3..68c0cebd26 100644 --- a/Documentation/pretty-formats.adoc +++ b/Documentation/pretty-formats.adoc @@ -117,244 +117,7 @@ The title was >>t4119: test autocomputing -p for traditional diff input.<< ------- + -The placeholders are: - -- Placeholders that expand to a single literal character: -'%n':: newline -'%%':: a raw '%' -'%x00':: '%x' followed by two hexadecimal digits is replaced with a - byte with the hexadecimal digits' value (we will call this - "literal formatting code" in the rest of this document). - -- Placeholders that affect formatting of later placeholders: -'%Cred':: switch color to red -'%Cgreen':: switch color to green -'%Cblue':: switch color to blue -'%Creset':: reset color -'%C(...)':: color specification, as described under Values in the - "CONFIGURATION FILE" section of linkgit:git-config[1]. By - default, colors are shown only when enabled for log output - (by `color.diff`, `color.ui`, or `--color`, and respecting - the `auto` settings of the former if we are going to a - terminal). `%C(auto,...)` is accepted as a historical - synonym for the default (e.g., `%C(auto,red)`). Specifying - `%C(always,...)` will show the colors even when color is - not otherwise enabled (though consider just using - `--color=always` to enable color for the whole output, - including this format and anything else git might color). - `auto` alone (i.e. `%C(auto)`) will turn on auto coloring - on the next placeholders until the color is switched - again. -'%m':: left (`<`), right (`>`) or boundary (`-`) mark -'%w([[,[,]]])':: switch line wrapping, like the -w option of - linkgit:git-shortlog[1]. -'%<( [,trunc|ltrunc|mtrunc])':: make the next placeholder take at - least N column widths, padding spaces on - the right if necessary. Optionally - truncate (with ellipsis '..') at the left (ltrunc) `..ft`, - the middle (mtrunc) `mi..le`, or the end - (trunc) `rig..`, if the output is longer than - N columns. - Note 1: that truncating - only works correctly with N >= 2. - Note 2: spaces around the N and M (see below) - values are optional. - Note 3: Emojis and other wide characters - will take two display columns, which may - over-run column boundaries. - Note 4: decomposed character combining marks - may be misplaced at padding boundaries. -'%<|( )':: make the next placeholder take at least until Mth - display column, padding spaces on the right if necessary. - Use negative M values for column positions measured - from the right hand edge of the terminal window. -'%>( )', '%>|( )':: similar to '%<( )', '%<|( )' respectively, - but padding spaces on the left -'%>>( )', '%>>|( )':: similar to '%>( )', '%>|( )' - respectively, except that if the next - placeholder takes more spaces than given and - there are spaces on its left, use those - spaces -'%><( )', '%><|( )':: similar to '%<( )', '%<|( )' - respectively, but padding both sides - (i.e. the text is centered) - -- Placeholders that expand to information extracted from the commit: -'%H':: commit hash -'%h':: abbreviated commit hash -'%T':: tree hash -'%t':: abbreviated tree hash -'%P':: parent hashes -'%p':: abbreviated parent hashes -'%an':: author name -'%aN':: author name (respecting .mailmap, see linkgit:git-shortlog[1] - or linkgit:git-blame[1]) -'%ae':: author email -'%aE':: author email (respecting .mailmap, see linkgit:git-shortlog[1] - or linkgit:git-blame[1]) -'%al':: author email local-part (the part before the '@' sign) -'%aL':: author local-part (see '%al') respecting .mailmap, see - linkgit:git-shortlog[1] or linkgit:git-blame[1]) -'%ad':: author date (format respects --date= option) -'%aD':: author date, RFC2822 style -'%ar':: author date, relative -'%at':: author date, UNIX timestamp -'%ai':: author date, ISO 8601-like format -'%aI':: author date, strict ISO 8601 format -'%as':: author date, short format (`YYYY-MM-DD`) -'%ah':: author date, human style (like the `--date=human` option of - linkgit:git-rev-list[1]) -'%cn':: committer name -'%cN':: committer name (respecting .mailmap, see - linkgit:git-shortlog[1] or linkgit:git-blame[1]) -'%ce':: committer email -'%cE':: committer email (respecting .mailmap, see - linkgit:git-shortlog[1] or linkgit:git-blame[1]) -'%cl':: committer email local-part (the part before the '@' sign) -'%cL':: committer local-part (see '%cl') respecting .mailmap, see - linkgit:git-shortlog[1] or linkgit:git-blame[1]) -'%cd':: committer date (format respects --date= option) -'%cD':: committer date, RFC2822 style -'%cr':: committer date, relative -'%ct':: committer date, UNIX timestamp -'%ci':: committer date, ISO 8601-like format -'%cI':: committer date, strict ISO 8601 format -'%cs':: committer date, short format (`YYYY-MM-DD`) -'%ch':: committer date, human style (like the `--date=human` option of - linkgit:git-rev-list[1]) -'%d':: ref names, like the --decorate option of linkgit:git-log[1] -'%D':: ref names without the " (", ")" wrapping. -'%(decorate[:])':: -ref names with custom decorations. The `decorate` string may be followed by a -colon and zero or more comma-separated options. Option values may contain -literal formatting codes. These must be used for commas (`%x2C`) and closing -parentheses (`%x29`), due to their role in the option syntax. -+ -** 'prefix=': Shown before the list of ref names. Defaults to "{nbsp}`(`". -** 'suffix=': Shown after the list of ref names. Defaults to "`)`". -** 'separator=': Shown between ref names. Defaults to "`,`{nbsp}". -** 'pointer=': Shown between HEAD and the branch it points to, if any. - Defaults to "{nbsp}`->`{nbsp}". -** 'tag=': Shown before tag names. Defaults to "`tag:`{nbsp}". - -+ -For example, to produce decorations with no wrapping -or tag annotations, and spaces as separators: -+ -`%(decorate:prefix=,suffix=,tag=,separator= )` - -'%(describe[:])':: -human-readable name, like linkgit:git-describe[1]; empty string for -undescribable commits. The `describe` string may be followed by a colon and -zero or more comma-separated options. Descriptions can be inconsistent when -tags are added or removed at the same time. -+ -** 'tags[=]': Instead of only considering annotated tags, - consider lightweight tags as well. -** 'abbrev=': Instead of using the default number of hexadecimal digits - (which will vary according to the number of objects in the repository with a - default of 7) of the abbreviated object name, use digits, or as many - digits as needed to form a unique object name. -** 'match=': Only consider tags matching the given - `glob(7)` pattern, excluding the "refs/tags/" prefix. -** 'exclude=': Do not consider tags matching the given - `glob(7)` pattern, excluding the "refs/tags/" prefix. - -'%S':: ref name given on the command line by which the commit was reached - (like `git log --source`), only works with `git log` -'%e':: encoding -'%s':: subject -'%f':: sanitized subject line, suitable for a filename -'%b':: body -'%B':: raw body (unwrapped subject and body) -ifndef::git-rev-list[] -'%N':: commit notes -endif::git-rev-list[] -'%GG':: raw verification message from GPG for a signed commit -'%G?':: show "G" for a good (valid) signature, - "B" for a bad signature, - "U" for a good signature with unknown validity, - "X" for a good signature that has expired, - "Y" for a good signature made by an expired key, - "R" for a good signature made by a revoked key, - "E" if the signature cannot be checked (e.g. missing key) - and "N" for no signature -'%GS':: show the name of the signer for a signed commit -'%GK':: show the key used to sign a signed commit -'%GF':: show the fingerprint of the key used to sign a signed commit -'%GP':: show the fingerprint of the primary key whose subkey was used - to sign a signed commit -'%GT':: show the trust level for the key used to sign a signed commit -'%gD':: reflog selector, e.g., `refs/stash@{1}` or `refs/stash@{2 - minutes ago}`; the format follows the rules described for the - `-g` option. The portion before the `@` is the refname as - given on the command line (so `git log -g refs/heads/master` - would yield `refs/heads/master@{0}`). -'%gd':: shortened reflog selector; same as `%gD`, but the refname - portion is shortened for human readability (so - `refs/heads/master` becomes just `master`). -'%gn':: reflog identity name -'%gN':: reflog identity name (respecting .mailmap, see - linkgit:git-shortlog[1] or linkgit:git-blame[1]) -'%ge':: reflog identity email -'%gE':: reflog identity email (respecting .mailmap, see - linkgit:git-shortlog[1] or linkgit:git-blame[1]) -'%gs':: reflog subject -'%(trailers[:])':: -display the trailers of the body as interpreted by -linkgit:git-interpret-trailers[1]. The `trailers` string may be followed by -a colon and zero or more comma-separated options. If any option is provided -multiple times, the last occurrence wins. -+ -** 'key=': only show trailers with specified . Matching is done - case-insensitively and trailing colon is optional. If option is - given multiple times trailer lines matching any of the keys are - shown. This option automatically enables the `only` option so that - non-trailer lines in the trailer block are hidden. If that is not - desired it can be disabled with `only=false`. E.g., - `%(trailers:key=Reviewed-by)` shows trailer lines with key - `Reviewed-by`. -** 'only[=]': select whether non-trailer lines from the trailer - block should be included. -** 'separator=': specify the separator inserted between trailer - lines. Defaults to a line feed character. The string may contain - the literal formatting codes described above. To use comma as - separator one must use `%x2C` as it would otherwise be parsed as - next option. E.g., `%(trailers:key=Ticket,separator=%x2C )` - shows all trailer lines whose key is "Ticket" separated by a comma - and a space. -** 'unfold[=]': make it behave as if interpret-trailer's `--unfold` - option was given. E.g., - `%(trailers:only,unfold=true)` unfolds and shows all trailer lines. -** 'keyonly[=]': only show the key part of the trailer. -** 'valueonly[=]': only show the value part of the trailer. -** 'key_value_separator=': specify the separator inserted between - the key and value of each trailer. Defaults to ": ". Otherwise it - shares the same semantics as 'separator=' above. - -NOTE: Some placeholders may depend on other options given to the -revision traversal engine. For example, the `%g*` reflog options will -insert an empty string unless we are traversing reflog entries (e.g., by -`git log -g`). The `%d` and `%D` placeholders will use the "short" -decoration format if `--decorate` was not already provided on the command -line. - -The boolean options accept an optional value `[=]`. The -values taken by `--type=bool` git-config[1], like `yes` and `off`, -are all accepted. Giving a boolean option without `=` is -equivalent to giving it with `=true`. - -If you add a `+` (plus sign) after '%' of a placeholder, a line-feed -is inserted immediately before the expansion if and only if the -placeholder expands to a non-empty string. - -If you add a `-` (minus sign) after '%' of a placeholder, all consecutive -line-feeds immediately preceding the expansion are deleted if and only if the -placeholder expands to an empty string. - -If you add a ` ` (space) after '%' of a placeholder, a space -is inserted immediately before the expansion if and only if the -placeholder expands to a non-empty string. +include::placeholders.adoc[] * 'tformat:' + From patchwork Sat Mar 1 21:45:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleks Todorov X-Patchwork-Id: 13997696 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 7B44B1DDC11 for ; Sat, 1 Mar 2025 21:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865655; cv=none; b=r/XDZjjX+EPFWU8BLnJvfArfXolAAIakZRdZEYbpgcpYmDZ17y6U/wChnkz/m962T3QlC0L1vWrfAuRBPW6zPryiIsTImZ3+VWbacxjBvi/oNjwksiOhT9Yk+8CahyIKn5aaoki2wNzTYIUMFieIkSJsvMSFAPk0SneslVMcCso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740865655; c=relaxed/simple; bh=VDzbMFBxEVjLZpqE5rC34q6jnqzw5lGIfZE2QJ0Xw94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ri35wZi2yc3NCfOi2ZhRJk8YE5lj/4L/BQc0l/i6JTdwhU4ajGWjiyuUAw9EZkZzHruqVVFYAehfP+8aKNTsJGu+fiTeuiBCtdySL0MbO8ZRyOJHo/Y+BipsEarNOGaPtk7S7KhVJWpfaSD9StgDkQIRAvKt4OJ8F9/NOHk7GQA= 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=b5v8q3ck; arc=none smtp.client-ip=209.85.128.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="b5v8q3ck" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-439946a49e1so20568105e9.0 for ; Sat, 01 Mar 2025 13:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740865652; x=1741470452; 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=DNoDGICRIZjpFc0M3crv7zQYP0PG5C5ExoDptZTbM90=; b=b5v8q3cks1zDI0d5H4YTYKgJ/kbXaYdX0uTgbR04UzPMiw4BpwSxN6sCVsR8r81FC8 ecz22yUydEDkB2xEiE4a5m5JZD3bIQLpVCjzOWcd1MTAUP/8R4SqJbM++VSqgbl/Ixu3 AuNXsOLeDjCt4rdCYPAjNOiBYM9OI/8os/4vu9bp4RCdc927oPSlHD9TSEdreAknpbfK tBY2/5oIVbfuCKvDruFldoGi/AmXF69mCrSTtZPErfrtdwUozrnXf9b3bkYesuszrgGC B4MaZkC31Y41GF44usABFeV9btDZpoJ5KBf3MhkNZNG/ccXXuLLRxJDiSp4VXBVt1pYl vKeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740865652; x=1741470452; 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=DNoDGICRIZjpFc0M3crv7zQYP0PG5C5ExoDptZTbM90=; b=jEheLruUwE87IbY6VOywkx/AINqnrMYIbsZUB061hM0tft3Z3C8EzWZVImR/MxO2FC dIZKXTkVn4SRyyeSUek55BrIU6HXaEmrR0GKuugeLsZtNnwEXpzeK/mE2VImiHy5aALA vYCQbNb5+KsWENXk8tuldgft4ZGrPHxn39lrEKsf8RT1NAEufjrW+p7lpgfcgeG8Ivz3 QvrGf2ChZlSoImWvy9EWcbSYysR2wR9a3XAEtW0INaGVNFEyzVp1QFNfOo1BStU7zOCP JA0PYpEDP7Gu+AdKEScNxI32JNZJwcWm8UOEwgVsT6lsKOoETVvGrbvaXwC3piAlB8bn Sq2g== X-Gm-Message-State: AOJu0YyLr73Thj/UKELMPK89tCGfQSASFfn7iC9JXEIc9w+k8Wfz6PEZ PqY0mgjSARrpbaHrWUEddQWsNJx3V8Q9m7e7NZrtbpZoQFF3AKr399fJQkom X-Gm-Gg: ASbGnctwUqBLErWfl2dMfZJwCKR6VVGqQ938tCduauPx8RU1Lb3r1izIjdketJT8L4d Ih6vWmuVkd/WAUHXqlxf96A+5IzkfVBnm8AJZvRHkZhqm5LCHwlEzZZhP/+shU6hmSqrmOxmJ0r Wb8xs8sbkaT+uiFAQwlS45wmm1pXw77tpoEWDhh7uE1YLkMF9z+rMaW4x/HbxBvFVaJntlMQpqB DJeWSto2yFMRUFb7QVZQ97UEqUs+dnFbZjrQm+thqKtUmGwiip7j07v5D6HLRqJdw0tz1rb5QHi 9qUvIQ0oGgsIW/j33EYaHg+YTPDvrnBbXd12yQo99m3X+ykzdiAuiShtSjaW0Wq4wpdR5v8/lol JyNus X-Google-Smtp-Source: AGHT+IFK/km3SasBMv8OmulDTsrX7d4fQidtwanw1gZGD4FeRPKa09yG7OzzcXRT4f+vDMFxwiPmBw== X-Received: by 2002:a5d:47c3:0:b0:38f:48ee:ddc2 with SMTP id ffacd0b85a97d-390eca47db0mr6699001f8f.37.1740865651641; Sat, 01 Mar 2025 13:47:31 -0800 (PST) Received: from aleksbgbg.communityfibre.co.uk ([103.205.25.90]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-390e47a72d5sm9603474f8f.31.2025.03.01.13.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Mar 2025 13:47:30 -0800 (PST) From: Aleks Todorov To: git@vger.kernel.org Cc: Aleks Todorov Subject: [PATCH 7/7] Documentation: Add docs for blame format Date: Sat, 1 Mar 2025 21:45:06 +0000 Message-ID: <20250301214652.536439-8-aleks.todorov.1337@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> References: <20250301214652.536439-1-aleks.todorov.1337@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add documentation explaining the new `git blame --format` option as well as the associated `blame.format` config option. Include a section listing the available placeholders. Also document the new (blame-specific) placeholders in this section. Signed-off-by: Aleks Todorov --- Documentation/config/blame.adoc | 5 +++++ Documentation/git-blame.adoc | 16 ++++++++++++++++ Documentation/placeholders.adoc | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/Documentation/config/blame.adoc b/Documentation/config/blame.adoc index 4d047c1790..88ef551c04 100644 --- a/Documentation/config/blame.adoc +++ b/Documentation/config/blame.adoc @@ -35,3 +35,8 @@ blame.markUnblamableLines:: blame.markIgnoredLines:: Mark lines that were changed by an ignored revision that we attributed to another commit with a '?' in the output of linkgit:git-blame[1]. + +blame.format:: + Apply the specified format by default when invoking + linkgit:git-blame[1]. For supported format specifiers, see the + discussion of the `--format` option in linkgit:git-blame[1]. diff --git a/Documentation/git-blame.adoc b/Documentation/git-blame.adoc index f75ed44790..373ff6b994 100644 --- a/Documentation/git-blame.adoc +++ b/Documentation/git-blame.adoc @@ -62,6 +62,17 @@ include::blame-options.adoc[] a certain threshold for 'git blame' to consider those lines of code to have been moved. +-F:: +--format:: + Emit blame information in a given ''. '' is a string + that can contain '%placeholder' specifiers, which will be expanded to + produce blame information. ++ +See the "PLACEHOLDERS" section to learn about all of the available specifiers. ++ +Note: you can specify the default blame format in the repository configuration +(see `blame.format` in linkgit:git-config[1]). + -f:: --show-name:: Show the filename in the original commit. By default @@ -235,6 +246,11 @@ one) at the beginning of the "extended information" lines. That way, if there is ever added information (like the commit encoding or extended commit commentary), a blame viewer will not care. +PLACEHOLDERS +------------ + +:git-blame: 1 +include::placeholders.adoc[] MAPPING AUTHORS --------------- diff --git a/Documentation/placeholders.adoc b/Documentation/placeholders.adoc index 7f4d0b59c7..5420a44e94 100644 --- a/Documentation/placeholders.adoc +++ b/Documentation/placeholders.adoc @@ -145,6 +145,10 @@ tags are added or removed at the same time. (like `git log --source`), only works with `git log` '%e':: encoding '%s':: subject +ifdef::git-blame[] +'%L':: line number +'%F':: filename in the original commit +endif::git-blame[] '%f':: sanitized subject line, suitable for a filename '%b':: body '%B':: raw body (unwrapped subject and body)