Skip to content

Commit

Permalink
sequencer: replace write_cherry_pick_head with update_ref
Browse files Browse the repository at this point in the history
Now update_ref (via write_pseudoref) does almost exactly what
write_cherry_pick_head did, so we can remove write_cherry_pick_head
and just use update_ref.

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David Turner authored and Junio C Hamano committed Jul 31, 2015
1 parent f3a9771 commit d96a539
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,6 @@ static void free_message(struct commit *commit, struct commit_message *msg)
unuse_commit_buffer(commit, msg->message);
}

static void write_cherry_pick_head(struct commit *commit, const char *pseudoref)
{
const char *filename;
int fd;
struct strbuf buf = STRBUF_INIT;

strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1));

filename = git_path("%s", pseudoref);
fd = open(filename, O_WRONLY | O_CREAT, 0666);
if (fd < 0)
die_errno(_("Could not open '%s' for writing"), filename);
if (write_in_full(fd, buf.buf, buf.len) != buf.len || close(fd))
die_errno(_("Could not write to '%s'"), filename);
strbuf_release(&buf);
}

static void print_advice(int show_hint, struct replay_opts *opts)
{
char *msg = getenv("GIT_CHERRY_PICK_HELP");
Expand Down Expand Up @@ -607,9 +590,11 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
* write it at all.
*/
if (opts->action == REPLAY_PICK && !opts->no_commit && (res == 0 || res == 1))
write_cherry_pick_head(commit, "CHERRY_PICK_HEAD");
update_ref(NULL, "CHERRY_PICK_HEAD", commit->object.sha1, NULL,
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
if (opts->action == REPLAY_REVERT && ((opts->no_commit && res == 0) || res == 1))
write_cherry_pick_head(commit, "REVERT_HEAD");
update_ref(NULL, "REVERT_HEAD", commit->object.sha1, NULL,
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);

if (res) {
error(opts->action == REPLAY_REVERT
Expand Down

0 comments on commit d96a539

Please sign in to comment.