git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] sequencer: write useful reflog message for fast-forward

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jun 19, 2013, 07:37 UTC
Message-ID
<1371627429-24819-1-git-send-email-artagnon@gmail.com>
The following command
  $ git cherry-pick --ff b8bb3f
writes the following uninformative message to the reflog
  cherry-pick
Improve it to
  cherry-pick: fast-forward

Avoid hard-coding "cherry-pick" in fast_forward_to(), so the sequencer is generic enough to support future actions.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 Changes since v1:
 - fast_forward_to() now takes opts to determine action_name()
 - strbuf_release() to free memory
 sequencer.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index ab6f8a7..423c1f5 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -270,15 +270,20 @@ static int error_dirty_index(struct replay_opts *opts)
 }
 
 static int fast_forward_to(const unsigned char *to, const unsigned char *from,
-			   int unborn)
+			int unborn, struct replay_opts *opts)
 {
 	struct ref_lock *ref_lock;
+	struct strbuf sb = STRBUF_INIT;
+	int ret;
 
 	read_cache();
 	if (checkout_fast_forward(from, to, 1))
 		exit(1); /* the callee should have complained already */
 	ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from, 0);
-	return write_ref_sha1(ref_lock, to, "cherry-pick");
+	strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
+	ret = write_ref_sha1(ref_lock, to, sb.buf);
+	strbuf_release(&sb);
+	return ret;
 }
 
 static int do_recursive_merge(struct commit *base, struct commit *next,
@@ -523,7 +528,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
 	if (opts->allow_ff &&
 	    ((parent && !hashcmp(parent->object.sha1, head)) ||
 	     (!parent && unborn)))
-	     return fast_forward_to(commit->object.sha1, head, unborn);
+		return fast_forward_to(commit->object.sha1, head, unborn, opts);
 
 	if (parent && parse_commit(parent) < 0)
 		/* TRANSLATORS: The first %s will be "revert" or
-- 
1.8.3.1.449.g41b32a4.dirty
Message 1 of 1 in “sequencer: write useful reflog message for fast-forward”
  1. sequencer: write useful reflog message for fast-forwardRamkumar Ramachandra, Jun 19, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.