Skip to content

Commit d96a539

Browse files
dturner-twgitster
authored andcommitted
sequencer: replace write_cherry_pick_head with update_ref
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f3a9771 commit d96a539

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

sequencer.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,6 @@ static void free_message(struct commit *commit, struct commit_message *msg)
158158
unuse_commit_buffer(commit, msg->message);
159159
}
160160

161-
static void write_cherry_pick_head(struct commit *commit, const char *pseudoref)
162-
{
163-
const char *filename;
164-
int fd;
165-
struct strbuf buf = STRBUF_INIT;
166-
167-
strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1));
168-
169-
filename = git_path("%s", pseudoref);
170-
fd = open(filename, O_WRONLY | O_CREAT, 0666);
171-
if (fd < 0)
172-
die_errno(_("Could not open '%s' for writing"), filename);
173-
if (write_in_full(fd, buf.buf, buf.len) != buf.len || close(fd))
174-
die_errno(_("Could not write to '%s'"), filename);
175-
strbuf_release(&buf);
176-
}
177-
178161
static void print_advice(int show_hint, struct replay_opts *opts)
179162
{
180163
char *msg = getenv("GIT_CHERRY_PICK_HELP");
@@ -607,9 +590,11 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
607590
* write it at all.
608591
*/
609592
if (opts->action == REPLAY_PICK && !opts->no_commit && (res == 0 || res == 1))
610-
write_cherry_pick_head(commit, "CHERRY_PICK_HEAD");
593+
update_ref(NULL, "CHERRY_PICK_HEAD", commit->object.sha1, NULL,
594+
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
611595
if (opts->action == REPLAY_REVERT && ((opts->no_commit && res == 0) || res == 1))
612-
write_cherry_pick_head(commit, "REVERT_HEAD");
596+
update_ref(NULL, "REVERT_HEAD", commit->object.sha1, NULL,
597+
REF_NODEREF, UPDATE_REFS_DIE_ON_ERR);
613598

614599
if (res) {
615600
error(opts->action == REPLAY_REVERT

0 commit comments

Comments
 (0)