Subject: Re: [PATCH v3 2/7] cherry-pick: treat CHERRY_PICK_HEAD and REVERT_HEAD as refs

From: Junio C Hamano <[email-masked]>
Date: Fri, 26 Jun 2015 14:42:29 -0700

David Turner <[email-masked]> writes:

> Instead of directly writing to and reading from files in
> $GIT_DIR, use ref API to interact with CHERRY_PICK_HEAD
> and REVERT_HEAD.
> ...
> diff --git a/sequencer.c b/sequencer.c
> index f8421a8..de904aa 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -160,19 +160,20 @@ static void free_message(struct commit *commit, struct commit_message *msg)
>  
>  static void write_cherry_pick_head(struct commit *commit, const char *pseudoref)

I guess this is no longer "pseudoref"?

> @@ -878,8 +879,8 @@ static int rollback_single_pick(void)
>  {
>  	unsigned char head_sha1[20];
>  
> -	if (!file_exists(git_path("CHERRY_PICK_HEAD")) &&
> -	    !file_exists(git_path("REVERT_HEAD")))
> +	if (read_ref("CHERRY_PICK_HEAD", head_sha1) &&
> +	    read_ref("REVERT_HEAD", head_sha1))
>  		return error(_("no cherry-pick or revert in progress"));
>  	if (read_ref_full("HEAD", 0, head_sha1, NULL))
>  		return error(_("cannot resolve HEAD"));

I would have expected that you would use ref_exists() here; you are
not reading "HEAD" yet writing it into head_sha1[], and not using
the value of the ref.

Other than that, looked very sensible.  Thanks.