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

3 messages from 2013-06-18 to 2013-06-18. Participants: Ramkumar Ramachandra, Junio C Hamano.
Thread: https://gitlist.dev/t/34204

## Ramkumar Ramachandra, 2013-06-18 18:35

Subject: [PATCH] sequencer: write useful reflog message for fast-forward
Message-ID: <1371580518-32455-1-git-send-email-artagnon@gmail.com>
URL: https://gitlist.dev/e/1371580518-32455-1-git-send-email-artagnon%40gmail.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 to b8bb3f

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 sequencer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sequencer.c b/sequencer.c
index ab6f8a7..ae63ff3 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -273,12 +273,14 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
 			   int unborn)
 {
 	struct ref_lock *ref_lock;
+	struct strbuf sb = STRBUF_INIT;
 
 	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, "cherry-pick: fast-forward to %s", find_unique_abbrev(to, DEFAULT_ABBREV));
+	return write_ref_sha1(ref_lock, to, sb.buf);
 }
 
 static int do_recursive_merge(struct commit *base, struct commit *next,
-- 
1.8.3.1.457.gd1408e5

```

## Junio C Hamano, 2013-06-18 18:53

Subject: Re: [PATCH] sequencer: write useful reflog message for fast-forward
Message-ID: <7vzjun45dr.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzjun45dr.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1371580518-32455-1-git-send-email-artagnon@gmail.com>

```
Ramkumar Ramachandra <artagnon@gmail.com> writes:

> 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 to b8bb3f
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---

Perhaps, but a few questions in general (i.e. not limited to the
difference the patch brings in, but because you are touching the
codepath anyway).

 - Is this limited to cherry-pick?  do_pick_commit() which is the
   caller of fast_forward_to() is called not just for cherry-pick
   but also for revert, and I do not see anything that makes sure
   that it is called only when (opts->action == REPLAY_CHERRY_PICK).

 - Do we want to abbreviate?  For that matter, why even say "to
   $commit", which can be seen in the "from to" part of the reflog
   record anyway?

In other words:

	strbuf_addf(&sb, "%s: fast-forward", action_name(opts))

might be sufficient, and when sequencer learns to handle more than
cherry-pick and revert, we won't have to remember that we need to
change this part.

>  sequencer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/sequencer.c b/sequencer.c
> index ab6f8a7..ae63ff3 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -273,12 +273,14 @@ static int fast_forward_to(const unsigned char *to, const unsigned char *from,
>  			   int unborn)
>  {
>  	struct ref_lock *ref_lock;
> +	struct strbuf sb = STRBUF_INIT;
>  
>  	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, "cherry-pick: fast-forward to %s", find_unique_abbrev(to, DEFAULT_ABBREV));
> +	return write_ref_sha1(ref_lock, to, sb.buf);
>  }
>  
>  static int do_recursive_merge(struct commit *base, struct commit *next,

```

## Ramkumar Ramachandra, 2013-06-18 19:02

Subject: Re: [PATCH] sequencer: write useful reflog message for fast-forward
Message-ID: <CALkWK0kU01zfvyietjuTFk01UteT+uuKXfjrfSirn=i8FHCxCw@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0kU01zfvyietjuTFk01UteT%2BuuKXfjrfSirn%3Di8FHCxCw%40mail.gmail.com
In-Reply-To: <7vzjun45dr.fsf@alter.siamese.dyndns.org>

```
Junio C Hamano wrote:
>         strbuf_addf(&sb, "%s: fast-forward", action_name(opts))

Agreed.  Can you just fix it up locally?

Thanks.

```
