From patchwork Fri Aug 21 16:59:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11730017 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 CB37013B1 for ; Fri, 21 Aug 2020 17:04:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AAFF420702 for ; Fri, 21 Aug 2020 17:04:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ti92Xh2Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728785AbgHURE2 (ORCPT ); Fri, 21 Aug 2020 13:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728589AbgHUQ7l (ORCPT ); Fri, 21 Aug 2020 12:59:41 -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 31484C061574 for ; Fri, 21 Aug 2020 09:59:41 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id 9so2550415wmj.5 for ; Fri, 21 Aug 2020 09:59:41 -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=yZIvkey6Uj4REB4QipV6iY4qH4NvmcwxVFGQ4lFzb+o=; b=ti92Xh2Zwe8iKPvJ8KFVwWnH6NzBzBgbkgswFtAE+DiJaLSTAQCgHT3yDvxC6AWdVv vprmVBgSQpJ84dladvBKrU+suksCa+W3aN1Pj6TPDY54DBj/3obPiwWtU/qyYupqp5MX 9y1HKxA5efuhuznS3HPlT0VaAulxiGvJP6PtmTn2K9inxO+olFhlOd3mMyqgXh7MFnFp 4TCX45MsYV+t3bTseQvd6dd2bX56aNik/1jGAGbx2Kp/KwmnQvjIfNi7HtOBawBvXcP2 nT3/yZP+jOwWabV9RddEU2C9rs6sDunl1DdnQMl5C1N2YqttDCCYQu+llBvZ+0c1SGMY KCrA== 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=yZIvkey6Uj4REB4QipV6iY4qH4NvmcwxVFGQ4lFzb+o=; b=jzCNg3DPEIR9FeFhwffLQCAAhU6a1iWocM+5YZZ1nDskahu5WtUSiPqqnEyIlHdnyA N1Tmh81GwLSsL2ORQV5g4cVqf4km81m4nG9o1/dYNUm1tcdEuctOIgTHlsmCxB7TJcfZ ez6dV6Z97fk8EQt7CF3OMyeO6dvICr5wZUe09AzPm8myb5yYs7xWSVsj7Uq1tD0sCCXu anxoYUNmAbkrs5h1Va9Pv++l2Zsc9ee9hINUN+zMbUpvkHSzWlPEnD7UKlBNTRxzCwyX Uwwh9H1MXW2N5TJb75m4rDscOdpmqc4ZH37dDckwHljh3DCN3KN966BYODIWfTLCieI3 qsrw== X-Gm-Message-State: AOAM532iMwhdkqwYeDPeLwZsctuoR//u+7bA1Sf67UMgEgP1TybwIXvH 7i3h6AKbgOhpHQ9Gov7Q/n0sE5dO57c= X-Google-Smtp-Source: ABdhPJwPvYSUJDdhU7hG+ULrhZaDDIJ38vfdPABYN8bHhvT+SEm+2LK2lMyDqwFaOFXiarACRFeNhQ== X-Received: by 2002:a1c:f018:: with SMTP id a24mr3852817wmb.7.1598029179693; Fri, 21 Aug 2020 09:59:39 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o7sm5529724wrv.50.2020.08.21.09.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:59:39 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Fri, 21 Aug 2020 16:59:34 +0000 Subject: [PATCH v3 1/4] refs: make refs_ref_exists public 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 This will be necessary to replace file existence checks for pseudorefs. Signed-off-by: Han-Wen Nienhuys --- refs.c | 2 +- refs.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index cf91711968..d46080f4b6 100644 --- a/refs.c +++ b/refs.c @@ -313,7 +313,7 @@ int read_ref(const char *refname, struct object_id *oid) return read_ref_full(refname, RESOLVE_REF_READING, oid, NULL); } -static int refs_ref_exists(struct ref_store *refs, const char *refname) +int refs_ref_exists(struct ref_store *refs, const char *refname) { return !!refs_resolve_ref_unsafe(refs, refname, RESOLVE_REF_READING, NULL, NULL); } diff --git a/refs.h b/refs.h index 29e28124cd..04bd25019f 100644 --- a/refs.h +++ b/refs.h @@ -105,6 +105,8 @@ int refs_verify_refname_available(struct ref_store *refs, const struct string_list *skip, struct strbuf *err); +int refs_ref_exists(struct ref_store *refs, const char *refname); + int ref_exists(const char *refname); int should_autocreate_reflog(const char *refname); From patchwork Fri Aug 21 16:59:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11730013 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 E0EA413B1 for ; Fri, 21 Aug 2020 17:04:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B44FD20702 for ; Fri, 21 Aug 2020 17:04:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uuJTikR5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728789AbgHURE3 (ORCPT ); Fri, 21 Aug 2020 13:04:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728605AbgHUQ7n (ORCPT ); Fri, 21 Aug 2020 12:59:43 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE5FBC061575 for ; Fri, 21 Aug 2020 09:59:42 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id r15so2540966wrp.13 for ; Fri, 21 Aug 2020 09:59:42 -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=+ph5onEkRmuF4W1OZ0B0SvfVph56e9EJeBNlm/Tmv8s=; b=uuJTikR5AqGnzZdP72CwIEfAWcIUu4+VdHdw9xgU0pDImPI7pIWTolwmupuaSQ08MC qQtssLske0lOtoiIIjAh2mvssUMK9ofyOGZjkslQR4/9Li5PLiODAWUousR4vHVh8k5P 9qSx5TCVdUKJUo/kWtLHKHKQsPPPba1NUK0Y2dPn0e3vy2rOqsP5FE3kiJu1Ra6J7Ryh P3MWM0oNTuh7OxpGhsGYwEkowB7DidZxcPeoJixCVda9XKz+pH4zJTOHMFis+w00+ZYQ wrpQUeYUL1487zxdYbyHUYGEWGx9UmTaaldJPIrM9L+Izi4w8K0wsvt8puM04KLenbNX Cjrg== 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=+ph5onEkRmuF4W1OZ0B0SvfVph56e9EJeBNlm/Tmv8s=; b=jywcCDF38+wpmFQF8kIt1FzDI6bIZQOGm8ugEGZfuWpQIN7mA7BtJK56KuzzkMtyyG L0iW7QrTcPlIg/pQoUNLcEXipaGqpgRKn/2zIHE5OjnodjtesAV0Tks9zoLIhDmAKqLK +SrAQmDL4JjNSPppwhLHxGhaNUs0WoZ15/emXZ69hkwS8MJxbDP5L6P0WgNi6KverqpN 6Ie+f9IW+BDB8a2rRauXIPiFvjj9eSfmrDsNTMXcxONh11iJZNw4LECGnaPKSMrCmLBh 7QEuYJRB4+ede+IDu/YA44G7zT6ExToctxGffeYaoVeEdGmGMn+dkR23ayhcHtahOVQy 30CA== X-Gm-Message-State: AOAM532A6O413cDODhdky148zsfohTjhT6qC6DKZwC2icCDgLzG00MJ9 gGeVLnpM/nq1CMNpcd0iPRL9p1QeTG8= X-Google-Smtp-Source: ABdhPJxhFIyp78xyMfSUVrbKIm6h0+FKb/xMn8WWsadhUX6I1csCxc4HLNcUu+TwRQ/8fclo5k9OOA== X-Received: by 2002:adf:ba83:: with SMTP id p3mr3631871wrg.246.1598029180514; Fri, 21 Aug 2020 09:59:40 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x14sm6229456wmc.5.2020.08.21.09.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:59:40 -0700 (PDT) Message-Id: <5ff5d2c6636ff7ef0c41bae4ce53923925979f0a.1598029177.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Fri, 21 Aug 2020 16:59:35 +0000 Subject: [PATCH v3 2/4] sequencer: treat CHERRY_PICK_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 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 --- builtin/merge.c | 2 +- path.c | 1 - path.h | 7 ++++--- sequencer.c | 42 ++++++++++++++++++++++++++---------------- wt-status.c | 4 ++-- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index 74829a838e..b9a89ba858 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1348,7 +1348,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) 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.")); diff --git a/path.c b/path.c index 8b2c753191..783cc2ae81 100644 --- a/path.c +++ b/path.c @@ -1528,7 +1528,6 @@ char *xdg_cache_home(const char *filename) return NULL; } -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") diff --git a/path.h b/path.h index 1f1bf8f87a..8941c018a9 100644 --- a/path.h +++ b/path.h @@ -170,7 +170,6 @@ void report_linked_checkout_garbage(void); } struct path_cache { - const char *cherry_pick_head; const char *revert_head; const char *squash_msg; const char *merge_msg; @@ -182,9 +181,11 @@ struct path_cache { const char *shallow; }; -#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); diff --git a/sequencer.c b/sequencer.c index 2425896911..3f538a0851 100644 --- a/sequencer.c +++ b/sequencer.c @@ -381,7 +381,8 @@ static void print_advice(struct repository *r, int show_hint, * (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); return; } @@ -1455,7 +1456,8 @@ static int do_commit(struct repository *r, 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, @@ -1966,7 +1968,8 @@ static int do_pick_commit(struct repository *r, 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"), @@ -2305,8 +2308,10 @@ void sequencer_post_commit_cleanup(struct repository *r, int verbose) 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; @@ -2671,8 +2676,9 @@ static int create_seq_dir(struct repository *r) 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) { @@ -2771,7 +2777,7 @@ static int rollback_single_pick(struct repository *r) { 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)) @@ -2874,7 +2880,8 @@ int sequencer_skip(struct repository *r, struct replay_opts *opts) } 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()) @@ -3569,7 +3576,8 @@ static int do_merge(struct repository *r, 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); @@ -4201,7 +4209,7 @@ static int continue_single_pick(struct repository *r) { 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); @@ -4318,9 +4326,10 @@ static int commit_staged_changes(struct repository *r, } if (is_clean) { - 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; @@ -4379,7 +4388,8 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) 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) @@ -5443,7 +5453,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) 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())) diff --git a/wt-status.c b/wt-status.c index d75399085d..c6abf2f3ca 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1672,8 +1672,8 @@ void wt_status_get_state(struct repository *r, 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); } From patchwork Fri Aug 21 16:59:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11730019 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 1BE3216B1 for ; Fri, 21 Aug 2020 17:04:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0009C207DE for ; Fri, 21 Aug 2020 17:04:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BJZWgNhz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728739AbgHUREY (ORCPT ); Fri, 21 Aug 2020 13:04:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728668AbgHUQ7o (ORCPT ); Fri, 21 Aug 2020 12:59:44 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C028C0613ED for ; Fri, 21 Aug 2020 09:59:44 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id f18so1608663wmc.0 for ; Fri, 21 Aug 2020 09:59:43 -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=DIFo+BrNurMfcn1iRpz15LZRf7JCJXN6gFBT83ytqOM=; b=BJZWgNhzg7wxi9qrxAk3lxs52D7xzpjzTh1KAafplA1Ax7hCmI4wBJDwYOajHyd+F/ p72dUm+jB+m/WElvcy6Pk72fB+Aiw6TR6xdHZVrghj98hbuLqmMZmf0age5UHlnoaaCR Km258SnXIG15oWK3rMyEiIfvYj0a/8oVDr6v2xl10NuoHjLQAdZwhsf3J9u9pEoNPWTz Q+aRPI/LbWYkQgIQSTLJDK0iva7+722+hoNbnqdfbK5dz3yvwMWmoxNtEJz8A2uH1iPp HKW4bCwBvtl+7sinNs9qMC9GcAN0nC5eivlfTZkITVJMkLLiXXyxisnHO3gebr+yS7mI kROg== 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=DIFo+BrNurMfcn1iRpz15LZRf7JCJXN6gFBT83ytqOM=; b=C3Ck8q5pG7oDOlWpQXWWy754mdLW0xLexxyuWRAp1dXQRxMRWmd/z+u2GW7/A3sMNK MqwtTI2PTWxmd1FuYrpzCxv39/Kly4Aw3AIsFshmkcOxGtctnndn9BCSklU9BdmVRaoy 01i8+hy+/oBzdF5nXju+0YaRd4/uR0nyiHaPzG8Ph6Ym3VLN8UHCWGMNoHzqavW3bE3j 0aWv4/wJvU/ZZ0nv0woOPOR6kSb+4qU3HZbyH7oi5ZmXf9wPACIloeYsy8ZGzNwT7L0B gaMZXzV5Jh9A46Orb8H/vJd9v2LyfSsKxuk06iYZOAjqGCjRLs+pQ4CJTCZ8VAtFZLUL VQJQ== X-Gm-Message-State: AOAM5322B2gtYNTJVsIrfb2WVNx8Qbh35I5g+SdN4IhzG7/BFalBRxr8 /a2iYRBoM7dKgCr0tz3POQjgHvwSaIk= X-Google-Smtp-Source: ABdhPJzgKOjxskhx2rLVlRvwgJudRFzZcxoZE1+yziZJ8Np61h/w92o01ASqR3WtEEJvM+mYKRi2NQ== X-Received: by 2002:a7b:c1d0:: with SMTP id a16mr4883034wmj.111.1598029181494; Fri, 21 Aug 2020 09:59:41 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m126sm6598270wmf.3.2020.08.21.09.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:59:40 -0700 (PDT) Message-Id: <8aacde69c8c4689b6b68f11a310a308595ed49ad.1598029177.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Fri, 21 Aug 2020 16:59:36 +0000 Subject: [PATCH v3 3/4] builtin/commit: suggest update-ref for pseudoref removal 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 When pseudorefs move to a different ref storage mechanism, pseudorefs no longer can be removed with 'rm'. Instead, suggest a "update-ref -d" command, which will work regardless of ref storage backend. Signed-off-by: Han-Wen Nienhuys --- builtin/commit.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 69ac78d5e5..671721c385 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -847,21 +847,19 @@ static int prepare_to_commit(const char *index_file, const char *prefix, if (cleanup_mode == COMMIT_MSG_CLEANUP_SCISSORS && !merge_contains_scissors) wt_status_add_cut_line(s->fp); - status_printf_ln(s, GIT_COLOR_NORMAL, - whence == FROM_MERGE - ? _("\n" - "It looks like you may be committing a merge.\n" - "If this is not correct, please remove the file\n" - " %s\n" - "and try again.\n") - : _("\n" - "It looks like you may be committing a cherry-pick.\n" - "If this is not correct, please remove the file\n" - " %s\n" - "and try again.\n"), + status_printf_ln( + s, GIT_COLOR_NORMAL, whence == FROM_MERGE ? - git_path_merge_head(the_repository) : - git_path_cherry_pick_head(the_repository)); + _("\n" + "It looks like you may be committing a merge.\n" + "If this is not correct, please run\n" + " git update-ref -d MERGE_HEAD\n" + "and try again.\n") : + _("\n" + "It looks like you may be committing a cherry-pick.\n" + "If this is not correct, please run\n" + " git update-ref -d CHERRY_PICK_HEAD\n" + "and try again.\n")); } fprintf(s->fp, "\n"); From patchwork Fri Aug 21 16:59:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Blain via GitGitGadget X-Patchwork-Id: 11729997 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 0C97113B1 for ; Fri, 21 Aug 2020 17:00:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0FB4207DE for ; Fri, 21 Aug 2020 17:00:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SCQVas0s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728324AbgHURAw (ORCPT ); Fri, 21 Aug 2020 13:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728663AbgHUQ7o (ORCPT ); Fri, 21 Aug 2020 12:59:44 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C57F1C061755 for ; Fri, 21 Aug 2020 09:59:43 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id d16so2554125wrq.9 for ; Fri, 21 Aug 2020 09:59:43 -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=2a22Ji+Lb045nXL4szHp+eaepH/aNbTIVowa/e/T8SY=; b=SCQVas0sLpyuLhnl0Fx12kIW5BA3SHEKDvaX4504J0FN8cXq1ZLpvERKMaMQ8gYczB jUU/WyMo2iLVB77EPMF+nVsuSydnojozgH4oMCIzKXVdowAndnKhbNxEp3VinVIWdLKL X/HKTpgbxJju5DECvk7i16eEKd8MYGk4UO6GgQmrvVjzgNr0vYYnPhc+kop8IwRsdwJ9 sQ7QU6ZjyUJ+myz0SDZFMVyZ9imJL3M/MWt1BYHKW2s7+EIDUBqYMDyZrn35gIsAWcP6 /4rgZh17s0hAHvBUUjWKXExW7BvQ79TVe6u3kMdyY6+IbZZFpc0Ky4rmPjROzeSUddmN hVOA== 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=2a22Ji+Lb045nXL4szHp+eaepH/aNbTIVowa/e/T8SY=; b=GGN+GJC0689PumKexCuWdOzR6kPjMQ+skZYVh2YyinZMDH7zsrfcnlqpA4Z5YTsUAa P7F/TpXcSyz7EgVYytKY7jEGXEJ3mCeFJB37XE/ttndYYL0p7m6kSPg4MTNO7JcBdbeb icyaoT0P+oHkq9uXjfor5F3TpAUAFce9hKSEB4A9meJ62K0H1Q0ZgGi4hSwomiM7qlzy M7A18hdB9qwzU8Uafeux15SyNVbEan4cnv3KaOfb63CUavY9X90JcyiAtMxFWwQ45yRw R4z69xhQMsH9+PnBTWRXZR7AndLD3E3bkck5Ifx5cWI7QhEpaa8V3p+7XwiV4d4jE2IP 9Kig== X-Gm-Message-State: AOAM532F6L49ycjfdcWuM2wTW9OVbpv+pHc9Gu9A/ufFNevAOBTjHGb5 JAxNT+DMaG3ZtxeZ4ZGNPO7xsDlYFkU= X-Google-Smtp-Source: ABdhPJzkSUB6trZYKTdSiXGcsBf5mDL5WzsNLv9iro4d6UVJeKevoEQ7F5IFfqCYpsjOYmNT7PaZHw== X-Received: by 2002:a5d:5383:: with SMTP id d3mr3527703wrv.42.1598029182260; Fri, 21 Aug 2020 09:59:42 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 145sm7393235wma.20.2020.08.21.09.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 09:59:41 -0700 (PDT) Message-Id: <9ba013664584087edcc3bc7101ef0d207b1f8b7d.1598029177.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Fri, 21 Aug 2020 16:59:37 +0000 Subject: [PATCH v3 4/4] sequencer: 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 783cc2ae81..7b385e5eb2 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 8941c018a9..e7e77da6aa 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 3f538a0851..d7db076715 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_ref(get_main_ref_store(r), "", "REVERT_HEAD", + NULL, 0) && + 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 c6abf2f3ca..ecbe570e28 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1678,7 +1678,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);