From patchwork Thu Jul 16 18:45:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 11668303 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 A443613B6 for ; Thu, 16 Jul 2020 18:45:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A15C20809 for ; Thu, 16 Jul 2020 18:45:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O/SPZE28" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729296AbgGPSpq (ORCPT ); Thu, 16 Jul 2020 14:45:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726986AbgGPSpp (ORCPT ); Thu, 16 Jul 2020 14:45:45 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 609FCC061755 for ; Thu, 16 Jul 2020 11:45:45 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id g10so5908750wmc.1 for ; Thu, 16 Jul 2020 11:45:45 -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=O/SPZE28uJOv4UZayljJ40fQTyQUGinTgJRoI30BSxFH3ONFNH91UBIiMmSiEiukQM JdOiv4m1PYnHAnvc+iMPj3Z6SGXvnvtlTiGuK4L08iP8zJFuCmdHk7KFwcKt1SkAp5It ZpjS1G6keZFAo4NfZ5QC++MdaCTXVfS8Grdp/+B9MYGyHkjKwJDurUGGcreTUqITh10J Cfet8SlbZNulvkad7d47dOp1vCct/g+BQ6QXPAvsg8ZbFzRd8Mt7bjNw1nYXbeXtgeDq 0eGLLHXMBje8lz9dgVfIIRjV0MWXtPbNQ134LqeWfk83PQIbsijTqu+LceJ0bhGnG5F5 Bbvw== 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=fPgri29RYHEH0RUFixDMoH2UHtEe6Z0zOya4Ok2VlgvDxSC1fjTo3ULjQFKGHDs2uZ 9NfzopslmNlY6/JDogXd7Gpdug2kOnz+q050ph632C0VKfoBBtURtnYkg6MlnzlutJ6J H/dci54E7gZuUrzFw4eVk+vUyoUJ0mFZ4psIJrY1+olBZ1asZQGXvBLyUIYXmp+4atms ne5DQQCB74VEAT1Dhwu7BbAcgBVvi2DvK04wSdcf8NdpxWSfU2Jt01JUORVeGTx3qm5S JwihfEKy3fmg/TGKevSZtVfeLF5pdmgFNi/3HzN6NkUHK/TfLjPuCqY2XWfI9cl9+Uun Qq0A== X-Gm-Message-State: AOAM530eKNFEMQHYwx8S+qDHJ4KGe9b4mY4MdEu7x5rL68FmwuRheTc/ q4EnKn85dgRpc5xaN+pme5bcqu/E X-Google-Smtp-Source: ABdhPJz99VWXn7TOwhsUIF3CL+SjZFjYH/ThLZ02OrxWrtg+jH16OX39arcw6ME/9FaaKWS6QVaTAg== X-Received: by 2002:a05:600c:2202:: with SMTP id z2mr5811725wml.13.1594925143468; Thu, 16 Jul 2020 11:45:43 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f15sm9402798wmj.44.2020.07.16.11.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 11:45:43 -0700 (PDT) Message-Id: <28bd3534d02b7384daf87fb89eb56909883ebec7.1594925141.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Thu, 16 Jul 2020 18:45:39 +0000 Subject: [PATCH v3 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 16 18:45:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 11668305 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 4B2CF161F for ; Thu, 16 Jul 2020 18:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22F7E20809 for ; Thu, 16 Jul 2020 18:45:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ue4gfJUJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729364AbgGPSps (ORCPT ); Thu, 16 Jul 2020 14:45:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729266AbgGPSpq (ORCPT ); Thu, 16 Jul 2020 14:45:46 -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 1BC57C08C5C0 for ; Thu, 16 Jul 2020 11:45:46 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id o11so8136097wrv.9 for ; Thu, 16 Jul 2020 11:45:46 -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=n2gPO7GdyilwpZ+StCNh0Wc6vWKegCa2Ei2TAGhVmxg=; b=ue4gfJUJ9ncO2c972rUJqOS2YSGnujhj57w9Qfe4XugUDDFlT3IAsDc9Ka/r8KvU5K ouJCbH2i0dF3BU1VXMCyYBkP23+imz2oIvJ5UzfIgp1Ds/DsPPF1S4JYtFAoF6qWjAQF RHRDbXaCoig33isfMOHNieGH3RtFk2Oqfxpm7bYdYiXXQMtFE+xM3wfYLndVUP7r3FvM r8pSRZRLQM4ZXZ9SjsQK9y9Q+BVD3PdCaF82CySdaLm3860RUn5VPzZwdgZbGWwRAj0Z sjRtGjWfsykrtmh1gebMwIpOGwW1rw4Q/tcg7xxGaQH26IX4narKAkxPyFRCSxtSVhTq zwoQ== 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=n2gPO7GdyilwpZ+StCNh0Wc6vWKegCa2Ei2TAGhVmxg=; b=W2IKPMoyViKNUKADBkHGYXKBsczOmPmvegDWyRw79eKqe6f1n72Te/p9y5GjLVzcTY fpnDrimsUOl7irsRGrhYQr+RoZk7iqP/eMZRnJ5nh+DqLLtRvAXW/K1NpV+/fv04Vf+g g9Y1I/5rR6Paa/SniYCd6/dJ1dwA62/wFYOHbASRzHDdhQ4K0rC1mVFLDAFHsKop8amT wGpSJi00Kdn43JPZ3WPJepNdEimEm7VV44ljA4A8aUXqgAZv4luFZpfLEnVuGajqHnjp onQGXKq7fQE2QrwHOySOOWe8TEatHXelP7157NmtbGF5l82IxR/5Bp/arNPTybdMbz+o 644Q== X-Gm-Message-State: AOAM533edNHF8NAoavBF5igtjCXgzkFxId7X1uNBYthP81oBO3tf65lw y0GszvILTlXZTVej1xGCuLafN5KV X-Google-Smtp-Source: ABdhPJzdqSh4bVoKC/EoZc+x6X913jkMExEBvNoaY/vD0C8ZyuxTVVVWIqZnN+gOzv6GVxZKY6r3UA== X-Received: by 2002:a5d:4710:: with SMTP id y16mr6448335wrq.189.1594925144401; Thu, 16 Jul 2020 11:45:44 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u17sm10723925wrp.70.2020.07.16.11.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 11:45:43 -0700 (PDT) Message-Id: <79cd5dd480a4218d4563120c03046375594cc23e.1594925141.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Thu, 16 Jul 2020 18:45:40 +0000 Subject: [PATCH v3 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 --- Documentation/git-update-ref.txt | 13 ++-- refs.c | 120 ++----------------------------- t/t1400-update-ref.sh | 10 +-- t/t1405-main-ref-store.sh | 5 +- 4 files changed, 23 insertions(+), 125 deletions(-) diff --git a/Documentation/git-update-ref.txt b/Documentation/git-update-ref.txt index 3e737c2360..d401234b03 100644 --- a/Documentation/git-update-ref.txt +++ b/Documentation/git-update-ref.txt @@ -148,12 +148,13 @@ still see a subset of the modifications. LOGGING UPDATES --------------- -If config parameter "core.logAllRefUpdates" is true and the ref is one under -"refs/heads/", "refs/remotes/", "refs/notes/", or the symbolic ref HEAD; or -the file "$GIT_DIR/logs/" exists then `git update-ref` will append -a line to the log file "$GIT_DIR/logs/" (dereferencing all -symbolic refs before creating the log name) describing the change -in ref value. Log lines are formatted as: +If config parameter "core.logAllRefUpdates" is true and the ref is one +under "refs/heads/", "refs/remotes/", "refs/notes/", or a pseudoref +like HEAD or ORIG_HEAD; or the file "$GIT_DIR/logs/" exists then +`git update-ref` will append a line to the log file +"$GIT_DIR/logs/" (dereferencing all symbolic refs before creating +the log name) describing the change in ref value. Log lines are +formatted as: oldsha1 SP newsha1 SP committer LF 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 16 18:45:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Schindelin via GitGitGadget X-Patchwork-Id: 11668307 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 9ED2117C5 for ; Thu, 16 Jul 2020 18:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82E8620809 for ; Thu, 16 Jul 2020 18:45:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YAmlbHUp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729375AbgGPSpt (ORCPT ); Thu, 16 Jul 2020 14:45:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729339AbgGPSpr (ORCPT ); Thu, 16 Jul 2020 14:45:47 -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 7026FC061755 for ; Thu, 16 Jul 2020 11:45:46 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id s10so8088110wrw.12 for ; Thu, 16 Jul 2020 11:45:46 -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=YAmlbHUpNoggkeqq5gbfziqYEITSPVSr96FFxUq2y/F24KajG0jlIm/2pgJg03hZby nbrFH0cRbUo160S895hHxWktBJOProgLtia9Fp3R+EXPNGtWGs7ViVEIdbQDhLrQLM7t 1nneQ5Wq7B2jvS+OprEgKkohhB2LVECKWzm9Ott4QFFGcnhlXMtEddeH4jW6zkFhUerK 0mXdlEJgcFw0jMCpZImwVub5bdsLf1HQ7Pr2d1jHcFvYybTpgJeA03RNqQIISmB2SAOL LD77mvA9ei7Y2hpsFL7H8Q8/V8VbB0+BF/MVFGLd2to+EPq/8fWcrI0agADuv+3XUh1X FQMw== 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=OOzEWJbLVTIOqKtxSZK+dvDV1gZv/pXs6aVq8Rk3jUfl4PqIA4dLh7B40s6WkutGxJ kCGGltYp/bcZdeOYNbuww0hDNhPjpPV1pw0Y1ORjo9XOf1j04TCZzXvt7IHK345n8FCX yiEKhwsXXDTdlqJlrF1HNtVCnuIc0JMUbAN7e5YZ8hxBLB/gPhE+Of13w5Kt+XzmOQOb 4OKuDIDe3/YdVVgf0WP5VHNjsOKMRqJ7cICoCTz4EVN3TCiMw8tZ2mcCkIkfIcyZaPE0 AsKLPHIgNq3HF0BxJvrbQATKppe4ctXyZs9AqaXUyY4sniKg7kqyiihnsrhR78AMkqiP DeGw== X-Gm-Message-State: AOAM533QkTlErzH+E5Qoa19mRCOG1o89rjZSMpIFePLgE8p8byaO37lp nBK23jtnysIRnfgOx2U0AieQSTQn X-Google-Smtp-Source: ABdhPJzgOXx9cqRfqXHSUz9s7VA2qbVgNIq3VPbRtNXdIMEmCSaU9MJ70o1cA4uPZTTkv8KV34mBVg== X-Received: by 2002:a5d:40c9:: with SMTP id b9mr6037220wrq.425.1594925145074; Thu, 16 Jul 2020 11:45:45 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 68sm9969800wmz.40.2020.07.16.11.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2020 11:45:44 -0700 (PDT) Message-Id: <3ab9f2f04ef35956600a738004780dc0c53d1faa.1594925141.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Han-Wen Nienhuys via GitGitGadget" Date: Thu, 16 Jul 2020 18:45:41 +0000 Subject: [PATCH v3 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)