From: Junio C Hamano Date: Fri, 26 Jun 2015 21:42:29 GMT Subject: Re: [PATCH v3 2/7] cherry-pick: treat CHERRY_PICK_HEAD and REVERT_HEAD as refs Message-ID: In-Reply-To: <1435278548-3790-2-git-send-email-dturner@twopensource.com> David Turner 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.