From patchwork Thu Jul 9 21:11:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Peterson via GitGitGadget X-Patchwork-Id: 11655129 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 DEA35913 for ; Thu, 9 Jul 2020 21:11:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6B2920774 for ; Thu, 9 Jul 2020 21:11:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bx1vz0VZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbgGIVL4 (ORCPT ); Thu, 9 Jul 2020 17:11:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726289AbgGIVLx (ORCPT ); Thu, 9 Jul 2020 17:11:53 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C09CC08C5DD for ; Thu, 9 Jul 2020 14:11:53 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id w3so3360325wmi.4 for ; Thu, 09 Jul 2020 14:11:53 -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=4tPbBuOlUBUJNGrzExajIWDAcijCiaD6SsrE7Y63AMM=; b=Bx1vz0VZw6Q/LZ2xBOTUjYb/PU9AAJNO8uvwhud5/7N6Bo9BUMC1H9vBR3t14pHRL3 So0yOfYUIozab0IuefUX8+Ay2g+H0oBqfrMbMtyCjWNmp8RovYqlFxbCrSMCjoRvXX5s ve6iXh35ePnv2E0XNY6LTICx+D3f2umHwiO4Ne3xFqCyaDp2/UVDChbytQfNE1om+g1a 1PnxiPH5yjcNByEAuvSMmthCi0ij8HdDlYE+BdG+2p9OVyiSF1fXhTGV/G54Kv746vWC xTudSTP48fv7r8/DK1z518lr+ZeaW1Bsu9F7jywo///aqmXwe64n6Ej6M79qWAtCyxYH 4orA== 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=4tPbBuOlUBUJNGrzExajIWDAcijCiaD6SsrE7Y63AMM=; b=O4eTIKHnzb4yyA57mVzJ+UeS6GIHu6/RsGntTNV6IAb1A9VOLeZU3tNr00CjOu5uln ZG6LbcIjHtpcvkVGpjzxtCUrPHLMZn3AZ9weTAqHq3Z8Mof4K4ZY/uobTPLRIj3tJaEr 6o8cRGEz1ZdkSAffNi+rnkWJgYWYAiQhwFPStfawf+QNb/ObvTSWlsHe88rM8e+HBhRR 0tW91GylnC0PryCOWLFLolE/N0YzPkcRmkVqxb3GzHhcSm5Lqkw3nFma6RlaTGHIBUl7 nxM5cW6E+kA7GqoFIBo9HU/FewDjyDBHqn2iElBeRQx7zIgaLXGYQ3Ju0G/simlBuyyb orEA== X-Gm-Message-State: AOAM530Ml39ls1a+FaK/aZ/dHqq7D4ly8NeySFsxmXx54GmjDmjyI19P WknqgYn0+7J2E/9CjNtj1nftEFuq X-Google-Smtp-Source: ABdhPJxszefPmYNmPFj2FX4ZCc/vmmcBHwakebSdnxtrPq30+TOz8JS1atcynZkFHlyQQ1sMYks3OQ== X-Received: by 2002:a7b:c406:: with SMTP id k6mr1764029wmi.130.1594329109998; Thu, 09 Jul 2020 14:11:49 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l14sm7241945wrn.18.2020.07.09.14.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 14:11:49 -0700 (PDT) Message-Id: <9c3dc4b2cb115de0725f79e27878103756de58ce.1594329108.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Thu, 09 Jul 2020 21:11:46 +0000 Subject: [PATCH v2 1/3] t1400: use git rev-parse for testing PSEUDOREF existence 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 allow these tests to run with alternative ref backends Signed-off-by: Han-Wen Nienhuys --- t/t1400-update-ref.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 27171f8261..7414b898f8 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -475,57 +475,57 @@ test_expect_success 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER test_expect_success 'given old value for missing pseudoref, do not create' ' test_must_fail git update-ref PSEUDOREF $A $B 2>err && - test_path_is_missing .git/PSEUDOREF && + test_must_fail git rev-parse PSEUDOREF && test_i18ngrep "could not read ref" err ' test_expect_success 'create pseudoref' ' git update-ref PSEUDOREF $A && - test $A = $(cat .git/PSEUDOREF) + test $A = $(git rev-parse PSEUDOREF) ' test_expect_success 'overwrite pseudoref with no old value given' ' git update-ref PSEUDOREF $B && - test $B = $(cat .git/PSEUDOREF) + test $B = $(git rev-parse PSEUDOREF) ' test_expect_success 'overwrite pseudoref with correct old value' ' git update-ref PSEUDOREF $C $B && - test $C = $(cat .git/PSEUDOREF) + test $C = $(git rev-parse PSEUDOREF) ' test_expect_success 'do not overwrite pseudoref with wrong old value' ' test_must_fail git update-ref PSEUDOREF $D $E 2>err && - test $C = $(cat .git/PSEUDOREF) && + test $C = $(git rev-parse PSEUDOREF) && test_i18ngrep "unexpected object ID" err ' test_expect_success 'delete pseudoref' ' git update-ref -d PSEUDOREF && - test_path_is_missing .git/PSEUDOREF + test_must_fail git rev-parse PSEUDOREF ' test_expect_success 'do not delete pseudoref with wrong old value' ' git update-ref PSEUDOREF $A && test_must_fail git update-ref -d PSEUDOREF $B 2>err && - test $A = $(cat .git/PSEUDOREF) && + test $A = $(git rev-parse PSEUDOREF) && test_i18ngrep "unexpected object ID" err ' test_expect_success 'delete pseudoref with correct old value' ' git update-ref -d PSEUDOREF $A && - test_path_is_missing .git/PSEUDOREF + test_must_fail git rev-parse PSEUDOREF ' test_expect_success 'create pseudoref with old OID zero' ' git update-ref PSEUDOREF $A $Z && - test $A = $(cat .git/PSEUDOREF) + test $A = $(git rev-parse PSEUDOREF) ' test_expect_success 'do not overwrite pseudoref with old OID zero' ' test_when_finished git update-ref -d PSEUDOREF && test_must_fail git update-ref PSEUDOREF $B $Z 2>err && - test $A = $(cat .git/PSEUDOREF) && + test $A = $(git rev-parse PSEUDOREF) && test_i18ngrep "already exists" err ' From patchwork Thu Jul 9 21:11:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Peterson via GitGitGadget X-Patchwork-Id: 11655123 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 40AE0913 for ; Thu, 9 Jul 2020 21:11:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 234B620774 for ; Thu, 9 Jul 2020 21:11:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GgsSeGEv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726446AbgGIVLy (ORCPT ); Thu, 9 Jul 2020 17:11:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgGIVLw (ORCPT ); Thu, 9 Jul 2020 17:11:52 -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 48BB3C08C5CE for ; Thu, 9 Jul 2020 14:11:52 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id a6so7058937wmm.0 for ; Thu, 09 Jul 2020 14:11:52 -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=fIip23kRmO/CyvjucgYrh4UtIzAlLTHpl2RZBY5pNyA=; b=GgsSeGEvF16AU2TqI9VP+yLwkD0MEAVRr1itUu7FVAqhfHOX76CDiBMMkXc2hHdJJx zHv0aE9DNDbjqFnLuPwDB2tugrmH0gdSsITfG1Vow0yAzeR5NPoyj/GAxpSsuZZFdaj7 7PRvKhGCDiEapxAxNV/izcB5S5r3+Vp/V8VECb15YA5zqbwE2y3WkayZ4C0V7IEuJaO0 MunUInvMSPUXiK3TeSTv5php1RKTj+eTPs5FY4HMtykGucJcgnc0Nv9v87sgT6DnaBTk jAfiClVDfTqSwoRlpZZuTUIfSDoc4wumQ/pXEYilP7NrxN9Ks6BvAHV7iFm6mmAmxDcS Z77g== 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=fIip23kRmO/CyvjucgYrh4UtIzAlLTHpl2RZBY5pNyA=; b=rmLfs1z+XgO3JsuTM4RGoPHWz5EHsPnWe5+/JdJe1pAdtrR08qzBxWjUYMsiUZkXxs DuExl8mhAIHPeXKBI/t2ri8dO99+RPWsn3GfmKJcdPQ1was6FyP+W/lFKMZVYjP2qS27 uOPaB4oBDq8+FKV75h0dOT2YzfOUPYrL7AHNOc8oyWh6tBNdSnuXMT761ErK3Fn8U5xE 0TZDhxsHfyUZfw+qdfWlyEUB6sVSzEj4pXtMnow4egpCuqITrcH8OiKJpIm2uu/Ol0Vq D9oUHOXIpfGKvr4mFgXpqphu9Lry0zlSbLxsdPN3tewr1mE7t2GZJviE5c8OLePaiNGr XhBg== X-Gm-Message-State: AOAM53318+nr8R91hCWmyV8H2DRAt0GmcLlhA0er8OE/V2gC0HHPWjj1 vjxOnuQYBCB6oNKZOEAtdrpncsxP X-Google-Smtp-Source: ABdhPJzRTC0B+l5V9Plvq4EsgjkL90+LJvzCmJNhTLurwYvxq8129oXpiRN+0xzvaZ5cviUK1naCNw== X-Received: by 2002:a1c:2485:: with SMTP id k127mr1768016wmk.138.1594329110781; Thu, 09 Jul 2020 14:11:50 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 26sm6064794wmj.25.2020.07.09.14.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 14:11:50 -0700 (PDT) Message-Id: <871b411517eaee006ed30e6dfa8b1133b15ecea6.1594329108.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Thu, 09 Jul 2020 21:11:47 +0000 Subject: [PATCH v2 2/3] Modify pseudo refs through ref backend storage 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 The previous behavior was introduced in commit 74ec19d4be ("pseudorefs: create and use pseudoref update and delete functions", Jul 31, 2015), with the justification "alternate ref backends still need to store pseudorefs in GIT_DIR". Refs such as REBASE_HEAD are read through the ref backend. This can only work consistently if they are written through the ref backend as well. Tooling that works directly on files under .git should be updated to use git commands to read refs instead. The following behaviors change: * Updates to pseudorefs (eg. ORIG_HEAD) with core.logAllRefUpdates=always will create reflogs for the pseudoref. * non-HEAD pseudoref symrefs are also dereferenced on deletion. Update t1405 accordingly. Signed-off-by: Han-Wen Nienhuys --- refs.c | 120 +++----------------------------------- t/t1400-update-ref.sh | 10 ++-- t/t1405-main-ref-store.sh | 5 +- 3 files changed, 16 insertions(+), 119 deletions(-) diff --git a/refs.c b/refs.c index 639cba93b4..d676acb1f4 100644 --- a/refs.c +++ b/refs.c @@ -771,102 +771,6 @@ long get_files_ref_lock_timeout_ms(void) return timeout_ms; } -static int write_pseudoref(const char *pseudoref, const struct object_id *oid, - const struct object_id *old_oid, struct strbuf *err) -{ - const char *filename; - int fd; - struct lock_file lock = LOCK_INIT; - struct strbuf buf = STRBUF_INIT; - int ret = -1; - - if (!oid) - return 0; - - strbuf_addf(&buf, "%s\n", oid_to_hex(oid)); - - filename = git_path("%s", pseudoref); - fd = hold_lock_file_for_update_timeout(&lock, filename, 0, - get_files_ref_lock_timeout_ms()); - if (fd < 0) { - strbuf_addf(err, _("could not open '%s' for writing: %s"), - filename, strerror(errno)); - goto done; - } - - if (old_oid) { - struct object_id actual_old_oid; - - if (read_ref(pseudoref, &actual_old_oid)) { - if (!is_null_oid(old_oid)) { - strbuf_addf(err, _("could not read ref '%s'"), - pseudoref); - rollback_lock_file(&lock); - goto done; - } - } else if (is_null_oid(old_oid)) { - strbuf_addf(err, _("ref '%s' already exists"), - pseudoref); - rollback_lock_file(&lock); - goto done; - } else if (!oideq(&actual_old_oid, old_oid)) { - strbuf_addf(err, _("unexpected object ID when writing '%s'"), - pseudoref); - rollback_lock_file(&lock); - goto done; - } - } - - if (write_in_full(fd, buf.buf, buf.len) < 0) { - strbuf_addf(err, _("could not write to '%s'"), filename); - rollback_lock_file(&lock); - goto done; - } - - commit_lock_file(&lock); - ret = 0; -done: - strbuf_release(&buf); - return ret; -} - -static int delete_pseudoref(const char *pseudoref, const struct object_id *old_oid) -{ - const char *filename; - - filename = git_path("%s", pseudoref); - - if (old_oid && !is_null_oid(old_oid)) { - struct lock_file lock = LOCK_INIT; - int fd; - struct object_id actual_old_oid; - - fd = hold_lock_file_for_update_timeout( - &lock, filename, 0, - get_files_ref_lock_timeout_ms()); - if (fd < 0) { - error_errno(_("could not open '%s' for writing"), - filename); - return -1; - } - if (read_ref(pseudoref, &actual_old_oid)) - die(_("could not read ref '%s'"), pseudoref); - if (!oideq(&actual_old_oid, old_oid)) { - error(_("unexpected object ID when deleting '%s'"), - pseudoref); - rollback_lock_file(&lock); - return -1; - } - - unlink(filename); - rollback_lock_file(&lock); - } else { - unlink(filename); - } - - return 0; -} - int refs_delete_ref(struct ref_store *refs, const char *msg, const char *refname, const struct object_id *old_oid, @@ -875,11 +779,6 @@ int refs_delete_ref(struct ref_store *refs, const char *msg, struct ref_transaction *transaction; struct strbuf err = STRBUF_INIT; - if (ref_type(refname) == REF_TYPE_PSEUDOREF) { - assert(refs == get_main_ref_store(the_repository)); - return delete_pseudoref(refname, old_oid); - } - transaction = ref_store_transaction_begin(refs, &err); if (!transaction || ref_transaction_delete(transaction, refname, old_oid, @@ -1202,18 +1101,13 @@ int refs_update_ref(struct ref_store *refs, const char *msg, struct strbuf err = STRBUF_INIT; int ret = 0; - if (ref_type(refname) == REF_TYPE_PSEUDOREF) { - assert(refs == get_main_ref_store(the_repository)); - ret = write_pseudoref(refname, new_oid, old_oid, &err); - } else { - t = ref_store_transaction_begin(refs, &err); - if (!t || - ref_transaction_update(t, refname, new_oid, old_oid, - flags, msg, &err) || - ref_transaction_commit(t, &err)) { - ret = 1; - ref_transaction_free(t); - } + t = ref_store_transaction_begin(refs, &err); + if (!t || + ref_transaction_update(t, refname, new_oid, old_oid, flags, msg, + &err) || + ref_transaction_commit(t, &err)) { + ret = 1; + ref_transaction_free(t); } if (ret) { const char *str = _("update_ref failed for ref '%s': %s"); diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 7414b898f8..65d349fb33 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -160,10 +160,10 @@ test_expect_success 'core.logAllRefUpdates=always creates reflog by default' ' git reflog exists $outside ' -test_expect_success 'core.logAllRefUpdates=always creates no reflog for ORIG_HEAD' ' +test_expect_success 'core.logAllRefUpdates=always creates reflog for ORIG_HEAD' ' test_config core.logAllRefUpdates always && git update-ref ORIG_HEAD $A && - test_must_fail git reflog exists ORIG_HEAD + git reflog exists ORIG_HEAD ' test_expect_success '--no-create-reflog overrides core.logAllRefUpdates=always' ' @@ -476,7 +476,7 @@ test_expect_success 'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER test_expect_success 'given old value for missing pseudoref, do not create' ' test_must_fail git update-ref PSEUDOREF $A $B 2>err && test_must_fail git rev-parse PSEUDOREF && - test_i18ngrep "could not read ref" err + test_i18ngrep "unable to resolve reference" err ' test_expect_success 'create pseudoref' ' @@ -497,7 +497,7 @@ test_expect_success 'overwrite pseudoref with correct old value' ' test_expect_success 'do not overwrite pseudoref with wrong old value' ' test_must_fail git update-ref PSEUDOREF $D $E 2>err && test $C = $(git rev-parse PSEUDOREF) && - test_i18ngrep "unexpected object ID" err + test_i18ngrep "cannot lock ref.*expected" err ' test_expect_success 'delete pseudoref' ' @@ -509,7 +509,7 @@ test_expect_success 'do not delete pseudoref with wrong old value' ' git update-ref PSEUDOREF $A && test_must_fail git update-ref -d PSEUDOREF $B 2>err && test $A = $(git rev-parse PSEUDOREF) && - test_i18ngrep "unexpected object ID" err + test_i18ngrep "cannot lock ref.*expected" err ' test_expect_success 'delete pseudoref with correct old value' ' diff --git a/t/t1405-main-ref-store.sh b/t/t1405-main-ref-store.sh index 331899ddc4..a8d695cd4f 100755 --- a/t/t1405-main-ref-store.sh +++ b/t/t1405-main-ref-store.sh @@ -31,9 +31,12 @@ test_expect_success 'create_symref(FOO, refs/heads/master)' ' test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' ' git rev-parse FOO -- && git rev-parse refs/tags/new-tag -- && + m=$(git rev-parse master) && $RUN delete-refs 0 nothing FOO refs/tags/new-tag && test_must_fail git rev-parse FOO -- && - test_must_fail git rev-parse refs/tags/new-tag -- + test_must_fail git rev-parse refs/tags/new-tag --&& + test_must_fail git rev-parse master -- && + git update-ref refs/heads/master $m ' test_expect_success 'rename_refs(master, new-master)' ' From patchwork Thu Jul 9 21:11:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Peterson via GitGitGadget X-Patchwork-Id: 11655125 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 CDF8B14F6 for ; Thu, 9 Jul 2020 21:11:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B206F20672 for ; Thu, 9 Jul 2020 21:11:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ANI4oEMo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726496AbgGIVL4 (ORCPT ); Thu, 9 Jul 2020 17:11:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726269AbgGIVLx (ORCPT ); Thu, 9 Jul 2020 17:11:53 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE78FC08C5DC for ; Thu, 9 Jul 2020 14:11:52 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id a6so3807263wrm.4 for ; Thu, 09 Jul 2020 14:11:52 -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=dqiBREn1JkCHHo274rBaLgYRiUYsSP4+AcndhNbv6/c=; b=ANI4oEMoH9RTvecQhxx22vYA1heAd+YfWYkdgRF7TR9n8HR2T8O1s8AFHqFBNTgiCv g0lwFye2So3vSuB8FIWF6DHwlurYYZo6QgkJ1pXO2597ZynqNweHizG/PHhMfOw4e3LI oOsD+uDZwES/b4E1fHc+BgI0BBknrCLHOSTQPxH87cJIxR03pPnPuRichgEdikHiR5bD 41jV3ebSn7GRUg/QWjfEozWUs9ZQw/wonaaHe8YIJQFT+oFR0BwJrEHyNRq/0fD4MYpy RIwhdHfQUyDgQXlp5twt+B2Ts92XW7go2bM6p2uP0Ypy6TAI/3PDtf+IjS5xNbtmBMM2 cOJQ== 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=dqiBREn1JkCHHo274rBaLgYRiUYsSP4+AcndhNbv6/c=; b=Iz/0zdk7f3buuE7YCPw9RIMPNAoqHbsRfVWlYkpWAZV795ipkbRlLgJiKwjnkV7ZPJ BJPioIAHrhywd8Uqa20Tlv9pI0eoMucICIUF05WCCIStPTT8jR5V8WT3aoGsLkmyN80i y/tqez9uiZ4aiu+wbZx2+6BG5Y7VjKQlmK3GuxkZYRGb62qOBVLfbkTszg6K2yAZ6nQh 0yH/6WxJPTxnwbuy6wT8qPAMkLf5VVxEeLeV54wWNevSbGgN7DVJN6IC+5ABHQbw1oVJ kUpdNfu/5uDFzpk2OBEHedwg8yEZHVp2Wj26GU55sjSG6DLQmJUuojKGwvTfteSlNV60 OqEg== X-Gm-Message-State: AOAM533ZF42j7AkZ7fEdImk7/54tLm1OeBxMVRtwj7Ht7/qiwrP2aBKC gufzHDoQm4YD7kv1VqKY7Zovju0z X-Google-Smtp-Source: ABdhPJzB5qO+YKNI6U6tfpeRgQZNUyI9N+6pJzR5KEFU3LvyQ/ooU7o59jfV6Uzu+cseAPke/+Xlmg== X-Received: by 2002:adf:8462:: with SMTP id 89mr63871864wrf.420.1594329111502; Thu, 09 Jul 2020 14:11:51 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b184sm6773920wmc.20.2020.07.09.14.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2020 14:11:51 -0700 (PDT) Message-Id: <1c2b9d5f177ab5ebf4d45ce77ebe8e6cec78c3a6.1594329108.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Thu, 09 Jul 2020 21:11:48 +0000 Subject: [PATCH v2 3/3] Make HEAD a PSEUDOREF rather than PER_WORKTREE. 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 is consistent with the definition of REF_TYPE_PSEUDOREF (uppercase in the root ref namespace). Signed-off-by: Han-Wen Nienhuys --- refs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/refs.c b/refs.c index d676acb1f4..5cd71f711f 100644 --- a/refs.c +++ b/refs.c @@ -708,10 +708,9 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log) static int is_per_worktree_ref(const char *refname) { - return !strcmp(refname, "HEAD") || - starts_with(refname, "refs/worktree/") || - starts_with(refname, "refs/bisect/") || - starts_with(refname, "refs/rewritten/"); + return starts_with(refname, "refs/worktree/") || + starts_with(refname, "refs/bisect/") || + starts_with(refname, "refs/rewritten/"); } static int is_pseudoref_syntax(const char *refname)