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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 26, 2015, 21:42 UTC
Message-ID
<xmqqy4j6rvsq.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1435278548-3790-2-git-send-email-dturner@twopensource.com>
David Turner <dturner@twopensource.com> writes:
Show 11 quoted lines
> 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"?
Show 11 quoted lines
> @@ -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.
Previous: David TurnerNext: David Turner
Message 3 of 12 in “refs.c: add err arguments to reflog functions”
  1. 1/7 refs.c: add err arguments to reflog functionsDavid Turner, Jun 26, 2015
  2. 2/7 cherry-pick: treat CHERRY_PICK_HEAD and REVERT_HEAD as refsDavid Turner, Jun 26, 2015
  3. Junio C HamanoJun 26, 2015
  4. 3/7 bisect: treat BISECT_HEAD as a refDavid Turner, Jun 26, 2015
  5. Junio C HamanoJun 26, 2015
  6. 4/7 refs: Break out check for reflog autocreationDavid Turner, Jun 26, 2015
  7. Junio C HamanoJun 26, 2015
  8. 5/7 refs: add safe_create_reflog functionDavid Turner, Jun 26, 2015
  9. Junio C HamanoJun 26, 2015
  10. 6/7 git-reflog: add create and exists functionsDavid Turner, Jun 26, 2015
  11. 7/7 git-stash: use git-reflog instead of creating filesDavid Turner, Jun 26, 2015
  12. Junio C HamanoJun 26, 2015

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.