From: "Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Philippe Blain <levraiphilippeblain@gmail.com>,
Philippe Blain <levraiphilippeblain@gmail.com>
Subject: [PATCH 2/3] wt-status: also abbreviate 'merge' and 'fixup -C' lines during rebase
Date: Fri, 28 Mar 2025 17:03:20 +0000 [thread overview]
Message-ID: <e297b71ba123b642c2e724d7dda475fa52dfdeaa.1743181401.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1897.git.1743181401.gitgitgadget@gmail.com>
From: Philippe Blain <levraiphilippeblain@gmail.com>
When "git status" is invoked during a rebase, we print the last commands
done and the next commands to do, and abbreviate commit hashes found in
those lines. However, we only abbreviate hashes in 'pick', 'squash' and
plain 'fixup' lines, not those in 'merge -C' and 'fixup -C' lines, as
the parsing done in wt-status.c::abbrev_oid_in_line is not prepared for
such lines.
Improve the parsing done by this function by special casing 'fixup' and
'merge' such that the hash to abbreviate is the string found in the
third field of 'split', instead of the second one for other commands.
Introduce a 'hash' strbuf pointer to point to the correct field in all
cases.
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
wt-status.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 1da5732f57b..d11d9f9f142 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1342,9 +1342,11 @@ static int split_commit_in_progress(struct wt_status *s)
/*
* Turn
- * "pick d6a2f0303e897ec257dd0e0a39a5ccb709bc2047 some message"
+ * "pick d6a2f0303e897ec257dd0e0a39a5ccb709bc2047 some message" and
+ * "merge -C d6a2f0303e897ec257dd0e0a39a5ccb709bc2047 some-branch"
* into
- * "pick d6a2f03 some message"
+ * "pick d6a2f03 some message" and
+ * "merge -C d6a2f03 some-branch"
*
* The function assumes that the line does not contain useless spaces
* before or after the command.
@@ -1360,20 +1362,31 @@ static void abbrev_oid_in_line(struct strbuf *line)
starts_with(line->buf, "l "))
return;
- split = strbuf_split_max(line, ' ', 3);
+ split = strbuf_split_max(line, ' ', 4);
if (split[0] && split[1]) {
struct object_id oid;
-
+ struct strbuf *hash;
+
+ if ((!strcmp(split[0]->buf, "merge ") ||
+ !strcmp(split[0]->buf, "m " ) ||
+ !strcmp(split[0]->buf, "fixup ") ||
+ !strcmp(split[0]->buf, "f " )) &&
+ (!strcmp(split[1]->buf, "-C ") ||
+ !strcmp(split[1]->buf, "-c "))) {
+ hash = split[2];
+ } else {
+ hash = split[1];
+ }
/*
* strbuf_split_max left a space. Trim it and re-add
* it after abbreviation.
*/
- strbuf_trim(split[1]);
- if (!repo_get_oid(the_repository, split[1]->buf, &oid)) {
- strbuf_reset(split[1]);
- strbuf_add_unique_abbrev(split[1], &oid,
+ strbuf_trim(hash);
+ if (!repo_get_oid(the_repository, hash->buf, &oid)) {
+ strbuf_reset(hash);
+ strbuf_add_unique_abbrev(hash, &oid,
DEFAULT_ABBREV);
- strbuf_addch(split[1], ' ');
+ strbuf_addch(hash, ' ');
strbuf_reset(line);
for (i = 0; split[i]; i++)
strbuf_addbuf(line, split[i]);
--
gitgitgadget
next prev parent reply other threads:[~2025-03-28 17:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 17:03 [PATCH 0/3] rebase -r: a bugfix and two status-related improvements Philippe Blain via GitGitGadget
2025-03-28 17:03 ` [PATCH 1/3] rebase -r: do create merge commit after empty resolution Philippe Blain via GitGitGadget
2025-03-28 17:14 ` Eric Sunshine
2025-03-28 17:23 ` Eric Sunshine
2025-04-01 16:17 ` Johannes Schindelin
2025-03-31 15:37 ` Phillip Wood
2025-03-28 17:03 ` Philippe Blain via GitGitGadget [this message]
2025-03-31 15:37 ` [PATCH 2/3] wt-status: also abbreviate 'merge' and 'fixup -C' lines during rebase Phillip Wood
2025-03-28 17:03 ` [PATCH 3/3] wt-status: suggest 'git rebase --continue' to conclude 'merge' instruction Philippe Blain via GitGitGadget
2025-03-31 15:38 ` Phillip Wood
2025-04-01 16:22 ` Johannes Schindelin
2025-04-02 13:09 ` phillip.wood123
2025-04-03 12:17 ` Johannes Schindelin
2025-04-03 15:08 ` phillip.wood123
2025-04-04 11:41 ` Johannes Schindelin
2025-04-04 14:13 ` Phillip Wood
2025-03-31 15:38 ` [PATCH 0/3] rebase -r: a bugfix and two status-related improvements Phillip Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e297b71ba123b642c2e724d7dda475fa52dfdeaa.1743181401.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=levraiphilippeblain@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).