From patchwork Mon Oct 23 22:11:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Koppe X-Patchwork-Id: 13433647 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83042224D7 for ; Mon, 23 Oct 2023 22:11:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k2kR1uEG" Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D1159B for ; Mon, 23 Oct 2023 15:11:58 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-313e742a787so2174727f8f.1 for ; Mon, 23 Oct 2023 15:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698099116; x=1698703916; 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=ptiY9uGr0tGcZYfRLICQClF0krFFysLZ7VCGpBGmACM=; b=k2kR1uEGrI18i5maC0iy3g+2dSKIsOwiQSL9cT3wZC2eAnf66N4G80VEavB5gusXMe 2P5xgVIbQzsvbC9P1k9BtAku0SIgKpxCCl7B9lt4o7y/ODqXzaB2+a8D3damuyzP8dqZ J2KEGRj4P32rTzn4vNKUnOsW5o9uI9DPCd7QhVluzefpj2ijEle7N3Wt+1Tt8RS7Oh27 EJ85Yg7OKMET3AOjJtVZ4Z8w6wzYYG/4FlQNlgtkTAYAndS2Ivp6nHrYpa5BVgplavgR Z90m0MmOgKQmgiWm4HcSPeaKfj7woN6NyIdgIDKbV5ak748tsncbQbKXW6Q/QUs1ZsZl WTxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698099116; x=1698703916; 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=ptiY9uGr0tGcZYfRLICQClF0krFFysLZ7VCGpBGmACM=; b=I2KwQzsDurczfoc53eS+AheHB4Ah350MOJvzdrqdzag2N6YrO7bnvKrz87huZ9DYC7 6yIo10FzkMryIwxfEyRKvV0zbbfnbHxWR1htk4X9p5vwBi7SP0oF2YI+U5/xUvRYiQQR og6UGyykxh7FfpsL8sN5OnnmLwQv9Yv08MWx69h+YObsbqhen3FaCXVW95SZWyVH4dHp rctzCoJ01ErMbioODzbTkLKKlaiiTrqwukn+lg0GMEWoDegpNaPFXPNlPDChlS1Xy5zG Vr+nl8cLC4PcRN7iJWOUQA4MEqfLbsF3Y2tjdpUFwlFAkvAMWSl390/AlZc/UwrfLxMd tCuA== X-Gm-Message-State: AOJu0YzGOXNmsHIUsJatFLMG9X8v+SyUaIXNMbwjAndzWL86vdJ6+cIE hm95ZgWxss+1QPeswgoSucNySjFnyIg18A== X-Google-Smtp-Source: AGHT+IGT7Hxg0+ZGLev5gCqMecFXSZ8dcdvN+s+VQr8LnXHORsgf70ewSSAkGkvuMy8iXczcwH0kYg== X-Received: by 2002:adf:9cc6:0:b0:31f:f8a7:a26c with SMTP id h6-20020adf9cc6000000b0031ff8a7a26cmr11127391wre.25.1698099116504; Mon, 23 Oct 2023 15:11:56 -0700 (PDT) Received: from localhost.localdomain (cpc105060-sgyl40-2-0-cust995.18-2.cable.virginm.net. [81.111.15.228]) by smtp.gmail.com with ESMTPSA id w11-20020a5d608b000000b0032008f99216sm8559953wrt.96.2023.10.23.15.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 15:11:56 -0700 (PDT) From: Andy Koppe To: git@vger.kernel.org Cc: gitster@pobox.com, stolee@gmail.com, Andy Koppe Subject: [PATCH v3 1/7] config: restructure color.decorate documentation Date: Mon, 23 Oct 2023 23:11:37 +0100 Message-ID: <20231023221143.72489-2-andy.koppe@gmail.com> X-Mailer: git-send-email 2.42.GIT In-Reply-To: <20231023221143.72489-1-andy.koppe@gmail.com> References: <20231022214432.56325-1-andy.koppe@gmail.com> <20231023221143.72489-1-andy.koppe@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 List color.decorate slots in git-config documentation one-by-one in the same way as color.grep slots, to aid readability and make it easier to add slots. Signed-off-by: Andy Koppe --- Documentation/config/color.txt | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Documentation/config/color.txt b/Documentation/config/color.txt index 1795b2d16b..3453703f9b 100644 --- a/Documentation/config/color.txt +++ b/Documentation/config/color.txt @@ -74,10 +74,25 @@ color.diff.:: `oldBold`, and `newBold` (see linkgit:git-range-diff[1] for details). color.decorate.:: - Use customized color for 'git log --decorate' output. `` is one - of `branch`, `remoteBranch`, `tag`, `stash` or `HEAD` for local - branches, remote-tracking branches, tags, stash and HEAD, respectively - and `grafted` for grafted commits. + Use customized color for the output of 'git log --decorate' as well as + the `%d`, `%D` and `%(decorate)` placeholders in custom log formats, + whereby `` specifies which decoration elements the color applies + to: ++ +-- +`HEAD`;; + the current HEAD +`branch`;; + local branches +`remoteBranch`;; + remote-tracking branches +`tag`;; + lightweight and annotated tags +`stash`;; + the stash ref +`grafted`;; + grafted and replaced commits +-- color.grep:: When set to `always`, always highlight matches. When `false` (or From patchwork Mon Oct 23 22:11:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Koppe X-Patchwork-Id: 13433648 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 964C02376D for ; Mon, 23 Oct 2023 22:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D7kTk0/b" Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4FF7BC for ; Mon, 23 Oct 2023 15:11:58 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3226cc3e324so3007851f8f.3 for ; Mon, 23 Oct 2023 15:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698099117; x=1698703917; 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=e1lvhVCXRzMw7HgOrEKsA1o0NdzhK9+ehJB0Dc8CB+A=; b=D7kTk0/bDqbMYAZIsYF1FEistUpnLweOQMGLNZyafww0IbwXrhHSjEEYjTIj+mclEX wh+LOH4mA6BcLq5yV4mFTdICa/OOSTv5Nk6ZjvVx5tsTpTeqHkzsL8tQbhLT1G5bvWqB GdODi+H7iEXUlvIcwomimWvt5Mi36qsSWj4alN+dXErndNPqPYZ0JGGYPspJHBlsS0jc n9MELWoYAV/ymnyfVQY8MVKtCWEXyXues01GL0Z79jRLbviI/Ah3ynrWkiDWMncI+Hu+ 5+9KsFzr2P0vmlzRRj0QZviqnJhoTEqXSJ0DD6MLkkoa/VI3guq1JSRg0WTwrwNaTByT mu8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698099117; x=1698703917; 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=e1lvhVCXRzMw7HgOrEKsA1o0NdzhK9+ehJB0Dc8CB+A=; b=jqxJJRhkmqpVjYiyXcvOsH20XHj2SZfoqa01mUfWEaHb3NGKkEffULmeqvcUeD4CrY 5HSq+aCaoGTXpCiyyvVVz9GdYYFjK5rtcIJGsmlphGzUqGbNXca3S21nMOPS54VLDAfZ PDCBh5EAFh+2P9UHZOmk+mF8xdcM+AzXqWUZNEoY7YZ+rxjN8ezNUkCt4DwhFjdA8bCA BU5Q1EJGz6y5CWkS2MDBT5lOFSeAQfIdhn/9a5FHW7aegu1ibgc2+jntmio6NuKQJGaM 6KyXw+DumbzNr6RGCnydeI5x6rGdE5Qi1cxf7Z1TPNjQrvOZgTq6t9s2KgiYNkEX/i1b E13A== X-Gm-Message-State: AOJu0YzVpXZflUHE5JAmQsdtgga9GXe0V9WyTyuM2gzCUXaUlqjW5IpF xra5/hvqMdPxsBGZHM+7Md9oP8ZkDGwJhA== X-Google-Smtp-Source: AGHT+IH4ScxFpMlNRVzmyoHgYuNN6kgLMu8+dBYNGaQb/AL3tQds/yAae1H6xovmG5yXALxH850YfQ== X-Received: by 2002:adf:fa4f:0:b0:319:67ac:4191 with SMTP id y15-20020adffa4f000000b0031967ac4191mr7938104wrr.37.1698099117176; Mon, 23 Oct 2023 15:11:57 -0700 (PDT) Received: from localhost.localdomain (cpc105060-sgyl40-2-0-cust995.18-2.cable.virginm.net. [81.111.15.228]) by smtp.gmail.com with ESMTPSA id w11-20020a5d608b000000b0032008f99216sm8559953wrt.96.2023.10.23.15.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 15:11:56 -0700 (PDT) From: Andy Koppe To: git@vger.kernel.org Cc: gitster@pobox.com, stolee@gmail.com, Andy Koppe Subject: [PATCH v3 2/7] log: use designated inits for decoration_colors Date: Mon, 23 Oct 2023 23:11:38 +0100 Message-ID: <20231023221143.72489-3-andy.koppe@gmail.com> X-Mailer: git-send-email 2.42.GIT In-Reply-To: <20231023221143.72489-1-andy.koppe@gmail.com> References: <20231022214432.56325-1-andy.koppe@gmail.com> <20231023221143.72489-1-andy.koppe@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use designated initializers instead of comments to denote the slots in the decoration_colors array for holding color settings, to make it consistent with the immediately following color_decorate_slots array and reduce the likelihood of mistakes when extending them. Signed-off-by: Andy Koppe --- log-tree.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/log-tree.c b/log-tree.c index 504da6b519..8bdf889f02 100644 --- a/log-tree.c +++ b/log-tree.c @@ -34,13 +34,13 @@ static int decoration_loaded; static int decoration_flags; static char decoration_colors[][COLOR_MAXLEN] = { - GIT_COLOR_RESET, - GIT_COLOR_BOLD_GREEN, /* REF_LOCAL */ - GIT_COLOR_BOLD_RED, /* REF_REMOTE */ - GIT_COLOR_BOLD_YELLOW, /* REF_TAG */ - GIT_COLOR_BOLD_MAGENTA, /* REF_STASH */ - GIT_COLOR_BOLD_CYAN, /* REF_HEAD */ - GIT_COLOR_BOLD_BLUE, /* GRAFTED */ + [DECORATION_NONE] = GIT_COLOR_RESET, + [DECORATION_REF_LOCAL] = GIT_COLOR_BOLD_GREEN, + [DECORATION_REF_REMOTE] = GIT_COLOR_BOLD_RED, + [DECORATION_REF_TAG] = GIT_COLOR_BOLD_YELLOW, + [DECORATION_REF_STASH] = GIT_COLOR_BOLD_MAGENTA, + [DECORATION_REF_HEAD] = GIT_COLOR_BOLD_CYAN, + [DECORATION_GRAFTED] = GIT_COLOR_BOLD_BLUE, }; static const char *color_decorate_slots[] = { From patchwork Mon Oct 23 22:11:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Koppe X-Patchwork-Id: 13433652 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 887D324206 for ; Mon, 23 Oct 2023 22:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Iy3Bi3rP" Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD63F9 for ; Mon, 23 Oct 2023 15:11:59 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4083f613275so31348135e9.2 for ; Mon, 23 Oct 2023 15:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698099118; x=1698703918; 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=IzsjamE7jN7HxkAhFVpQRuLG40ZGjdHKjqFlQ6bMONs=; b=Iy3Bi3rPErfbZbQ1Lb+TI03C1D+UQs/Z9LMkTpzW2bu9JYdBsFxj4ohYP7NyvPrFfe nDnEa5Aj8PYYiuN65PCihui74sRVSu8WQZWY934JI1fEH9YnpQk1BxB2xZ6HQrZOwr15 ag7pZJeo1U9R7VOlNKtFQirn1ljVnjgPecVkbL8oI2JGOciJo0+POsTMwBcDm95WrFf9 HKpc1mz5bX5XUgEwlxArvJVAAwFHC9p3o7U2XeGiozsNTmBbHMSWHDol+5fEV28hGkC5 6wZeJBjhAvbtJM3665JB7zo8XSD73cCZd6V0pI/xaIXBhc6yZ4/awoEovQnthIrYRZFe gAjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698099118; x=1698703918; 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=IzsjamE7jN7HxkAhFVpQRuLG40ZGjdHKjqFlQ6bMONs=; b=kWiOlIsu6a2dyWB0BjkxUhVI3Tlep5cfludZ8MptKVt72m7hWZiCCD3Hte39rrsebL VOVD9/RyO8rceriG09DAX/yzm0wjIj57qR2yyDjBi1Y9V6Hc5QrESF/sFhjSXDqtKNWo Amk4/R5632asdYhua9Yj1vba7eeXxgGWESu7TAqMuchxw92sETXnJXlx8DbW6YGVEMrN gl7g7sR3wrONyCfu/o3nXALVyqHRmo8YjDZ0NVsUSdtnYItsTF/Do2EaUj2rzwdLCaUh zvPLdlLkJni+5kpTRifoaSAnmfot/zJoiBCwu0yM8vELnUN0PdsjgNHg9X+BcYPbIWA6 qTHQ== X-Gm-Message-State: AOJu0YwETu96Z+D5F2iR+8StFpHpJ5b2Qc9McVf8Uw8Ldbb4GlHPcdZ8 d5udWWEudbyo1/Zd3dCVjlBYIUfRiEOdJA== X-Google-Smtp-Source: AGHT+IFjI+7COj2xpKAfY5bHeNZC7v8pJJJdyv+9BVQ2zhMuEdBd/T+wSIQJdb8UM4xnWkRZW3XzeQ== X-Received: by 2002:a05:600c:3b0f:b0:406:44e6:c00d with SMTP id m15-20020a05600c3b0f00b0040644e6c00dmr8924618wms.2.1698099117992; Mon, 23 Oct 2023 15:11:57 -0700 (PDT) Received: from localhost.localdomain (cpc105060-sgyl40-2-0-cust995.18-2.cable.virginm.net. [81.111.15.228]) by smtp.gmail.com with ESMTPSA id w11-20020a5d608b000000b0032008f99216sm8559953wrt.96.2023.10.23.15.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 15:11:57 -0700 (PDT) From: Andy Koppe To: git@vger.kernel.org Cc: gitster@pobox.com, stolee@gmail.com, Andy Koppe Subject: [PATCH v3 3/7] log: add color.decorate.symbol config variable Date: Mon, 23 Oct 2023 23:11:39 +0100 Message-ID: <20231023221143.72489-4-andy.koppe@gmail.com> X-Mailer: git-send-email 2.42.GIT In-Reply-To: <20231023221143.72489-1-andy.koppe@gmail.com> References: <20231022214432.56325-1-andy.koppe@gmail.com> <20231023221143.72489-1-andy.koppe@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add new color.decorate.symbol config variable for determining the color of the prefix, suffix, separator and pointer symbols used in log --decorate output and related log format placeholders, to allow them to be colored differently from commit hashes. For backward compatibility, fall back to the commit hash color that can be specified with the color.diff.commit variable if the new variable is not provided. Add the variable to the color.decorate. documentation. Amend t4207-log-decoration-colors.sh to test it. Put ${c_reset} elements in the expected output at the end of lines for consistency. Signed-off-by: Andy Koppe --- Documentation/config/color.txt | 2 ++ commit.h | 1 + log-tree.c | 15 ++++++--- t/t4207-log-decoration-colors.sh | 58 +++++++++++++++++--------------- 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/Documentation/config/color.txt b/Documentation/config/color.txt index 3453703f9b..cc0a881125 100644 --- a/Documentation/config/color.txt +++ b/Documentation/config/color.txt @@ -92,6 +92,8 @@ color.decorate.:: the stash ref `grafted`;; grafted and replaced commits +`symbol`;; + punctuation symbols surrounding the other elements -- color.grep:: diff --git a/commit.h b/commit.h index 28928833c5..cb13e4d5ba 100644 --- a/commit.h +++ b/commit.h @@ -56,6 +56,7 @@ enum decoration_type { DECORATION_REF_STASH, DECORATION_REF_HEAD, DECORATION_GRAFTED, + DECORATION_SYMBOL, }; void add_name_decoration(enum decoration_type type, const char *name, struct object *obj); diff --git a/log-tree.c b/log-tree.c index 8bdf889f02..890024f205 100644 --- a/log-tree.c +++ b/log-tree.c @@ -41,6 +41,7 @@ static char decoration_colors[][COLOR_MAXLEN] = { [DECORATION_REF_STASH] = GIT_COLOR_BOLD_MAGENTA, [DECORATION_REF_HEAD] = GIT_COLOR_BOLD_CYAN, [DECORATION_GRAFTED] = GIT_COLOR_BOLD_BLUE, + [DECORATION_SYMBOL] = GIT_COLOR_NIL, }; static const char *color_decorate_slots[] = { @@ -50,6 +51,7 @@ static const char *color_decorate_slots[] = { [DECORATION_REF_STASH] = "stash", [DECORATION_REF_HEAD] = "HEAD", [DECORATION_GRAFTED] = "grafted", + [DECORATION_SYMBOL] = "symbol", }; static const char *decorate_get_color(int decorate_use_color, enum decoration_type ix) @@ -312,7 +314,7 @@ void format_decorations(struct strbuf *sb, { const struct name_decoration *decoration; const struct name_decoration *current_and_HEAD; - const char *color_commit, *color_reset; + const char *color_symbol, *color_reset; const char *prefix = " ("; const char *suffix = ")"; @@ -337,7 +339,10 @@ void format_decorations(struct strbuf *sb, tag = opts->tag; } - color_commit = diff_get_color(use_color, DIFF_COMMIT); + color_symbol = decorate_get_color(use_color, DECORATION_SYMBOL); + if (color_is_nil(color_symbol)) + color_symbol = diff_get_color(use_color, DIFF_COMMIT); + color_reset = decorate_get_color(use_color, DECORATION_NONE); current_and_HEAD = current_pointed_by_HEAD(decoration); @@ -352,7 +357,7 @@ void format_decorations(struct strbuf *sb, decorate_get_color(use_color, decoration->type); if (*prefix) { - strbuf_addstr(sb, color_commit); + strbuf_addstr(sb, color_symbol); strbuf_addstr(sb, prefix); strbuf_addstr(sb, color_reset); } @@ -369,7 +374,7 @@ void format_decorations(struct strbuf *sb, if (current_and_HEAD && decoration->type == DECORATION_REF_HEAD) { - strbuf_addstr(sb, color_commit); + strbuf_addstr(sb, color_symbol); strbuf_addstr(sb, pointer); strbuf_addstr(sb, color_reset); strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type)); @@ -382,7 +387,7 @@ void format_decorations(struct strbuf *sb, decoration = decoration->next; } if (*suffix) { - strbuf_addstr(sb, color_commit); + strbuf_addstr(sb, color_symbol); strbuf_addstr(sb, suffix); strbuf_addstr(sb, color_reset); } diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh index 21986a866d..f4173b6114 100755 --- a/t/t4207-log-decoration-colors.sh +++ b/t/t4207-log-decoration-colors.sh @@ -18,6 +18,7 @@ test_expect_success setup ' git config color.decorate.tag "reverse bold yellow" && git config color.decorate.stash magenta && git config color.decorate.grafted black && + git config color.decorate.symbol white && git config color.decorate.HEAD cyan && c_reset="" && @@ -29,6 +30,7 @@ test_expect_success setup ' c_stash="" && c_HEAD="" && c_grafted="" && + c_symbol="" && test_commit A && git clone . other && @@ -53,17 +55,17 @@ cmp_filtered_decorations () { # to this test since it does not contain any decoration, hence --first-parent test_expect_success 'commit decorations colored correctly' ' cat >expect <<-EOF && - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\ -${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \ -${c_reset}${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \ -${c_reset}${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B -${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ -${c_tag}tag: ${c_reset}${c_tag}A1${c_reset}${c_commit}, \ -${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1 - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ -${c_stash}refs/stash${c_reset}${c_commit})${c_reset} On main: Changes to A.t - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ -${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}${c_HEAD}HEAD${c_reset}\ +${c_symbol} -> ${c_reset}${c_branch}main${c_reset}${c_symbol}, ${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_symbol}, ${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_symbol})${c_reset} B +${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}A1${c_reset}${c_symbol}, ${c_reset}\ +${c_remoteBranch}other/main${c_reset}${c_symbol})${c_reset} A1 + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_stash}refs/stash${c_reset}${c_symbol})${c_reset} On main: Changes to A.t + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_symbol})${c_reset} A EOF git log --first-parent --no-abbrev --decorate --oneline --color=always --all >actual && @@ -78,14 +80,14 @@ test_expect_success 'test coloring with replace-objects' ' git replace HEAD~1 HEAD~2 && cat >expect <<-EOF && - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\ -${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \ -${c_reset}${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_commit})${c_reset} D - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ -${c_tag}tag: ${c_reset}${c_tag}C${c_reset}${c_commit}, \ -${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} B - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ -${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}${c_HEAD}HEAD${c_reset}\ +${c_symbol} -> ${c_reset}${c_branch}main${c_reset}${c_symbol}, ${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_symbol})${c_reset} D + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}C${c_reset}${c_symbol}, ${c_reset}\ +${c_grafted}replaced${c_reset}${c_symbol})${c_reset} B + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_symbol})${c_reset} A EOF git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual && @@ -104,15 +106,15 @@ test_expect_success 'test coloring with grafted commit' ' git replace --graft HEAD HEAD~2 && cat >expect <<-EOF && - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\ -${c_commit} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \ -${c_reset}${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_commit}, \ -${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} D - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ -${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \ -${c_reset}${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B - ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ -${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}${c_HEAD}HEAD${c_reset}\ +${c_symbol} -> ${c_reset}${c_branch}main${c_reset}${c_symbol}, ${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_symbol}, ${c_reset}\ +${c_grafted}replaced${c_reset}${c_symbol})${c_reset} D + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_symbol}, ${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_symbol})${c_reset} B + ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_symbol})${c_reset} A EOF git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual && From patchwork Mon Oct 23 22:11:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Koppe X-Patchwork-Id: 13433649 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B1DD241EB for ; Mon, 23 Oct 2023 22:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lFEASuLN" Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46AF2FF for ; Mon, 23 Oct 2023 15:12:00 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40838915cecso31560785e9.2 for ; Mon, 23 Oct 2023 15:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698099118; x=1698703918; 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=UhRKklJGxie/vlH3D+R+b+XR44576sUzPO/PvuzcSbY=; b=lFEASuLNk/Cm2aXfya/fVDVPMfQ1e3G8JXSAccvv40a3+1xEag6tBMhr/lG+k1p8fS OyReQVhL3gIdHyrVHzVzbtKlhHe3zvos+IkW7pRbplWgpgnNQtQMl5zkQqZHVGNGtg0i rJ/8kAtz14cZ95AMr7QzFdK+GFBJj+r6RekmGcP1M0XCmesMY0wnQKYlU5joT2lETkoo oJkGFGRzzc6NXpQV1+dtiFm0aBLb4qTT/X5HpExcEIkVK3PKcgXpQkLcxw9EYiZbr/pu LhxicqKuP3zoom3q1ixsil1q79ddiGyvAQays7nHGpcuvggZO0SiW/mHctvSB/L1SMsK U5tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698099118; x=1698703918; 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=UhRKklJGxie/vlH3D+R+b+XR44576sUzPO/PvuzcSbY=; b=mPi1iFY27i98wmesx4t1CQTYDT/ejGRWqt7RoKQSEh85LB401QFslV1khVmNpbGvQE 2MB3sHQGgp1fbrkefcG7g5lm4rKTkCadzSXJ9nnoRSn4I8N1gysf9Yie62Hpn2RB53fe CGT5Gwb4jKcbrmJ+Wsnh7GzIWu08l9gTNkPYe85Upm0xgvwgK0WjEXXC8rn+2vtIVS09 YXg7fogGwAhYLw8DXv939ZMIVZdA14SzW+qVSz6qUTCI4XG7FT3rqaTA1gf9Gza26ZdX dmmJQvcmzGmbHTD8w8z3hkVZ48e6F/80MFCC265STQm+r+AhfT9ykVirwzTlz5CAf86X RukA== X-Gm-Message-State: AOJu0YzM2RgI1Sb+WkjRsfK/hbJ9uvI8Eh7mrrOPwLyNLW6poqR4Bhqx fnln4GxyCqvni2QDBZlc6EXWYdOVm2JUQQ== X-Google-Smtp-Source: AGHT+IEhylOBywnuRDaSaNlpDaL67KNoJDdxpqPhE9/sRPUZTe5Em3i4PZXc51xwyGzKoUAEFwyQFg== X-Received: by 2002:a05:600c:35ca:b0:407:7ea1:e9a4 with SMTP id r10-20020a05600c35ca00b004077ea1e9a4mr7976158wmq.5.1698099118647; Mon, 23 Oct 2023 15:11:58 -0700 (PDT) Received: from localhost.localdomain (cpc105060-sgyl40-2-0-cust995.18-2.cable.virginm.net. [81.111.15.228]) by smtp.gmail.com with ESMTPSA id w11-20020a5d608b000000b0032008f99216sm8559953wrt.96.2023.10.23.15.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 15:11:58 -0700 (PDT) From: Andy Koppe To: git@vger.kernel.org Cc: gitster@pobox.com, stolee@gmail.com, Andy Koppe Subject: [PATCH v3 4/7] log: add color.decorate.ref config variable Date: Mon, 23 Oct 2023 23:11:40 +0100 Message-ID: <20231023221143.72489-5-andy.koppe@gmail.com> X-Mailer: git-send-email 2.42.GIT In-Reply-To: <20231023221143.72489-1-andy.koppe@gmail.com> References: <20231022214432.56325-1-andy.koppe@gmail.com> <20231023221143.72489-1-andy.koppe@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refs other than branches, remote-tracking branches, tags and the stash do not appear in log decorations by default, but they can be shown by using decoration filter options such as --clear-decorations or log.initialDecorationSet. However, they would appear without color. Add config variable color.decorate.ref for such refs, defaulting to bold magenta, which is the same as refs/stash. Document the new variable on the git-config page and amend t4207-log-decoration-colors.sh to test it. Signed-off-by: Andy Koppe --- Documentation/config/color.txt | 5 +++++ commit.h | 1 + log-tree.c | 4 +++- t/t4207-log-decoration-colors.sh | 9 +++++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/config/color.txt b/Documentation/config/color.txt index cc0a881125..005a2bdb03 100644 --- a/Documentation/config/color.txt +++ b/Documentation/config/color.txt @@ -90,11 +90,16 @@ color.decorate.:: lightweight and annotated tags `stash`;; the stash ref +`ref`;; + any other refs (not shown by default) `grafted`;; grafted and replaced commits `symbol`;; punctuation symbols surrounding the other elements -- ++ +(Variable `log.initialDecorationSet` or linkgit:git-log[1] option +`--clear-decorations` can be used to show all refs.) color.grep:: When set to `always`, always highlight matches. When `false` (or diff --git a/commit.h b/commit.h index cb13e4d5ba..f6b2125fc4 100644 --- a/commit.h +++ b/commit.h @@ -54,6 +54,7 @@ enum decoration_type { DECORATION_REF_REMOTE, DECORATION_REF_TAG, DECORATION_REF_STASH, + DECORATION_REF, DECORATION_REF_HEAD, DECORATION_GRAFTED, DECORATION_SYMBOL, diff --git a/log-tree.c b/log-tree.c index 890024f205..fb3d87b83d 100644 --- a/log-tree.c +++ b/log-tree.c @@ -39,6 +39,7 @@ static char decoration_colors[][COLOR_MAXLEN] = { [DECORATION_REF_REMOTE] = GIT_COLOR_BOLD_RED, [DECORATION_REF_TAG] = GIT_COLOR_BOLD_YELLOW, [DECORATION_REF_STASH] = GIT_COLOR_BOLD_MAGENTA, + [DECORATION_REF] = GIT_COLOR_BOLD_MAGENTA, [DECORATION_REF_HEAD] = GIT_COLOR_BOLD_CYAN, [DECORATION_GRAFTED] = GIT_COLOR_BOLD_BLUE, [DECORATION_SYMBOL] = GIT_COLOR_NIL, @@ -49,6 +50,7 @@ static const char *color_decorate_slots[] = { [DECORATION_REF_REMOTE] = "remoteBranch", [DECORATION_REF_TAG] = "tag", [DECORATION_REF_STASH] = "stash", + [DECORATION_REF] = "ref", [DECORATION_REF_HEAD] = "HEAD", [DECORATION_GRAFTED] = "grafted", [DECORATION_SYMBOL] = "symbol", @@ -151,7 +153,7 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid, int i; struct object *obj; enum object_type objtype; - enum decoration_type deco_type = DECORATION_NONE; + enum decoration_type deco_type = DECORATION_REF; struct decoration_filter *filter = (struct decoration_filter *)cb_data; const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref; diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh index f4173b6114..4b51e34f8b 100755 --- a/t/t4207-log-decoration-colors.sh +++ b/t/t4207-log-decoration-colors.sh @@ -17,6 +17,7 @@ test_expect_success setup ' git config color.decorate.remoteBranch red && git config color.decorate.tag "reverse bold yellow" && git config color.decorate.stash magenta && + git config color.decorate.ref blue && git config color.decorate.grafted black && git config color.decorate.symbol white && git config color.decorate.HEAD cyan && @@ -28,11 +29,13 @@ test_expect_success setup ' c_remoteBranch="" && c_tag="" && c_stash="" && + c_ref="" && c_HEAD="" && c_grafted="" && c_symbol="" && test_commit A && + git update-ref refs/foo A && git clone . other && ( cd other && @@ -65,10 +68,12 @@ ${c_remoteBranch}other/main${c_reset}${c_symbol})${c_reset} A1 ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ ${c_stash}refs/stash${c_reset}${c_symbol})${c_reset} On main: Changes to A.t ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ -${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_symbol})${c_reset} A +${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_symbol}, ${c_reset}\ +${c_ref}refs/foo${c_reset}${c_symbol})${c_reset} A EOF - git log --first-parent --no-abbrev --decorate --oneline --color=always --all >actual && + git log --first-parent --no-abbrev --decorate --clear-decorations \ + --oneline --color=always --all >actual && cmp_filtered_decorations ' From patchwork Mon Oct 23 22:11:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Koppe X-Patchwork-Id: 13433650 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDC4224200 for ; Mon, 23 Oct 2023 22:12:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aU/r1Vsl" Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C58399 for ; Mon, 23 Oct 2023 15:12:01 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c503da4fd6so56032601fa.1 for ; Mon, 23 Oct 2023 15:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698099119; x=1698703919; 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=9IgaVws3XFXy+Lt2OCphZWNOgHLzlOEKRWpYSFDctJw=; b=aU/r1Vslq6IqTy7uXWgsoLPpN0iG2w9JVfIEVF+Oe0I18ugZFBNeZOiS66u4/JJ/Vt OSvcz/f7T+6c0OEVAdBemMYOsTzTQKt4KSdMMtnPJabLk/iCVleocCcS3f/Mz7ehtmmC hrE1nA3IuL4N5EOZFe/l2Zc7zvjox4yOpoHRXUlESbhYFU9dE+wNsFPKgl2UDZ2sxBgy UVr8oCglAI118JtE4/Rlz1BHNGvqNj5XSU0UHxeUG9ImlM59PlMfmNAdwBmUq/LW1U0y vcaQzJyc+QmRop5ZxEGkR8usSEoDpvV5fliAKA7C54uYUKQyEQAfP5IGQX415mRuaOzu WajQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698099119; x=1698703919; 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=9IgaVws3XFXy+Lt2OCphZWNOgHLzlOEKRWpYSFDctJw=; b=e5sj/nvD9pbgYLHgcifapKOalommzvKm/3l6o5IxGJ2cUTf0FE90IqlDNiP/nSvFYB u53h6sOJ+pl5bbG8E1TKDZnQ6+jpsNeDY3oLXEdz+l5MdHfEy4MKiccMQ5JZH/hED0gV G1bRAO2UKeoAek5suSw71uQ/mQbxQynzvZNVWCHq21VLPGW40VeDKlttoJ+ggu4A/t1I 8oSCrfk43DcmQbRZA1LanyqZ7eCuQeyB8XnU5DrZoqaGdNpeFcIrJ0jV7Cc58+4WQumX OpGj8Jh/+B4hcUuSERQrQIjfqaxcQvuZDO0FaPICjy4VgKizp85+dS0nHFxQyPkEpv8S 87cQ== X-Gm-Message-State: AOJu0YwEKqEXsDPKxQllTaPRLfczo+YNjRbl+oJtK/mvpYWoAJXcT/2d Ljnpsu8jDEKwVST2XBSbp3IGBTr2MtHc3Q== X-Google-Smtp-Source: AGHT+IEP2s9UO19VhGI6neY/GBOt341KLuT9kSqiMt0VI+dVB2r28ojkLnhIYSb+VuzVcY1708U+Yg== X-Received: by 2002:a2e:b8cc:0:b0:2c5:1f57:1ef5 with SMTP id s12-20020a2eb8cc000000b002c51f571ef5mr8057751ljp.39.1698099119398; Mon, 23 Oct 2023 15:11:59 -0700 (PDT) Received: from localhost.localdomain (cpc105060-sgyl40-2-0-cust995.18-2.cable.virginm.net. [81.111.15.228]) by smtp.gmail.com with ESMTPSA id w11-20020a5d608b000000b0032008f99216sm8559953wrt.96.2023.10.23.15.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 15:11:59 -0700 (PDT) From: Andy Koppe To: git@vger.kernel.org Cc: gitster@pobox.com, stolee@gmail.com, Andy Koppe Subject: [PATCH v3 5/7] refs: add pseudorefs array and iteration functions Date: Mon, 23 Oct 2023 23:11:41 +0100 Message-ID: <20231023221143.72489-6-andy.koppe@gmail.com> X-Mailer: git-send-email 2.42.GIT In-Reply-To: <20231023221143.72489-1-andy.koppe@gmail.com> References: <20231022214432.56325-1-andy.koppe@gmail.com> <20231023221143.72489-1-andy.koppe@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Define const array 'pseudorefs' with the names of the pseudorefs that are documented in gitrevisions.1, and add functions for_each_pseudoref() and refs_for_each_pseudoref() for iterating over them. The functions process the pseudorefs in the same way as head_ref() and refs_head_ref() process HEAD, invoking an each_ref_fn callback on each pseudoref that exists. This is in preparation for adding pseudorefs to log decorations. Signed-off-by: Andy Koppe --- refs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ refs.h | 5 +++++ 2 files changed, 47 insertions(+) diff --git a/refs.c b/refs.c index fcae5dddc6..aa7e4c02c5 100644 --- a/refs.c +++ b/refs.c @@ -65,6 +65,21 @@ static unsigned char refname_disposition[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4, 4 }; +/* + * List of documented pseudorefs. This needs to be kept in sync with the list + * in Documentation/revisions.txt. + */ +static const char *const pseudorefs[] = { + "FETCH_HEAD", + "ORIG_HEAD", + "MERGE_HEAD", + "REBASE_HEAD", + "CHERRY_PICK_HEAD", + "REVERT_HEAD", + "BISECT_HEAD", + "AUTO_MERGE", +}; + struct ref_namespace_info ref_namespace[] = { [NAMESPACE_HEAD] = { .ref = "HEAD", @@ -1549,6 +1564,33 @@ int head_ref(each_ref_fn fn, void *cb_data) return refs_head_ref(get_main_ref_store(the_repository), fn, cb_data); } +int refs_for_each_pseudoref(struct ref_store *refs, + each_ref_fn fn, void *cb_data) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(pseudorefs); i++) { + struct object_id oid; + int flag; + + if (refs_resolve_ref_unsafe(refs, pseudorefs[i], + RESOLVE_REF_READING, &oid, &flag)) { + int ret = fn(pseudorefs[i], &oid, flag, cb_data); + + if (ret) + return ret; + } + } + + return 0; +} + +int for_each_pseudoref(each_ref_fn fn, void *cb_data) +{ + return refs_for_each_pseudoref(get_main_ref_store(the_repository), + fn, cb_data); +} + struct ref_iterator *refs_ref_iterator_begin( struct ref_store *refs, const char *prefix, diff --git a/refs.h b/refs.h index 23211a5ea1..7b55cced31 100644 --- a/refs.h +++ b/refs.h @@ -320,6 +320,8 @@ typedef int each_repo_ref_fn(struct repository *r, */ int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data); +int refs_for_each_pseudoref(struct ref_store *refs, + each_ref_fn fn, void *cb_data); int refs_for_each_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data); int refs_for_each_ref_in(struct ref_store *refs, const char *prefix, @@ -334,6 +336,9 @@ int refs_for_each_remote_ref(struct ref_store *refs, /* just iterates the head ref. */ int head_ref(each_ref_fn fn, void *cb_data); +/* iterates pseudorefs. */ +int for_each_pseudoref(each_ref_fn fn, void *cb_data); + /* iterates all refs. */ int for_each_ref(each_ref_fn fn, void *cb_data); From patchwork Mon Oct 23 22:11:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Koppe X-Patchwork-Id: 13433651 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A47D24204 for ; Mon, 23 Oct 2023 22:12:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JEBhl2HH" Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE019B for ; Mon, 23 Oct 2023 15:12:01 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4083ac51d8aso30382865e9.2 for ; Mon, 23 Oct 2023 15:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698099120; x=1698703920; 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=hJp/q/ZEUO49STF++3yf9/VRpHPtJGlQEiwgRkLc/M8=; b=JEBhl2HHFYm3dUBxqBbwmINgpT/ZcYvBEvxUBlt3oEBWP853Fir+MoLvs8bZcKPToQ Qych0DIahMCm4seuKnsVBuSWx4R6Pg8pQgpNw0TSx+1KT0lKZlKvf/pbonWMJQjMc0kW DDs6Hk/fpDX3SaoQWxLSy8rIKBpJwybfsAO8rrZxNbEVcMz7P6MDXlMCiANlxS+MhfDx n+xxqW+k+UldxCjg5WWOJh/y26qDFwKCSXxTT/BKse/bVPPLXCczDFetDbRVr5y/pEg9 blaOHb6X06fbnPoD7v0cwS/uW5lPr6r6L2a0fDdnVKK0Mve/fSXIH1usHbKsL+QZ98ig CRqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698099120; x=1698703920; 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=hJp/q/ZEUO49STF++3yf9/VRpHPtJGlQEiwgRkLc/M8=; b=adY9xV8tWt8oAEBmLEh4r5xKdi/eLBs768s1D8AJrCi8WiRl30BqVN/pddcf0stCLd YtsSfssidDBH7B8Q85Ew2/0PK5VSsBUnrVvUbJdI4eJX/jhVIa0DGNy7y2bOEcKWGsBg WH6n3s7bXeuk9BhVU2+QOZlIwEX+Kh7Vivk8lPfWDh6s5On7Z7tZyLnYqzukFf5DH9lO 9n63R74LBq32vmTdeviADJnjOkqXI5wHYtYsiH9ZxAABp3Sm0paGQqSIHSF0652f2HIS aQJ3FVSw4Ins9pC8RciIvv4RPety3Zc9c71hzZNUVApIIIISQw3nTUE20oNLnSfpr13a s1cQ== X-Gm-Message-State: AOJu0Yze1aA6QNOHjlJrnTr5gBUf1senEtpCTV5R0sDBh8NlEbGBsEsD +AFEgJ5DvKGyqWyDmfAT9KIbAdS5VyKyCg== X-Google-Smtp-Source: AGHT+IGaLJqaT4nvGOWUpsWvwoDQlKlvHwW6J/5Bkhva5HZc7r0fVt22F86aO3WaipBPk+3FlVvuEA== X-Received: by 2002:a05:600c:45cb:b0:401:daf2:2737 with SMTP id s11-20020a05600c45cb00b00401daf22737mr8337698wmo.30.1698099120078; Mon, 23 Oct 2023 15:12:00 -0700 (PDT) Received: from localhost.localdomain (cpc105060-sgyl40-2-0-cust995.18-2.cable.virginm.net. [81.111.15.228]) by smtp.gmail.com with ESMTPSA id w11-20020a5d608b000000b0032008f99216sm8559953wrt.96.2023.10.23.15.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 15:11:59 -0700 (PDT) From: Andy Koppe To: git@vger.kernel.org Cc: gitster@pobox.com, stolee@gmail.com, Andy Koppe Subject: [PATCH v3 6/7] refs: exempt pseudorefs from pattern prefixing Date: Mon, 23 Oct 2023 23:11:42 +0100 Message-ID: <20231023221143.72489-7-andy.koppe@gmail.com> X-Mailer: git-send-email 2.42.GIT In-Reply-To: <20231023221143.72489-1-andy.koppe@gmail.com> References: <20231022214432.56325-1-andy.koppe@gmail.com> <20231023221143.72489-1-andy.koppe@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In normalize_glob_ref(), don't prefix pseudorefs with "refs/", thereby implementing a NEEDSWORK from b877e617e6e5. This is in preparation for showing pseudorefs in log decorations, as they are not matched as intended in decoration filters otherwise. The function is only used in load_ref_decorations(). Signed-off-by: Andy Koppe --- refs.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/refs.c b/refs.c index aa7e4c02c5..fbd15a8cff 100644 --- a/refs.c +++ b/refs.c @@ -565,13 +565,16 @@ void normalize_glob_ref(struct string_list_item *item, const char *prefix, if (prefix) strbuf_addstr(&normalized_pattern, prefix); - else if (!starts_with(pattern, "refs/") && - strcmp(pattern, "HEAD")) - strbuf_addstr(&normalized_pattern, "refs/"); - /* - * NEEDSWORK: Special case other symrefs such as REBASE_HEAD, - * MERGE_HEAD, etc. - */ + else if (!starts_with(pattern, "refs/") && strcmp(pattern, "HEAD")) { + int i; + + for (i = 0; i < ARRAY_SIZE(pseudorefs); i++) + if (!strcmp(pattern, pseudorefs[i])) + break; + + if (i == ARRAY_SIZE(pseudorefs)) + strbuf_addstr(&normalized_pattern, "refs/"); + } strbuf_addstr(&normalized_pattern, pattern); strbuf_strip_suffix(&normalized_pattern, "/"); From patchwork Mon Oct 23 22:11:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Koppe X-Patchwork-Id: 13433653 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D53E249EA for ; Mon, 23 Oct 2023 22:12:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PijFtjdj" Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0D9C10C for ; Mon, 23 Oct 2023 15:12:02 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40790b0a224so29824055e9.0 for ; Mon, 23 Oct 2023 15:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698099121; x=1698703921; 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=sKIi5pMDq0+MztaeX4hU+yA7cYdp8u+R0r274ddNIHU=; b=PijFtjdj2KGyfX3dRIi7Bq/JM8zAuu+R9p3+joMAsKuP3w2hQw166HGWnCF8yZcoB+ /OvyKg5EfcX/+dbkNDIySbqOD/GVn3oCl3PlnLzJf5qBR7CJxcZS5zi+Zl0B25hVlFWD TkhMZaQ1FRqxDgDiQsnfnFiqHdEjyVTmH1/ck1eOg2XFY6rSWWKr/+f7wmt/rAQW6HLl 2QTo6/6EyO9prL2bNwWcGubJR92/39lAp4KBBaLPDbSKIJlDVALi+0uqGzlslfBNdoiP WWUA5k26lxY1QWr4u7yiq7evm3uwdFB53zzZR0/kX5x/VljyAt8nktZHO14PPQtzNyz6 F5/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698099121; x=1698703921; 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=sKIi5pMDq0+MztaeX4hU+yA7cYdp8u+R0r274ddNIHU=; b=dU9xtzJG6Vo8p/p/2QZYMVXC0srxD6LDAfm7KjAqEmM/+If0TnkcSNPG6LANTzcomr Kut358fl4Ot6s22nJRh4ule/A6rnn9cY4lKObRQR4fQ4ZbxgotuGVW+P3KUgaWTnWH+n BgbPg6TcJw14tyZIn8Go0bfrYFoVU+svdzRti0NtkfhDYIpB+cBITpQFAR3uMjVqux7O id2u01Tf1Ju86Ns5aQh9uacqJnZH82767Gfkv2OxmbKvsEjmu1QRbRaYc0w3hetN4gAg ZeTTqi0eWWmgGP1+hklSDbW2pkr+nBuS+9g5enk/qNmFZc5Dyti6hAxB87dpxJX/QWmx ZE1A== X-Gm-Message-State: AOJu0YwI5MDfjNLvYWwInysp9P7UudnA8ibIL6peGYEv8H/+4LBG4gkK YuN+YmheUsjZm9oT2S4u1iJAn1pp1cDXBw== X-Google-Smtp-Source: AGHT+IHMaJEdI5+AD4lCk5gYqY0GGLlMR8aSMIukBKtR1XSRw0fOz8aLsDvAvHOG59EeoiFM7IhieA== X-Received: by 2002:a05:600c:1546:b0:3fe:4cbc:c345 with SMTP id f6-20020a05600c154600b003fe4cbcc345mr7756003wmg.41.1698099120882; Mon, 23 Oct 2023 15:12:00 -0700 (PDT) Received: from localhost.localdomain (cpc105060-sgyl40-2-0-cust995.18-2.cable.virginm.net. [81.111.15.228]) by smtp.gmail.com with ESMTPSA id w11-20020a5d608b000000b0032008f99216sm8559953wrt.96.2023.10.23.15.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 15:12:00 -0700 (PDT) From: Andy Koppe To: git@vger.kernel.org Cc: gitster@pobox.com, stolee@gmail.com, Andy Koppe Subject: [PATCH v3 7/7] log: add color.decorate.pseudoref config variable Date: Mon, 23 Oct 2023 23:11:43 +0100 Message-ID: <20231023221143.72489-8-andy.koppe@gmail.com> X-Mailer: git-send-email 2.42.GIT In-Reply-To: <20231023221143.72489-1-andy.koppe@gmail.com> References: <20231022214432.56325-1-andy.koppe@gmail.com> <20231023221143.72489-1-andy.koppe@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add the ability to show pseudorefs such as ORIG_HEAD and MERGE_HEAD in log decorations. Add config variable color.decorate.pseudoref to determine their color, defaulting to bold cyan, which is the same as HEAD. They will not be shown unless the default decoration filtering is overridden with relevant log options such as --clear-decorations or log.initialDecorationSet. Signed-off-by: Andy Koppe --- Documentation/config/color.txt | 4 +++- commit.h | 1 + log-tree.c | 24 +++++++++++++++++++ ..._--decorate=full_--clear-decorations_--all | 4 ++-- ...f.log_--decorate_--clear-decorations_--all | 4 ++-- t/t4202-log.sh | 21 +++++++++------- t/t4207-log-decoration-colors.sh | 13 +++++++--- 7 files changed, 54 insertions(+), 17 deletions(-) diff --git a/Documentation/config/color.txt b/Documentation/config/color.txt index 005a2bdb03..7af7d65f76 100644 --- a/Documentation/config/color.txt +++ b/Documentation/config/color.txt @@ -92,6 +92,8 @@ color.decorate.:: the stash ref `ref`;; any other refs (not shown by default) +`pseudoref`;; + pseudorefs such as ORIG_HEAD or MERGE_HEAD (not shown by default) `grafted`;; grafted and replaced commits `symbol`;; @@ -99,7 +101,7 @@ color.decorate.:: -- + (Variable `log.initialDecorationSet` or linkgit:git-log[1] option -`--clear-decorations` can be used to show all refs.) +`--clear-decorations` can be used to show all refs and pseudorefs.) color.grep:: When set to `always`, always highlight matches. When `false` (or diff --git a/commit.h b/commit.h index f6b2125fc4..44dd3ce19b 100644 --- a/commit.h +++ b/commit.h @@ -56,6 +56,7 @@ enum decoration_type { DECORATION_REF_STASH, DECORATION_REF, DECORATION_REF_HEAD, + DECORATION_REF_PSEUDO, DECORATION_GRAFTED, DECORATION_SYMBOL, }; diff --git a/log-tree.c b/log-tree.c index fb3d87b83d..65ebb74d40 100644 --- a/log-tree.c +++ b/log-tree.c @@ -41,6 +41,7 @@ static char decoration_colors[][COLOR_MAXLEN] = { [DECORATION_REF_STASH] = GIT_COLOR_BOLD_MAGENTA, [DECORATION_REF] = GIT_COLOR_BOLD_MAGENTA, [DECORATION_REF_HEAD] = GIT_COLOR_BOLD_CYAN, + [DECORATION_REF_PSEUDO] = GIT_COLOR_BOLD_CYAN, [DECORATION_GRAFTED] = GIT_COLOR_BOLD_BLUE, [DECORATION_SYMBOL] = GIT_COLOR_NIL, }; @@ -52,6 +53,7 @@ static const char *color_decorate_slots[] = { [DECORATION_REF_STASH] = "stash", [DECORATION_REF] = "ref", [DECORATION_REF_HEAD] = "HEAD", + [DECORATION_REF_PSEUDO] = "pseudoref", [DECORATION_GRAFTED] = "grafted", [DECORATION_SYMBOL] = "symbol", }; @@ -208,6 +210,27 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid, return 0; } +static int add_pseudoref_decoration(const char *refname, + const struct object_id *oid, + int flags UNUSED, + void *cb_data) +{ + struct object *obj; + enum object_type objtype; + struct decoration_filter *filter = (struct decoration_filter *)cb_data; + + if (filter && !ref_filter_match(refname, filter)) + return 0; + + objtype = oid_object_info(the_repository, oid, NULL); + if (objtype < 0) + return 0; + + obj = lookup_object_by_type(the_repository, oid, objtype); + add_name_decoration(DECORATION_REF_PSEUDO, refname, obj); + return 0; +} + static int add_graft_decoration(const struct commit_graft *graft, void *cb_data UNUSED) { @@ -236,6 +259,7 @@ void load_ref_decorations(struct decoration_filter *filter, int flags) decoration_loaded = 1; decoration_flags = flags; for_each_ref(add_ref_decoration, filter); + for_each_pseudoref(add_pseudoref_decoration, filter); head_ref(add_ref_decoration, filter); for_each_commit_graft(add_graft_decoration, filter); } diff --git a/t/t4013/diff.log_--decorate=full_--clear-decorations_--all b/t/t4013/diff.log_--decorate=full_--clear-decorations_--all index 1c030a6554..7d16978e7f 100644 --- a/t/t4013/diff.log_--decorate=full_--clear-decorations_--all +++ b/t/t4013/diff.log_--decorate=full_--clear-decorations_--all @@ -33,13 +33,13 @@ Date: Mon Jun 26 00:04:00 2006 +0000 Merge branch 'side' -commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (refs/heads/side) +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (FETCH_HEAD, refs/heads/side) Author: A U Thor Date: Mon Jun 26 00:03:00 2006 +0000 Side -commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 (ORIG_HEAD) Author: A U Thor Date: Mon Jun 26 00:02:00 2006 +0000 diff --git a/t/t4013/diff.log_--decorate_--clear-decorations_--all b/t/t4013/diff.log_--decorate_--clear-decorations_--all index 88be82cce3..4f9be50ce0 100644 --- a/t/t4013/diff.log_--decorate_--clear-decorations_--all +++ b/t/t4013/diff.log_--decorate_--clear-decorations_--all @@ -33,13 +33,13 @@ Date: Mon Jun 26 00:04:00 2006 +0000 Merge branch 'side' -commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (side) +commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (FETCH_HEAD, side) Author: A U Thor Date: Mon Jun 26 00:03:00 2006 +0000 Side -commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 +commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 (ORIG_HEAD) Author: A U Thor Date: Mon Jun 26 00:02:00 2006 +0000 diff --git a/t/t4202-log.sh b/t/t4202-log.sh index af4a123cd2..b14da62e3e 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -927,7 +927,7 @@ test_expect_success 'multiple decorate-refs' ' test_expect_success 'decorate-refs-exclude with glob' ' cat >expect.decorate <<-\EOF && Merge-tag-reach (HEAD -> main) - Merge-tags-octopus-a-and-octopus-b + Merge-tags-octopus-a-and-octopus-b (ORIG_HEAD) seventh (tag: seventh) octopus-b (tag: octopus-b) octopus-a (tag: octopus-a) @@ -944,7 +944,7 @@ test_expect_success 'decorate-refs-exclude with glob' ' test_expect_success 'decorate-refs-exclude without globs' ' cat >expect.decorate <<-\EOF && Merge-tag-reach (HEAD -> main) - Merge-tags-octopus-a-and-octopus-b + Merge-tags-octopus-a-and-octopus-b (ORIG_HEAD) seventh (tag: seventh) octopus-b (tag: octopus-b, octopus-b) octopus-a (tag: octopus-a, octopus-a) @@ -961,7 +961,7 @@ test_expect_success 'decorate-refs-exclude without globs' ' test_expect_success 'multiple decorate-refs-exclude' ' cat >expect.decorate <<-\EOF && Merge-tag-reach (HEAD -> main) - Merge-tags-octopus-a-and-octopus-b + Merge-tags-octopus-a-and-octopus-b (ORIG_HEAD) seventh (tag: seventh) octopus-b (tag: octopus-b) octopus-a (tag: octopus-a) @@ -1022,10 +1022,12 @@ test_expect_success 'decorate-refs-exclude and simplify-by-decoration' ' EOF git log -n6 --decorate=short --pretty="tformat:%f%d" \ --decorate-refs-exclude="*octopus*" \ + --decorate-refs-exclude="ORIG_HEAD" \ --simplify-by-decoration >actual && test_cmp expect.decorate actual && - git -c log.excludeDecoration="*octopus*" log \ - -n6 --decorate=short --pretty="tformat:%f%d" \ + git -c log.excludeDecoration="*octopus*" \ + -c log.excludeDecoration="ORIG_HEAD" \ + log -n6 --decorate=short --pretty="tformat:%f%d" \ --simplify-by-decoration >actual && test_cmp expect.decorate actual ' @@ -1067,9 +1069,10 @@ test_expect_success 'decorate-refs and simplify-by-decoration without output' ' test_cmp expect actual ' -test_expect_success 'decorate-refs-exclude HEAD' ' +test_expect_success 'decorate-refs-exclude HEAD ORIG_HEAD' ' git log --decorate=full --oneline \ - --decorate-refs-exclude="HEAD" >actual && + --decorate-refs-exclude="HEAD" \ + --decorate-refs-exclude="ORIG_HEAD" >actual && ! grep HEAD actual ' @@ -1107,7 +1110,7 @@ test_expect_success '--clear-decorations overrides defaults' ' cat >expect.all <<-\EOF && Merge-tag-reach (HEAD -> refs/heads/main) - Merge-tags-octopus-a-and-octopus-b + Merge-tags-octopus-a-and-octopus-b (ORIG_HEAD) seventh (tag: refs/tags/seventh) octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b) octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a) @@ -1139,7 +1142,7 @@ test_expect_success '--clear-decorations clears previous exclusions' ' cat >expect.all <<-\EOF && Merge-tag-reach (HEAD -> refs/heads/main) reach (tag: refs/tags/reach, refs/heads/reach) - Merge-tags-octopus-a-and-octopus-b + Merge-tags-octopus-a-and-octopus-b (ORIG_HEAD) octopus-b (tag: refs/tags/octopus-b, refs/heads/octopus-b) octopus-a (tag: refs/tags/octopus-a, refs/heads/octopus-a) seventh (tag: refs/tags/seventh) diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh index 4b51e34f8b..0b32e0bb8e 100755 --- a/t/t4207-log-decoration-colors.sh +++ b/t/t4207-log-decoration-colors.sh @@ -18,6 +18,7 @@ test_expect_success setup ' git config color.decorate.tag "reverse bold yellow" && git config color.decorate.stash magenta && git config color.decorate.ref blue && + git config color.decorate.pseudoref "bold cyan" && git config color.decorate.grafted black && git config color.decorate.symbol white && git config color.decorate.HEAD cyan && @@ -30,6 +31,7 @@ test_expect_success setup ' c_tag="" && c_stash="" && c_ref="" && + c_pseudoref="" && c_HEAD="" && c_grafted="" && c_symbol="" && @@ -46,7 +48,10 @@ test_expect_success setup ' test_commit B && git tag v1.0 && echo >>A.t && - git stash save Changes to A.t + git stash save Changes to A.t && + git reset other/main && + git reset ORIG_HEAD && + git revert --no-commit @~ ' cmp_filtered_decorations () { @@ -63,17 +68,19 @@ ${c_symbol} -> ${c_reset}${c_branch}main${c_reset}${c_symbol}, ${c_reset}\ ${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_symbol}, ${c_reset}\ ${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_symbol})${c_reset} B ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_pseudoref}ORIG_HEAD${c_reset}${c_symbol}, ${c_reset}\ ${c_tag}tag: ${c_reset}${c_tag}A1${c_reset}${c_symbol}, ${c_reset}\ ${c_remoteBranch}other/main${c_reset}${c_symbol})${c_reset} A1 ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ ${c_stash}refs/stash${c_reset}${c_symbol})${c_reset} On main: Changes to A.t ${c_commit}COMMIT_ID${c_reset}${c_symbol} (${c_reset}\ +${c_pseudoref}REVERT_HEAD${c_reset}${c_symbol}, ${c_reset}\ ${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_symbol}, ${c_reset}\ ${c_ref}refs/foo${c_reset}${c_symbol})${c_reset} A EOF - git log --first-parent --no-abbrev --decorate --clear-decorations \ - --oneline --color=always --all >actual && + git log --first-parent --no-abbrev --decorate --color=always \ + --decorate-refs-exclude=FETCH_HEAD --oneline --all >actual && cmp_filtered_decorations '