From patchwork Fri Jun 5 18:03:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 11590339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED676159A for ; Fri, 5 Jun 2020 18:03:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB766206FA for ; Fri, 5 Jun 2020 18:03:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ciuDoaLU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728091AbgFESDc (ORCPT ); Fri, 5 Jun 2020 14:03:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728070AbgFESD3 (ORCPT ); Fri, 5 Jun 2020 14:03:29 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DB1CC08C5C4 for ; Fri, 5 Jun 2020 11:03:28 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id j198so9621056wmj.0 for ; Fri, 05 Jun 2020 11:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=pOs6eMd+RC2vCLBLhB9pmRACQnnoM2tWyOisjR62G7U=; b=ciuDoaLUzeAzA9cW7m1de10naRvdoos7+4lNJAIwcY0WjMdCrqEg2BdA1jd58Hx8fu 9DoG9IJ7PnpOAqpPQVzqcKf9JVK1zl+kY7qlRHUbL9SgiON7kGSr4tfd8RZPFsVpKruI X73comYC0+v8K7tmxTAppxtzwVHbC8poXOr3w6rlqEZpoy54/lQ6tKesQpU5SiHHuJlJ 2P2xgl8nSaPvP+RhaX0IIx/sRDa+eOzygLIEdYLS1797TLDNf2MIUygsWDsU8iTu40u2 JT2bn+tFcK97Z4BZVRLZpxx4L+3IMvwAJXBBLUwSbN2vc+V1SsMBJt0+CEzPPMcoLqOG cFLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=pOs6eMd+RC2vCLBLhB9pmRACQnnoM2tWyOisjR62G7U=; b=akdCeLWoo8pszCAMe8ALz7JY//hOPeCqOlRTEx1HkRvhCQaBTjQGXl0xky0AbXkVw0 NoceCWOhDH3awlS+oZB4wtoTqv+W4FmGlxkj97nDpv4jcgrAeNAI3Z4n2pdoPTKfRpE1 Mllf6QqVYN7C+CVoo0ViGDFvgyzeJU3haeJSqchg0bQKBSBDYN3YrgHrWaELtvruaU4T HEKHaKoAWV9/EG6jffIKyc44nU7YdeHV7/uNj0wFhzBwkzpHjbXcPy3CnsXowmyOkxLp 9Ih0VvOu60R0xBT7gUr4H0cpSg+Rc7BJYKMZxj4d5FU6qWNDzGU8QYmLzReA6i48x96q iQJg== X-Gm-Message-State: AOAM531h0SWaXM44OnQR8VzJQfq5NmL349NZWXj8YWKt5pzZMgu697fO r6pckye5Xz4SNYbCvo2dt5ilYsP/ X-Google-Smtp-Source: ABdhPJxmQsug3/UdLa3jMv2A/zHYCm4vN3i9M/qthSkqz7B2E9ttW9X6P83PEuMG9gQBuREx7tY4rg== X-Received: by 2002:a7b:cb4e:: with SMTP id v14mr3755923wmj.164.1591380207067; Fri, 05 Jun 2020 11:03:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n7sm12973444wrx.82.2020.06.05.11.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 11:03:26 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Fri, 05 Jun 2020 18:03:09 +0000 Subject: [PATCH v16 05/14] Treat REVERT_HEAD as a pseudo ref Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys Signed-off-by: Han-Wen Nienhuys --- path.c | 1 - path.h | 8 +++----- sequencer.c | 16 +++++++++------- wt-status.c | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/path.c b/path.c index 783cc2ae819..7b385e5eb28 100644 --- a/path.c +++ b/path.c @@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename) return NULL; } -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(merge_rr, "MERGE_RR") diff --git a/path.h b/path.h index 8941c018a99..e7e77da6aaa 100644 --- a/path.h +++ b/path.h @@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void); } struct path_cache { - const char *revert_head; const char *squash_msg; const char *merge_msg; const char *merge_rr; @@ -181,12 +180,11 @@ struct path_cache { const char *shallow; }; -#define PATH_CACHE_INIT \ - { \ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ +#define PATH_CACHE_INIT \ + { \ + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL \ } -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_merge_rr(struct repository *r); diff --git a/sequencer.c b/sequencer.c index 26286ec8d08..25ef9fc773d 100644 --- a/sequencer.c +++ b/sequencer.c @@ -2317,8 +2317,10 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose) need_cleanup = 1; } - if (file_exists(git_path_revert_head(r))) { - if (!unlink(git_path_revert_head(r)) && verbose) + if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) { + if (!refs_delete_pseudoref(get_main_ref_store(r), "REVERT_HEAD", + NULL) && + verbose) warning(_("cancelling a revert in progress")); opts.action = REPLAY_REVERT; need_cleanup = 1; @@ -2677,7 +2679,7 @@ static int create_seq_dir(struct repository *r) const char *in_progress_error = NULL; const char *in_progress_advice = NULL; unsigned int advise_skip = - file_exists(git_path_revert_head(r)) || + refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") || refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD"); if (!sequencer_get_last_command(r, &action)) { @@ -2778,7 +2780,7 @@ static int rollback_single_pick(struct repository *r) struct object_id head_oid; if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") && - !file_exists(git_path_revert_head(r))) + !refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) return error(_("no cherry-pick or revert in progress")); if (read_ref_full("HEAD", 0, &head_oid, NULL)) return error(_("cannot resolve HEAD")); @@ -2872,7 +2874,7 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts) */ switch (opts->action) { case REPLAY_REVERT: - if (!file_exists(git_path_revert_head(r))) { + if (!refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) { if (action != REPLAY_REVERT) return error(_("no revert in progress")); if (!rollback_is_safe()) @@ -4210,7 +4212,7 @@ static int continue_single_pick(struct repository *r) const char *argv[] = { "commit", NULL }; if (!refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") && - !file_exists(git_path_revert_head(r))) + !refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) return error(_("no cherry-pick or revert in progress")); return run_command_v_opt(argv, RUN_GIT_CMD); } @@ -4390,7 +4392,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) /* Verify that the conflict has been resolved */ if (refs_ref_exists(get_main_ref_store(r), "CHERRY_PICK_HEAD") || - file_exists(git_path_revert_head(r))) { + refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD")) { res = continue_single_pick(r); if (res) goto release_todo_list; diff --git a/wt-status.c b/wt-status.c index 96302be030b..81b768504a1 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1642,7 +1642,7 @@ void wt_status_get_state(struct repository *r, oidcpy(&state->cherry_pick_head_oid, &oid); } wt_status_check_bisect(NULL, state); - if (!stat(git_path_revert_head(r), &st) && + if (refs_ref_exists(get_main_ref_store(r), "REVERT_HEAD") && !get_oid("REVERT_HEAD", &oid)) { state->revert_in_progress = 1; oidcpy(&state->revert_head_oid, &oid);