From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794052549; b=GSrUQlx+EyAmB1XKZaONLMIxzjSkMW5VI+tSdBN3W0fE4cZXWyHPdNYa6YwFNgq8NE8P RE+iZbv7rommc77Hw8q/DV9UMmjjvTzuNx8omLBfw0RnJS5UZ7DaPvsz2k3zNLpHKjY/P NIFUHvu1pSUu9mCNbh2wTdiyTlJZYNcuS27FdlcOmm88/RZ/lvfdz16hJH4dBXqLI28jf T7B+PET/We53WyhCX7JdXP64JOh4x/QvuIDWL0c3euMm4QSyvbagaN9Tew9jSCKd4MHp4 ypxsdUYSGjY9JZsksB4mgKVexQHo5EAzWezBGekRvA8G9Qr6PHu1c8PEChh5WGlxzWA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794052549; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-Id:In-Reply-To: References:From:Date:Subject:Fcc:Content-Type: Content-Transfer-Encoding:MIME-Version:To:Cc; bh=3tZ/uEfjWLwHbNf4/fK9A+bq3Lm7qF8ppHvbBVUDsXw=; b=J96Ta+mb3MAqx4+X+qYWdNqfEVvNxtVS6vhJaAYSfRDCBtf3ORD/9hebw+sMSCUU6G3v OzekkHdzsAq0oNA9AUz0AQeuwr4YdNTabbesNJ96z1Ai7PGzq+YXt1XaptvdLkqz0hJgF 9p+9mK0I+CIg4PaZZc3buNle1+Y+24J1e8WreTci+6jR6OosGL5+fHsOkHUQGS2SyCCA5 HG6DH4QiDicoFBG/QOWbY2btb8gyOTWrLi1mHV+KuF0fHH2NFLkO5+ie7idL7JEwmmG7K amxj9/hZyaRiYa8zmZRHHe8FlY4ZlTkToAYgFZBpqWJvrQiecSVqCq8vRijgINTKJjw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eYqLx61O; arc=none smtp.remote-ip=209.85.210.47 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85A6A606A32D for ; Sat, 7 Nov 2026 11:55:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 85A6A606A32D 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.a=rsa-sha256 header.s=20260707 header.b=eYqLx61O Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-833e671ee9fso1635023a34.0 for ; Sat, 07 Nov 2026 03:55:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794052547; x=1794657347; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:references:in-reply-to:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=3tZ/uEfjWLwHbNf4/fK9A+bq3Lm7qF8ppHvbBVUDsXw=; b=eYqLx61OklJFVNqroC76v81/E38lNsA2fU+D69LfjeRKeuuZoURfGUb5sGRrIbBkkM 3tdrMq9NO8nIk5c92hC9uVorJh2oDHMAVy3U+JiI6ttjU1K+kMcMAat0glZ4sXRrlrC1 6xDcHc8xRfRcke5NorXNIhxRPfUVgLYuR4TSA0eFd4uXQgp7vXhbzpjdqyYDhFsBe9DW rvkCgwCLLTc04aUH6qOCYe0XdE57oOzEJ2i7W0gTBQGdL6q7fa9O5gOBPvlMo4zbBirW SvW5yR/fqWYPK52LtgFyDSShu9lYLHQDpe0PyjyeFvcBXr25JENYZL/X9qZkt6/EBlJv amIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794052547; x=1794657347; h=cc:to:mime-version:content-transfer-encoding:content-type:fcc :subject:date:from:references:in-reply-to:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3tZ/uEfjWLwHbNf4/fK9A+bq3Lm7qF8ppHvbBVUDsXw=; b=A7EGO8ac5XmItL79tHBCjXs5nM3zQpOtov2fB4LolUze8qAt6feImIKAod/jBvLknB 34ErvqT7B4eSaErsMZkP0wcPe4DmwDDEzx1WAGdUxmMGf3Q6+XkylTmmnA9qL3mFBmM9 9HLzab7uyfdCNimySwSUAay0iYlYPh+xMiWBKDyntAVi3NrNulMOeg4YGE7/gJopTVL2 4OH+u2QtMOpTrklIUEwpyb9yrfOUxiJaoqizOS+GkBKQKCAse/rT7a+8bJKo+G1pnS5V twkC8OdGCNMXN93H4h2r7Xqc2qVHrh6at+Wdtcmae9d8TZCwid40CeFRdouX1E9CrKY0 UBxw== X-Gm-Message-State: APuU4Z+q3mVyV8Vnju4FTUptr6c/HG2lTXoox/H3MB+KtnpfO+Y04wwF l+BVe7mX9X2q102c3GuuFsAhk2PXXnLFr7CsIx5btDBUxGEc1FQu0B3utcmf1Q== X-Gm-Gg: AYBFou1QilyQhb0O+IJKzLPpWZAt7PvtKx2rMH4qz/TxkHEOM4V1rE/HmZriOh6i2mx FzFqDxHu9k2y8B/CVuf9POUwUwBr95/3+LMdp9sxkiJSlKiCkQK8Qsu6eEoDr4P6gaFAuLnLOfY VZC0oxnwFYIhXl0BdB9SeVvMhx8E1qIph9my2ppjC0RX/uuyt1ICa6x+uf1SrMHGukF9Uo20N57 hrHeYEopXlevD/l0UTvqLm5Jjct4wj7JocOS74FC46EHQp/iJ9unnPiMPt4YFDN16kKl8gjAYmS D7fJ8aWhUXZ6c4J4W4Oi7NpAQwb1vr3v04Zm9D2OMR2ET+st/fLJ4RjobWntAGpodAuGoU6kapF 1Xm5BJmhWgUzbiENzABx5DcrVjQGTAHUb1/mt+GsQE70CaQwmLLId23OqJTUfb/4juYzMgAnrpL u3B8DJ7BSMtjtQ9e5NiFcCJ6jJf8VdshrWvj5/5I+RgHt5zjgZMUi3qEjBlmwgqwn4aulkbU0jG o3YE6mhd1zwoAMJ8X/OUb4z1j+kgXTkGObqyyE4EZaoz1aA6ENIaZZ5kgVjh6y72wJHKaYSexyY dwnoiTxP5rvNNLZOyhfzvWqlfWCke6JI X-Received: by 2002:a05:6808:c3c2:b0:4ea:686e:fe86 with SMTP id 5614622812f47-567e14912f9mr3784243b6e.63.1794052547273; Sat, 07 Nov 2026 03:55:47 -0800 (PST) Received: from [127.0.0.1] ([13.86.110.186]) by smtp.gmail.com with ESMTPSA id 5614622812f47-567e7ddc155sm3719480b6e.7.2026.11.07.03.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Nov 2026 03:55:45 -0800 (PST) Message-Id: <34bb9309088b2ff9252d22456b504c3e20b63bef.1794052536.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Harald Nordgren via GitGitGadget" Date: Sat, 07 Nov 2026 11:55:36 +0000 Subject: [PATCH v5 2/2] pretty: add %gb to name the branch of each reflog entry Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 To: git@vger.kernel.org Cc: Kristoffer Haugsbakk , "D. Ben Knoble" , Phillip Wood , Harald Nordgren , Harald Nordgren From: Harald Nordgren The reflog of HEAD records the work done on every branch, so the output of "git reflog" mixes them and does not say which entry was made on which branch. Working that out by hand means looking back for the branch switch before each entry, and a rebase can move HEAD to another branch without writing one, as "git rebase " does. Add a "%gb" placeholder that names the branch HEAD was on when each entry was recorded: $ git log -g --format='%h %gd: (%gb) %gs' 9c8d7e6 HEAD@{0}: (topic) rebase (finish): returning to refs/heads/topic 9c8d7e6 HEAD@{1}: (topic) rebase (pick): add tests 1a2b3c4 HEAD@{2}: (topic) rebase (start): checkout main 1a2b3c4 HEAD@{3}: (main) commit: fix typo 5d6e7f8 HEAD@{4}: (main) checkout: moving from topic to main The branch is read from the entries created by branch switches, branch renames and rebases. The entries of a rebase are labeled with the branch being rebased. When HEAD was detached, the entry shows "detached at " with the commit HEAD was detached at, or for a rebase of a detached HEAD the commit the rebase ended on. These entries only record what was typed, so when no newer entry says otherwise, a name counts as a branch if a branch of that name exists. When nothing older in the reflog says which branch a rebase started on, the rebase is taken to have started on the branch it rebased. For the reflog of any other ref, "%gb" is the name of that ref. Signed-off-by: Harald Nordgren --- Documentation/pretty-formats.adoc | 3 + pretty.c | 4 + reflog-walk.c | 217 +++++++++++++++++++++++++++- reflog-walk.h | 2 + t/t1414-reflog-walk.sh | 229 ++++++++++++++++++++++++++++++ 5 files changed, 449 insertions(+), 6 deletions(-) diff --git a/Documentation/pretty-formats.adoc b/Documentation/pretty-formats.adoc index 2ae0eb11a9..a8d00397c4 100644 --- a/Documentation/pretty-formats.adoc +++ b/Documentation/pretty-formats.adoc @@ -334,6 +334,9 @@ endif::git-rev-list[] +%gE+:: reflog identity email (respecting .mailmap, see linkgit:git-shortlog[1] or linkgit:git-blame[1]) +%gs+:: reflog subject ++%gb+:: reflog branch, the branch `HEAD` was on when the entry was + recorded, e.g., `topic` or `detached at 1a2b3c4`. For the reflog + of any other ref, this is the shortened refname. ++%(trailers++`[: