Check for existence and delete CHERRY_PICK_HEAD through ref functions.
This will help cherry-pick work with alternate ref storage backends.
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
else
die(_("You have not concluded your merge (MERGE_HEAD exists)."));
}
else
die(_("You have not concluded your merge (MERGE_HEAD exists)."));
}
- if (file_exists(git_path_cherry_pick_head(the_repository))) {
+ if (ref_exists("CHERRY_PICK_HEAD")) {
if (advice_resolve_conflict)
die(_("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
"Please, commit your changes before you merge."));
if (advice_resolve_conflict)
die(_("You have not concluded your cherry-pick (CHERRY_PICK_HEAD exists).\n"
"Please, commit your changes before you merge."));
-REPO_GIT_PATH_FUNC(cherry_pick_head, "CHERRY_PICK_HEAD")
REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD")
REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG")
REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")
REPO_GIT_PATH_FUNC(revert_head, "REVERT_HEAD")
REPO_GIT_PATH_FUNC(squash_msg, "SQUASH_MSG")
REPO_GIT_PATH_FUNC(merge_msg, "MERGE_MSG")
- const char *cherry_pick_head;
const char *revert_head;
const char *squash_msg;
const char *merge_msg;
const char *revert_head;
const char *squash_msg;
const char *merge_msg;
-#define PATH_CACHE_INIT { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
+#define PATH_CACHE_INIT \
+ { \
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \
+ }
-const char *git_path_cherry_pick_head(struct repository *r);
const char *git_path_revert_head(struct repository *r);
const char *git_path_squash_msg(struct repository *r);
const char *git_path_merge_msg(struct repository *r);
const char *git_path_revert_head(struct repository *r);
const char *git_path_squash_msg(struct repository *r);
const char *git_path_merge_msg(struct repository *r);
* (typically rebase --interactive) wants to take care
* of the commit itself so remove CHERRY_PICK_HEAD
*/
* (typically rebase --interactive) wants to take care
* of the commit itself so remove CHERRY_PICK_HEAD
*/
- unlink(git_path_cherry_pick_head(r));
+ refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
+ NULL, 0);
author, opts, flags, &oid);
strbuf_release(&sb);
if (!res) {
author, opts, flags, &oid);
strbuf_release(&sb);
if (!res) {
- unlink(git_path_cherry_pick_head(r));
+ refs_delete_ref(get_main_ref_store(r), "",
+ "CHERRY_PICK_HEAD", NULL, 0);
unlink(git_path_merge_msg(r));
if (!is_rebase_i(opts))
print_commit_summary(r, NULL, &oid,
unlink(git_path_merge_msg(r));
if (!is_rebase_i(opts))
print_commit_summary(r, NULL, &oid,
flags |= ALLOW_EMPTY;
} else if (allow == 2) {
drop_commit = 1;
flags |= ALLOW_EMPTY;
} else if (allow == 2) {
drop_commit = 1;
- unlink(git_path_cherry_pick_head(r));
+ refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
+ NULL, 0);
unlink(git_path_merge_msg(r));
fprintf(stderr,
_("dropping %s %s -- patch contents already upstream\n"),
unlink(git_path_merge_msg(r));
fprintf(stderr,
_("dropping %s %s -- patch contents already upstream\n"),
struct replay_opts opts = REPLAY_OPTS_INIT;
int need_cleanup = 0;
struct replay_opts opts = REPLAY_OPTS_INIT;
int need_cleanup = 0;
- if (file_exists(git_path_cherry_pick_head(r))) {
- if (!unlink(git_path_cherry_pick_head(r)) && verbose)
+ if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD")) {
+ if (!refs_delete_ref(get_main_ref_store(r), "",
+ "CHERRY_PICK_HEAD", NULL, 0) &&
+ verbose)
warning(_("cancelling a cherry picking in progress"));
opts.action = REPLAY_PICK;
need_cleanup = 1;
warning(_("cancelling a cherry picking in progress"));
opts.action = REPLAY_PICK;
need_cleanup = 1;
enum replay_action action;
const char *in_progress_error = NULL;
const char *in_progress_advice = NULL;
enum replay_action action;
const char *in_progress_error = NULL;
const char *in_progress_advice = NULL;
- unsigned int advise_skip = file_exists(git_path_revert_head(r)) ||
- file_exists(git_path_cherry_pick_head(r));
+ unsigned int advise_skip =
+ file_exists(git_path_revert_head(r)) ||
+ refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD");
if (!sequencer_get_last_command(r, &action)) {
switch (action) {
if (!sequencer_get_last_command(r, &action)) {
switch (action) {
{
struct object_id head_oid;
{
struct object_id head_oid;
- if (!file_exists(git_path_cherry_pick_head(r)) &&
+ if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
!file_exists(git_path_revert_head(r)))
return error(_("no cherry-pick or revert in progress"));
if (read_ref_full("HEAD", 0, &head_oid, NULL))
!file_exists(git_path_revert_head(r)))
return error(_("no cherry-pick or revert in progress"));
if (read_ref_full("HEAD", 0, &head_oid, NULL))
}
break;
case REPLAY_PICK:
}
break;
case REPLAY_PICK:
- if (!file_exists(git_path_cherry_pick_head(r))) {
+ if (!refs_ref_exists(get_main_ref_store(r),
+ "CHERRY_PICK_HEAD")) {
if (action != REPLAY_PICK)
return error(_("no cherry-pick in progress"));
if (!rollback_is_safe())
if (action != REPLAY_PICK)
return error(_("no cherry-pick in progress"));
if (!rollback_is_safe())
oid_to_hex(&j->item->object.oid));
strbuf_release(&ref_name);
oid_to_hex(&j->item->object.oid));
strbuf_release(&ref_name);
- unlink(git_path_cherry_pick_head(r));
+ refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
+ NULL, 0);
rollback_lock_file(&lock);
rollback_lock_file(&lock);
rollback_lock_file(&lock);
rollback_lock_file(&lock);
{
const char *argv[] = { "commit", NULL };
{
const char *argv[] = { "commit", NULL };
- if (!file_exists(git_path_cherry_pick_head(r)) &&
+ if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
!file_exists(git_path_revert_head(r)))
return error(_("no cherry-pick or revert in progress"));
return run_command_v_opt(argv, RUN_GIT_CMD);
!file_exists(git_path_revert_head(r)))
return error(_("no cherry-pick or revert in progress"));
return run_command_v_opt(argv, RUN_GIT_CMD);
- const char *cherry_pick_head = git_path_cherry_pick_head(r);
-
- if (file_exists(cherry_pick_head) && unlink(cherry_pick_head))
+ if (refs_ref_exists(get_main_ref_store(r),
+ "CHERRY_PICK_HEAD") &&
+ refs_delete_ref(get_main_ref_store(r), "",
+ "CHERRY_PICK_HEAD", NULL, 0))
return error(_("could not remove CHERRY_PICK_HEAD"));
if (!final_fixup)
return 0;
return error(_("could not remove CHERRY_PICK_HEAD"));
if (!final_fixup)
return 0;
if (!is_rebase_i(opts)) {
/* Verify that the conflict has been resolved */
if (!is_rebase_i(opts)) {
/* Verify that the conflict has been resolved */
- if (file_exists(git_path_cherry_pick_head(r)) ||
+ if (refs_ref_exists(get_main_ref_store(r),
+ "CHERRY_PICK_HEAD") ||
file_exists(git_path_revert_head(r))) {
res = continue_single_pick(r);
if (res)
file_exists(git_path_revert_head(r))) {
res = continue_single_pick(r);
if (res)
int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
{
int sequencer_determine_whence(struct repository *r, enum commit_whence *whence)
{
- if (file_exists(git_path_cherry_pick_head(r))) {
+ if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD")) {
struct object_id cherry_pick_head, rebase_head;
if (file_exists(git_path_seq_dir()))
struct object_id cherry_pick_head, rebase_head;
if (file_exists(git_path_seq_dir()))
state->merge_in_progress = 1;
} else if (wt_status_check_rebase(NULL, state)) {
; /* all set */
state->merge_in_progress = 1;
} else if (wt_status_check_rebase(NULL, state)) {
; /* all set */
- } else if (!stat(git_path_cherry_pick_head(r), &st) &&
- !get_oid("CHERRY_PICK_HEAD", &oid)) {
+ } else if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") &&
+ !get_oid("CHERRY_PICK_HEAD", &oid)) {
state->cherry_pick_in_progress = 1;
oidcpy(&state->cherry_pick_head_oid, &oid);
}
state->cherry_pick_in_progress = 1;
oidcpy(&state->cherry_pick_head_oid, &oid);
}