From patchwork Tue Feb 22 00:17:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12754372 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1817DC433EF for ; Tue, 22 Feb 2022 00:18:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237630AbiBVASc (ORCPT ); Mon, 21 Feb 2022 19:18:32 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237601AbiBVASb (ORCPT ); Mon, 21 Feb 2022 19:18:31 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 987C925581 for ; Mon, 21 Feb 2022 16:18:04 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id p184-20020a1c29c1000000b0037f76d8b484so465364wmp.5 for ; Mon, 21 Feb 2022 16:18:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=8jYl8gjf0naJJiVvZzP4wht3NW0AgZiyMz69tEpui/o=; b=JB2oYeTzZ0vKJClshiOCrDpj3Lg5HvmprcDQcvNMxjUNL0HWS76P8x1sez5vdyD2qo tLeYgarrY0plt27pIIKx3D2ZpK5Ke3r/BD2EHESw2aWUPkpnOAaW7q2Pf+ww9Cfonkgn vyzWQ846Y9ixru5cSCrbe5BRCoBsAtroIBZsNQ4diX+GCV3Mlt3hf0CoOCJHEEJvxL0y VkTVEZTUhjuXr97HWK0ru/dRQ1xUJ2ElZgTtlLSXNngAKCB/XQU49bzcpmD8qiX7g4fj DNsRc0jjjmK0/OQm1fAE7rZf6tfstx8h3B2UAPCOm2Jkxp/4Tu+rAsM8xdDc9KbBxCVo g1Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=8jYl8gjf0naJJiVvZzP4wht3NW0AgZiyMz69tEpui/o=; b=EdEdvzpXoG5K74S0zsT+0mx5W3gBCObQiHalOGaviZDqDGzW3j4FQlsmd3tgwjOUy8 ujZoJ5tu3HCMAUyxA/Xyg6vGRnqjiZMX7TDl6a9v2qeBBT6Uxj4FKXxlqzIjQWaW63sV bOlsDzxEbGWdZx1EQLxJSXAgf2l72DmVVxeBZ/qQusgc7QWq6PHP8+P7Cl2icRRXupK4 bjoTr0rWpGe+AZVRrSIsroqUY/KB6pxdssKKHJxbSy3RgcwU+ybumIMaMehLjKFdO+YW zXiZF2ambi32NHcUWdUHO+C6PkGC+kglOXcQ33kXwdQyHuyP/uXctZJrixklL6tmPjDk iuYQ== X-Gm-Message-State: AOAM532x+5Hz6HEBddO11O5UBkTR4lzYC62S6Wr7oJZUvpZINpuyA3/I JRZZK5wNx5PsBf0ui92WeE4hBMR3fAI= X-Google-Smtp-Source: ABdhPJw4ARIBQmFGXE8VUiOBK8vGGccuncvAP2CqWAXK9PmlMik3dhngMbVWq5mAtFkg8IzXwNd85g== X-Received: by 2002:a7b:c19a:0:b0:37b:c68c:7162 with SMTP id y26-20020a7bc19a000000b0037bc68c7162mr1092009wmi.7.1645489082929; Mon, 21 Feb 2022 16:18:02 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c9sm31398959wrn.51.2022.02.21.16.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 16:18:02 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 22 Feb 2022 00:17:50 +0000 Subject: [PATCH v2 01/11] worktree: combine two translatable messages MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: sunshine@sunshineco.com, gitster@pobox.com, newren@gmail.com, jn.avila@free.fr, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee These two messages differ only by the config key name, which should not be translated. Extract those keys so the messages can be translated from the same string. Reported-by: Jean-Noël AVILA Signed-off-by: Derrick Stolee --- builtin/worktree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index c6eb636329a..7c272078dc9 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -384,11 +384,13 @@ static int add_worktree(const char *path, const char *refname, bare && git_config_set_multivar_in_file_gently( to_file, "core.bare", NULL, "true", 0)) - error(_("failed to unset 'core.bare' in '%s'"), to_file); + error(_("failed to unset '%s' in '%s'"), + "core.bare", to_file); if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) && git_config_set_in_file_gently(to_file, "core.worktree", NULL)) - error(_("failed to unset 'core.worktree' in '%s'"), to_file); + error(_("failed to unset '%s' in '%s'"), + "core.worktree", to_file); git_configset_clear(&cs); } From patchwork Tue Feb 22 00:17:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12754374 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95B21C433F5 for ; Tue, 22 Feb 2022 00:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237644AbiBVASe (ORCPT ); Mon, 21 Feb 2022 19:18:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237610AbiBVASb (ORCPT ); Mon, 21 Feb 2022 19:18:31 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EDE125583 for ; Mon, 21 Feb 2022 16:18:05 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id d3so14115663wrf.1 for ; Mon, 21 Feb 2022 16:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=WKsjhKQh9X+EsJy0g/IlxjZL2l4R2BAcspMe0/TGXqM=; b=ceZPFFWcguvSxoRKXjdQRGOxx3HyItdtAoG7A6WPDFrCNMI2Yfl8wMgRUlRZw8pbQ4 /hTqULCqMTYk1Z2xNzs4FS2w9JY7v8DTa74pZZLxj1O7WyjZiDrrzMvPtHc9MaoihL0f 6T72xuMG2JrVirSG8uxf2x12c26T6ZnSESKXpVX9Y+9wmj9zhjMTo6Bpu/qUeBUzOVqB AzX0BEbo2y+Tsbdr7Z3+CDejm1N9rCrBx0XgSC2xbH2d9kK+VdWPHXf3no6qMmPBmuI3 mAZO9kvhbmwD4xEHNjWZB+6w8EnOehmbklJwxpDCsRoaAXe+fvTA9k+HjLSc3yOJdItc ejDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=WKsjhKQh9X+EsJy0g/IlxjZL2l4R2BAcspMe0/TGXqM=; b=Y4KhfEFBLfjQO6PRVJSw/69Zz6SSEriV/4IRXWdHPbPyc80c7ib8BnjekJ+BmRiEIV Ygp3TDrq3lJJJvd30WDXPCXgEYNVHP028nd2JNnelDnIsV5VTitqlgCfM+O+d1UG33Eq OE7lsN1AnETInMEHxGNO8JBZwvcbtyUURFCk64krBZrNmoDMDVhLkyBlJja14wO5sE8y 7O9ffynkf8TJx+4WE5aEJbdTvz1Y/rEbhcgWMpC3RglQlODEdos8JVS016M1DCcou79D gXeOpI7xBMXNcma/CANByvNUGJlYeQFzLX8iIrya1LECFNNZsijpgfLAaMrFqO8cq6zF V8XQ== X-Gm-Message-State: AOAM532MKW1FEivaft7vyLgLmZEbwB+xfqkmgmwVpj3L8/q2zqaFlBxD PiZ1rqqUhEl+KfhskCPdOlx0iHN8dzU= X-Google-Smtp-Source: ABdhPJwbzv02mQbAd8Fwvmu3TsZ+OpL+GcppFbqa29fk2aojTr+xN2jDQOKv+pfSMWhDyEXbNNdzvA== X-Received: by 2002:a5d:6847:0:b0:1dd:f498:d28e with SMTP id o7-20020a5d6847000000b001ddf498d28emr17241276wrw.609.1645489083776; Mon, 21 Feb 2022 16:18:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f10-20020a05600c154a00b0037bbbc15ca7sm1135246wmg.36.2022.02.21.16.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 16:18:03 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 22 Feb 2022 00:17:51 +0000 Subject: [PATCH v2 02/11] worktree: extract copy_filtered_worktree_config() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: sunshine@sunshineco.com, gitster@pobox.com, newren@gmail.com, jn.avila@free.fr, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee This logic was introduced by 5325591 (worktree: copy sparse-checkout patterns and config on add, 2022-02-07), but some feedback came in that the add_worktree() method was already too complex. It is better to extract this logic into a helper method to reduce this complexity. Reported-by: Eric Sunshine Signed-off-by: Derrick Stolee --- builtin/worktree.c | 81 ++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index 7c272078dc9..2771a6dc793 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -236,6 +236,46 @@ static void check_candidate_path(const char *path, die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd); } +static void copy_filtered_worktree_config(const char *worktree_git_dir) +{ + char *from_file = git_pathdup("config.worktree"); + char *to_file = xstrfmt("%s/config.worktree", worktree_git_dir); + + if (file_exists(from_file)) { + struct config_set cs = { { 0 } }; + const char *core_worktree; + int bare; + + if (safe_create_leading_directories(to_file) || + copy_file(to_file, from_file, 0666)) { + error(_("failed to copy worktree config from '%s' to '%s'"), + from_file, to_file); + goto worktree_copy_cleanup; + } + + git_configset_init(&cs); + git_configset_add_file(&cs, from_file); + + if (!git_configset_get_bool(&cs, "core.bare", &bare) && + bare && + git_config_set_multivar_in_file_gently( + to_file, "core.bare", NULL, "true", 0)) + error(_("failed to unset '%s' in '%s'"), + "core.bare", to_file); + if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) && + git_config_set_in_file_gently(to_file, + "core.worktree", NULL)) + error(_("failed to unset '%s' in '%s'"), + "core.worktree", to_file); + + git_configset_clear(&cs); + } + +worktree_copy_cleanup: + free(from_file); + free(to_file); +} + static int add_worktree(const char *path, const char *refname, const struct add_opts *opts) { @@ -360,45 +400,8 @@ static int add_worktree(const char *path, const char *refname, * values from the current worktree into the new one, that way the * new worktree behaves the same as this one. */ - if (repository_format_worktree_config) { - char *from_file = git_pathdup("config.worktree"); - char *to_file = xstrfmt("%s/config.worktree", - sb_repo.buf); - - if (file_exists(from_file)) { - struct config_set cs = { { 0 } }; - const char *core_worktree; - int bare; - - if (safe_create_leading_directories(to_file) || - copy_file(to_file, from_file, 0666)) { - error(_("failed to copy worktree config from '%s' to '%s'"), - from_file, to_file); - goto worktree_copy_cleanup; - } - - git_configset_init(&cs); - git_configset_add_file(&cs, from_file); - - if (!git_configset_get_bool(&cs, "core.bare", &bare) && - bare && - git_config_set_multivar_in_file_gently( - to_file, "core.bare", NULL, "true", 0)) - error(_("failed to unset '%s' in '%s'"), - "core.bare", to_file); - if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) && - git_config_set_in_file_gently(to_file, - "core.worktree", NULL)) - error(_("failed to unset '%s' in '%s'"), - "core.worktree", to_file); - - git_configset_clear(&cs); - } - -worktree_copy_cleanup: - free(from_file); - free(to_file); - } + if (repository_format_worktree_config) + copy_filtered_worktree_config(sb_repo.buf); strvec_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf); strvec_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path); From patchwork Tue Feb 22 00:17:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12754377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03F52C433FE for ; Tue, 22 Feb 2022 00:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237677AbiBVASj (ORCPT ); Mon, 21 Feb 2022 19:18:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237619AbiBVASc (ORCPT ); Mon, 21 Feb 2022 19:18:32 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F8A2558A for ; Mon, 21 Feb 2022 16:18:06 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id d3so14115703wrf.1 for ; Mon, 21 Feb 2022 16:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=M3yfAW+FMygRnAbUO3SWrYQH55uT4SNwhA5DqD8nFTc=; b=n4YOTMiULxqGKriUJ57mKToZ+T2MHBPAAEZDNjcFosD8shmqn/QwEZ75SMtckHfXZ/ 915PuyzaS3tNmDH4zd+BJWljcpDI/jP9m/Gi6SjnKTkovJyWsEMElhh9178N7sVIMRrV tpxaMBy/yaKypIQ/7IsD/X3G/jdu/VQBbXpS5mNk+VglD8lLwYUoZUUlcnU4QAp4Hr2w iaf0i1mB43CRSctLoy4Uk2UE+x8RFsdjIgyO8zhOfZMSaFejd+RILcekaYQORodRgviP IUhliCCbbxgrDsMel6JenI1zm5DGYL+g4oVBGViR+0vde1hiuKNlo2q3gdCH7BYoh0LH Ij7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=M3yfAW+FMygRnAbUO3SWrYQH55uT4SNwhA5DqD8nFTc=; b=K79h8IX2AXHD8XfryPtgA1N6jHg++9TrCIuM7nsiGnA3PTQVA/yEEWQdYqG+yass0a ikZRa+EkW1Y7lOkwalmkqgd8VcYi3giF2zx9CaZFhllN1wr92S64EnrJE1yvcGGncHWr ZaoKvJGFTV8NghpcMTVgjuceIp+uPLuMtc7nPbyZ9tqOjSITD4VH/lz72JDddwoO5x9I DErKj/aB+aU+eAOtsVJk7oXfRcA4uwaAv4P3+AMM6yXyfHLKYAleFUDGHEPD37Ir05gd XyaIH2nqlhq42VVHQsh+TipQ7ZWR5ZU3CvVdUngejq2yS5/HORBW54nvbudoosRj+lzM odFQ== X-Gm-Message-State: AOAM530xc8wFzImW3Vmks5MC4z/IXDCVP4n9jc2inW1Gg3JJphYQoqR3 yz6sEevNRrxwmk3A8Sa4k13/ahh1jTQ= X-Google-Smtp-Source: ABdhPJzMM1ZvEqXuyMnV6CH9hvqb75x0qL1zbjofv937EYnIBfcmKfQEmCj3AfFsh1uJhtSFPOFXRw== X-Received: by 2002:a5d:4c41:0:b0:1e5:1a70:fb86 with SMTP id n1-20020a5d4c41000000b001e51a70fb86mr17187564wrt.452.1645489084522; Mon, 21 Feb 2022 16:18:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z5-20020a05600c0a0500b0037bb8df81a2sm915684wmp.13.2022.02.21.16.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 16:18:04 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 22 Feb 2022 00:17:52 +0000 Subject: [PATCH v2 03/11] worktree: extract copy_sparse_checkout() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: sunshine@sunshineco.com, gitster@pobox.com, newren@gmail.com, jn.avila@free.fr, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee This logic was introduced by 5325591 (worktree: copy sparse-checkout patterns and config on add, 2022-02-07), but some feedback came in that the add_worktree() method was already too complex. It is better to extract this logic into a helper method to reduce this complexity. Reported-by: Eric Sunshine Signed-off-by: Derrick Stolee --- builtin/worktree.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index 2771a6dc793..c806aa2b261 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -236,6 +236,22 @@ static void check_candidate_path(const char *path, die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd); } +static void copy_sparse_checkout(const char *worktree_git_dir) +{ + char *from_file = git_pathdup("info/sparse-checkout"); + char *to_file = xstrfmt("%s/info/sparse-checkout", worktree_git_dir); + + if (file_exists(from_file)) { + if (safe_create_leading_directories(to_file) || + copy_file(to_file, from_file, 0666)) + error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"), + from_file, to_file); + } + + free(from_file); + free(to_file); +} + static void copy_filtered_worktree_config(const char *worktree_git_dir) { char *from_file = git_pathdup("config.worktree"); @@ -379,21 +395,8 @@ static int add_worktree(const char *path, const char *refname, * If the current worktree has sparse-checkout enabled, then copy * the sparse-checkout patterns from the current worktree. */ - if (core_apply_sparse_checkout) { - char *from_file = git_pathdup("info/sparse-checkout"); - char *to_file = xstrfmt("%s/info/sparse-checkout", - sb_repo.buf); - - if (file_exists(from_file)) { - if (safe_create_leading_directories(to_file) || - copy_file(to_file, from_file, 0666)) - error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"), - from_file, to_file); - } - - free(from_file); - free(to_file); - } + if (core_apply_sparse_checkout) + copy_sparse_checkout(sb_repo.buf); /* * If we are using worktree config, then copy all current config From patchwork Tue Feb 22 00:17:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12754375 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3127C433FE for ; Tue, 22 Feb 2022 00:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237659AbiBVASg (ORCPT ); Mon, 21 Feb 2022 19:18:36 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237609AbiBVASb (ORCPT ); Mon, 21 Feb 2022 19:18:31 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C443D25593 for ; Mon, 21 Feb 2022 16:18:06 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id az26-20020a05600c601a00b0037c078db59cso467255wmb.4 for ; Mon, 21 Feb 2022 16:18:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=IEwQOKVfS1z3z4RURBKjrMl0ojCq6mcDnKEPehPFfRg=; b=L63cAZC7OkPKPWWqh6GKWFhuNG+im/kQ1N/dg6Yn3ipCFm5uGnt1V6ipe+qLyJ9Aq/ lhGj1Iok5A03iYYrG5cw4IFxP+rByt1YaNuqKv4AevzdbbDqOn43iEKBZnDfBED3ex2E p1xbUOutXRlAWZLLE2ABjrS+6c+fbpAppPOKQmCTPrEAckI5khnb8gNRgJBiPtG979ZV og5jjmlzQETixAhRzyyM+u54lcHu/eEvMV34Q8YvMI/0V/qkah6qzQMnns46CzNluFnH BelJ8Tk57cPCpUXUigh8Tzx/DQDvfukVW4/CD6OQaTL0bGZDp4nbL9Lvp696pnn86YS0 nlIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=IEwQOKVfS1z3z4RURBKjrMl0ojCq6mcDnKEPehPFfRg=; b=ZQ49CKNCJHiRlRuD6/OxOO+yFKi9Fpi9vGKHEejA3VVONJI6qMgPb6qBwOCitoIDCH V/YZWNvlQlW5DoL9IFUfWLuQJPOXcojGBGUcJX01jNQSneIYK3CO6XEf6lIavEAEqu9e uP2LmkTa30h2ZfTLi/OAYmDkF6Hlcouj01e/WdpEjlIvuv4muctp31JIRniMJySs+Urw oH6Pr7C/1BY6t6Lu2u3yglYvSmyNXl47773MGLcJL5gHq6ZN3ceH6cV1htU5tpBtbXzx cJVxR19Xzfw8if6UoXrUNwvzEaSauvIzJGX4jrNQ6KngxoQaK1eHqIUOToiAO2OMAfN+ Nb7A== X-Gm-Message-State: AOAM533Cdonp8aKYX2MN2fucO0hfuvWe7fh2JbAjIGBGOqTrxJIjNCts zlgQOS9vu1CV7efY2NfUtuGwEYZo8LI= X-Google-Smtp-Source: ABdhPJwclWutvMOPO8h8Hw8w61qE898elkFheBhPLhrb/Yv37Fog28ocvfXToQMKiXcjtAC9V8Q1yA== X-Received: by 2002:a7b:c5d1:0:b0:37f:a8a3:9e17 with SMTP id n17-20020a7bc5d1000000b0037fa8a39e17mr1125575wmk.109.1645489085260; Mon, 21 Feb 2022 16:18:05 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x10sm15382739wre.110.2022.02.21.16.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 16:18:04 -0800 (PST) Message-Id: <1e62e4e4fa1a543ad134d70d97740cac5826e587.1645489080.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 22 Feb 2022 00:17:53 +0000 Subject: [PATCH v2 04/11] worktree: extract checkout_worktree() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: sunshine@sunshineco.com, gitster@pobox.com, newren@gmail.com, jn.avila@free.fr, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee The ability to add the --no-checkout flag to 'git worktree' was added in ef2a0ac9a0 (worktree: add: introduce --checkout option, 2016-03-29). Recently, we noticed that add_worktree() is rather complicated, so extract the logic for this checkout process to simplify the method. Signed-off-by: Derrick Stolee --- builtin/worktree.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index c806aa2b261..25807e63a25 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -292,6 +292,18 @@ worktree_copy_cleanup: free(to_file); } +static int checkout_worktree(const struct add_opts *opts, + struct strvec *child_env) +{ + struct child_process cp = CHILD_PROCESS_INIT; + cp.git_cmd = 1; + strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL); + if (opts->quiet) + strvec_push(&cp.args, "--quiet"); + strvec_pushv(&cp.env_array, child_env->v); + return run_command(&cp); +} + static int add_worktree(const char *path, const char *refname, const struct add_opts *opts) { @@ -425,17 +437,9 @@ static int add_worktree(const char *path, const char *refname, if (ret) goto done; - if (opts->checkout) { - struct child_process cp = CHILD_PROCESS_INIT; - cp.git_cmd = 1; - strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL); - if (opts->quiet) - strvec_push(&cp.args, "--quiet"); - strvec_pushv(&cp.env_array, child_env.v); - ret = run_command(&cp); - if (ret) - goto done; - } + if (opts->checkout && + (ret = checkout_worktree(opts, &child_env))) + goto done; is_junk = 0; FREE_AND_NULL(junk_work_tree); From patchwork Tue Feb 22 00:17:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12754376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FF8FC433F5 for ; Tue, 22 Feb 2022 00:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237670AbiBVASh (ORCPT ); Mon, 21 Feb 2022 19:18:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237617AbiBVASc (ORCPT ); Mon, 21 Feb 2022 19:18:32 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8578725594 for ; Mon, 21 Feb 2022 16:18:07 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id s1so3338133wrg.10 for ; Mon, 21 Feb 2022 16:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=G3FbLFEqO3aEUBUJI2bH5XLPGjurAqgIMRRvIVHdmIk=; b=Lz5kR4SuBhHxas1zlU88iY3gnQHGn2dZMTGY40ikvKVuP1RY2qBtrDWJJZ2RXYKef8 8FCIO6xhhIUto0N4NNczFlofWvVKfTzbfoHicI3sBXHnEyi8zy7JYLu+HduP2F/k+4y3 G8rmXsV2DqlvvoyvSHzp9votbyVUhdJNMZx1RhTudxSq8nBTzragPBt6c67aZZx9LLFQ hK/p1Sb/efRF6E18L1UrGtUT4jbao2UYcllyBW5Xw4MMQ3B/xhmz2kHmCpS09H5n/nj2 kx7nFQp7ihfCC/efBKDn/nZL1LY6+8lgmLdOkS+D1WeSiLM5jmOnVrfz8dybA2ETiANE ZVkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=G3FbLFEqO3aEUBUJI2bH5XLPGjurAqgIMRRvIVHdmIk=; b=oait2+pijO/aPCEFH1K5/E1KAzO0LuxXqfqkRaJXZIP9DIYiyIXbe6zTRz/uYnkw6H BC+aJg8unildtkmhSDmTMpBRk9d8fGo63CHgER573qqucZUajg8loaF4AHOOrydWLCk6 yUymPUhuPocuztblaY9uC2NDDGxesn5zfWySfL2QmQ5uaGvBIMWFYsP2no3HASUc5zHE saeoGIo4xohWEvOKftGrHBeWz8Zf7ROmNYTWRRS2wY4awlsSWuSKBnah7WsnHbppQmEv s7qSdGaEvFnpzWuohSLVpsaxkzrUkGT7yAI4GWAA0BfabIglDyUW2nQnSSaiSmKVMcIu UkDg== X-Gm-Message-State: AOAM532+FJY9uc1OJ0YySuQWKoviYWinSqU7KNfjPUqX43+KfhzJx+sR n1SwOWZOiCoDmqjqNRAg2+9gLCZp/U8= X-Google-Smtp-Source: ABdhPJx6VpdKVrxI+odSk9ykcXmazZ7DtEQjlOWGKJPVqRA7ij/xOOFMt4iFKdZPtdgtT8YUfYfC+w== X-Received: by 2002:adf:f0c6:0:b0:1e7:13f7:74b9 with SMTP id x6-20020adff0c6000000b001e713f774b9mr17269610wro.361.1645489085929; Mon, 21 Feb 2022 16:18:05 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h7sm32996565wru.41.2022.02.21.16.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 16:18:05 -0800 (PST) Message-Id: <2801ae232ae5cd0aa431e90eb37bbaf765d64fa5.1645489080.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 22 Feb 2022 00:17:54 +0000 Subject: [PATCH v2 05/11] worktree: use 'worktree' over 'working tree' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: sunshine@sunshineco.com, gitster@pobox.com, newren@gmail.com, jn.avila@free.fr, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee It is helpful to distinguish between a 'working tree' and a 'worktree'. A worktree contains a working tree plus additional metadata. This metadata includes per-worktree refs and worktree-specific config. This is the first of multiple changes to git-worktree.txt, restricted to the DESCRIPTION section. Helped-by: Junio C Hamano Signed-off-by: Derrick Stolee --- Documentation/git-worktree.txt | 50 ++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index b8d53c48303..27437615436 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -25,45 +25,49 @@ Manage multiple working trees attached to the same repository. A git repository can support multiple working trees, allowing you to check out more than one branch at a time. With `git worktree add` a new working -tree is associated with the repository. This new working tree is called a -"linked working tree" as opposed to the "main working tree" prepared by -linkgit:git-init[1] or linkgit:git-clone[1]. -A repository has one main working tree (if it's not a -bare repository) and zero or more linked working trees. When you are done -with a linked working tree, remove it with `git worktree remove`. +tree is associated with the repository, along with additional metadata +that differentiates that working tree from others in the same repository. +The working tree, along with this metada, is called a "worktree". + +This new worktree is called a "linked worktree" as opposed to the "main +worktree" prepared by linkgit:git-init[1] or linkgit:git-clone[1]. +A repository has one main worktree (if it's not a bare repository) and +zero or more linked worktrees. When you are done with a linked worktree, +remove it with `git worktree remove`. In its simplest form, `git worktree add ` automatically creates a new branch whose name is the final component of ``, which is convenient if you plan to work on a new topic. For instance, `git worktree add ../hotfix` creates new branch `hotfix` and checks it out at -path `../hotfix`. To instead work on an existing branch in a new working -tree, use `git worktree add `. On the other hand, if you -just plan to make some experimental changes or do testing without -disturbing existing development, it is often convenient to create a -'throwaway' working tree not associated with any branch. For instance, -`git worktree add -d ` creates a new working tree with a detached -`HEAD` at the same commit as the current branch. +path `../hotfix`. To instead work on an existing branch in a new worktree, +use `git worktree add `. On the other hand, if you just +plan to make some experimental changes or do testing without disturbing +existing development, it is often convenient to create a 'throwaway' +worktree not associated with any branch. For instance, +`git worktree add -d ` creates a new worktree with a detached `HEAD` +at the same commit as the current branch. If a working tree is deleted without using `git worktree remove`, then its associated administrative files, which reside in the repository (see "DETAILS" below), will eventually be removed automatically (see `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run -`git worktree prune` in the main or any linked working tree to -clean up any stale administrative files. +`git worktree prune` in the main or any linked worktree to clean up any +stale administrative files. -If a linked working tree is stored on a portable device or network share -which is not always mounted, you can prevent its administrative files from -being pruned by issuing the `git worktree lock` command, optionally -specifying `--reason` to explain why the working tree is locked. +If the working tree for a a linked worktree is stored on a portable device +or network share which is not always mounted, you can prevent its +administrative files from being pruned by issuing the `git worktree lock` +command, optionally specifying `--reason` to explain why the worktree is +locked. COMMANDS -------- add []:: -Create `` and checkout `` into it. The new working directory -is linked to the current repository, sharing everything except working -directory specific files such as `HEAD`, `index`, etc. As a convenience, -`` may be a bare "`-`", which is synonymous with `@{-1}`. +Create a worktree at `` and checkout `` into it. The new worktree +is linked to the current repository, sharing everything except per-worktree +files such as `HEAD`, `index`, etc. As a convenience, `` may +be a bare "`-`", which is synonymous with `@{-1}`. + If `` is a branch name (call it ``) and is not found, and neither `-b` nor `-B` nor `--detach` are used, but there does From patchwork Tue Feb 22 00:17:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12754378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76874C433EF for ; Tue, 22 Feb 2022 00:18:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237680AbiBVASk (ORCPT ); Mon, 21 Feb 2022 19:18:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237629AbiBVASc (ORCPT ); Mon, 21 Feb 2022 19:18:32 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DDC324BF9 for ; Mon, 21 Feb 2022 16:18:08 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id s13so1208048wrb.6 for ; Mon, 21 Feb 2022 16:18:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=NT9DvlJE+oW0ELFOsGJDmOFgN2zCUOS/DmKMsx8BpMc=; b=YNC8Nj10Ym5MGko5Xhxc9hAgW3hk6s09bxLcFp9MbbUmvGxUQ/GkLUaESKL5OyxPy3 zkufB2q23OmNb0bEWm/QiH65cU5ij+yS32ujqz9zvnpogHhOuUDlkgUThWuxglMx6gtL J/u/EGrixZ/dNx7eHGTUQTunZfiBPBKbxm1DAMtOfPXSd4psLbaCvXkscedwLFtLYpuu lJmbe/9aZVMPkBnC5lfGreIrhc/JRav0ew4Qq1lcJGOhOcA2dxIcbBJKctS5MKrTsGEe Oqk3mVU+8emh5gc73UsbxAzit5xLBIQcnIl4Nof+cIN+ASgYcTBjosPgQKo6KBMktW3B goOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=NT9DvlJE+oW0ELFOsGJDmOFgN2zCUOS/DmKMsx8BpMc=; b=lgGp31ceLWSIUEGXizzMaL/EjH2DN49mF/+0w/gYxOUzBqlmDFCG0mwqc69SlsE7Zn h6b2a9UBQqebpBhYZniwDv3FomSbFHDeQpVZ5M/BYfUNXiBOukvs2FZqKK20d1k+UniG JVN8LrnnNvDoT2XYImVKtim5YlU4v4BrrqSNPn5H4BUGIEaoLKjtVyvEA/J2zeECYalR /K2x3nhS+9bfHdUIYguVm59BBn9ls2slEqF4bd665tmUn8cVcOZC2kLwyXyyIhbMXGES lrH+n0yngfQRxuusZmDm2bYqFOy2dgOBvoXBIUFw7t417NMnV2AWOLyiPl+63kMIpTYw +fLA== X-Gm-Message-State: AOAM53231BYdMUNmXRU+mGGY3ZFDkQ2F9TXj+jmo5OaDBqU2JeMuHe1Z zivY4jtZmY96nLtDci4zxDjZweUbIgM= X-Google-Smtp-Source: ABdhPJxwD0exh41aVOMkdG2Ibq3fUtYwOLrG8O2TIytXgL0Q5wKhEAZbtw6qdNjktzW37QsoyVHTbQ== X-Received: by 2002:adf:f748:0:b0:1e4:a5c0:d783 with SMTP id z8-20020adff748000000b001e4a5c0d783mr17578677wrp.91.1645489086734; Mon, 21 Feb 2022 16:18:06 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z3sm866917wmp.42.2022.02.21.16.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 16:18:06 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 22 Feb 2022 00:17:55 +0000 Subject: [PATCH v2 06/11] worktree: use 'worktree' over 'working tree' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: sunshine@sunshineco.com, gitster@pobox.com, newren@gmail.com, jn.avila@free.fr, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee It is helpful to distinguish between a 'working tree' and a 'worktree'. A worktree contains a working tree plus additional metadata. This metadata includes per-worktree refs and worktree-specific config. This is the second of multiple changes to git-worktree.txt, restricted to the COMMANDS section. There is some language around the movement of "the working tree of a linked worktree" which is used once, but the remaining uses are left as just moving "a linked worktree" for brevity. Helped-by: Junio C Hamano Signed-off-by: Derrick Stolee --- Documentation/git-worktree.txt | 85 ++++++++++++++++------------------ 1 file changed, 41 insertions(+), 44 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 27437615436..00edf343610 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -88,75 +88,72 @@ branches from there if `` is ambiguous but exists on the linkgit:git-config[1]. + If `` is omitted and neither `-b` nor `-B` nor `--detach` used, -then, as a convenience, the new working tree is associated with a branch -(call it ``) named after `$(basename )`. If `` -doesn't exist, a new branch based on `HEAD` is automatically created as -if `-b ` was given. If `` does exist, it will be -checked out in the new working tree, if it's not checked out anywhere -else, otherwise the command will refuse to create the working tree (unless -`--force` is used). +then, as a convenience, the new worktree is associated with a branch (call +it ``) named after `$(basename )`. If `` doesn't +exist, a new branch based on `HEAD` is automatically created as if +`-b ` was given. If `` does exist, it will be checked out +in the new worktree, if it's not checked out anywhere else, otherwise the +command will refuse to create the worktree (unless `--force` is used). list:: -List details of each working tree. The main working tree is listed first, -followed by each of the linked working trees. The output details include -whether the working tree is bare, the revision currently checked out, the +List details of each worktree. The main worktree is listed first, +followed by each of the linked worktrees. The output details include +whether the worktree is bare, the revision currently checked out, the branch currently checked out (or "detached HEAD" if none), "locked" if -the worktree is locked, "prunable" if the worktree can be pruned by `prune` -command. +the worktree is locked, "prunable" if the worktree can be pruned by the +`prune` command. lock:: -If a working tree is on a portable device or network share which -is not always mounted, lock it to prevent its administrative -files from being pruned automatically. This also prevents it from -being moved or deleted. Optionally, specify a reason for the lock -with `--reason`. +If a worktree is on a portable device or network share which is not always +mounted, lock it to prevent its administrative files from being pruned +automatically. This also prevents it from being moved or deleted. +Optionally, specify a reason for the lock with `--reason`. move:: -Move a working tree to a new location. Note that the main working tree -or linked working trees containing submodules cannot be moved with this -command. (The `git worktree repair` command, however, can reestablish -the connection with linked working trees if you move the main working -tree manually.) +Move a worktree to a new location. Note that the main worktree or linked +worktrees containing submodules cannot be moved with this command. (The +`git worktree repair` command, however, can reestablish the connection +with linked worktrees if you move the main worktree manually.) prune:: -Prune working tree information in `$GIT_DIR/worktrees`. +Prune worktree information in `$GIT_DIR/worktrees`. remove:: -Remove a working tree. Only clean working trees (no untracked files -and no modification in tracked files) can be removed. Unclean working -trees or ones with submodules can be removed with `--force`. The main -working tree cannot be removed. +Remove a worktree. Only clean worktrees (no untracked files and no +modification in tracked files) can be removed. Unclean worktrees or ones +with submodules can be removed with `--force`. The main worktree cannot be +removed. repair [...]:: -Repair working tree administrative files, if possible, if they have -become corrupted or outdated due to external factors. +Repair worktree administrative files, if possible, if they have become +corrupted or outdated due to external factors. + -For instance, if the main working tree (or bare repository) is moved, -linked working trees will be unable to locate it. Running `repair` in -the main working tree will reestablish the connection from linked -working trees back to the main working tree. +For instance, if the main worktree (or bare repository) is moved, linked +worktrees will be unable to locate it. Running `repair` in the main +worktree will reestablish the connection from linked worktrees back to the +main worktree. + -Similarly, if a linked working tree is moved without using `git worktree -move`, the main working tree (or bare repository) will be unable to -locate it. Running `repair` within the recently-moved working tree will -reestablish the connection. If multiple linked working trees are moved, -running `repair` from any working tree with each tree's new `` as -an argument, will reestablish the connection to all the specified paths. +Similarly, if the working directory for a linked worktree is moved without +using `git worktree move`, the main worktree (or bare repository) will be +unable to locate it. Running `repair` within the recently-moved worktree +will reestablish the connection. If multiple linked worktrees are moved, +running `repair` from any worktree with each tree's new `` as an +argument, will reestablish the connection to all the specified paths. + -If both the main working tree and linked working trees have been moved -manually, then running `repair` in the main working tree and specifying the -new `` of each linked working tree will reestablish all connections -in both directions. +If both the main worktree and linked worktrees have been moved manually, +then running `repair` in the main worktree and specifying the new `` +of each linked worktree will reestablish all connections in both +directions. unlock:: -Unlock a working tree, allowing it to be pruned, moved or deleted. +Unlock a worktree, allowing it to be pruned, moved or deleted. OPTIONS ------- From patchwork Tue Feb 22 00:17:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12754379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98CE5C4332F for ; Tue, 22 Feb 2022 00:18:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237686AbiBVASk (ORCPT ); Mon, 21 Feb 2022 19:18:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237632AbiBVASd (ORCPT ); Mon, 21 Feb 2022 19:18:33 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03C6925581 for ; Mon, 21 Feb 2022 16:18:09 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id u1so29737726wrg.11 for ; Mon, 21 Feb 2022 16:18:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=hrlmiApyqNDFMdN5yr+/7ShYPjSY4TX/K8+UbrnSPtY=; b=YfFsrZ94yO+EmxHrQpC9PBGn/m6NdZVuvygBEKBf4glBX5cVKQpfJIRvYkluD0FYOj TEZjxISNCluP+YhL1/zPIktYoysedq1XnUBaXh/Pue2WG5ThlSvrkd8euByOl0ZmcxIe RCL6DM/9g1zsdb8V3tumNonJiHiZ1nFa2sKCFry/oIRVNCvnnfxvyp+fV3cKMTX/WyPv d+ZSg3EM4ZvEXptGZ1yVze3lgv3czaaLcEw77yL9GTw2ucVOpCCx9aVqnWJrDXO0Eqzk N5bEHz1de6Qe0+zqIeMoFp6v3r9W/Dw0we1LZq0ZN0R7+a2jofDH9i0pAlj6BkDG2Gkg EV2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=hrlmiApyqNDFMdN5yr+/7ShYPjSY4TX/K8+UbrnSPtY=; b=HPlKF0h5utB/p8Grt407n8BmIHSVNBu/kjTFmsmjveLf2zf2nC5TxH33n6QtDd7BQK UL7hu1X47Gf0bbn6dgVqVnh3fTtbYMHdvbZnZAmWvKUaKRnrbp7sGU25SHnaWTDOs+6e trccmja3OyWEdczWPGMLPp047jZ+NWF1xnSiS9GereQFtsceRsP0amvNXifXSxaXrMLd dH7FI4q4xwDIiuqaf3S18f8EYNtvjdOc69ivFsSJfX3p+N2V7f0pZIq0c0nqXXUhjWwj PffqBPo7c62VG89Ytaouw4+Ui6jOZ8EiwaoyjnAw6bv/YZnMXO7lgF+umK14w53VxWHP A8Zw== X-Gm-Message-State: AOAM5330dWcSLu5zByxuq3OsDr8eHwysDV+skU4ndcmmxq1HGTapC/k+ ODr/tC0wCz65jxi728pA117G7vFsR2k= X-Google-Smtp-Source: ABdhPJyV2Gsj5A53jMYKddovqPrTPtOCbiLSBSxQiULtZaAG+MKQaA19fAshn528T6P8TNqlCRtMSQ== X-Received: by 2002:adf:df86:0:b0:1e3:126f:440c with SMTP id z6-20020adfdf86000000b001e3126f440cmr17568740wrl.140.1645489087433; Mon, 21 Feb 2022 16:18:07 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c4sm32502332wri.22.2022.02.21.16.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 16:18:07 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 22 Feb 2022 00:17:56 +0000 Subject: [PATCH v2 07/11] worktree: use 'worktree' over 'working tree' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: sunshine@sunshineco.com, gitster@pobox.com, newren@gmail.com, jn.avila@free.fr, Taylor Blau , Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee It is helpful to distinguish between a 'working tree' and a 'worktree'. A worktree contains a working tree plus additional metadata. This metadata includes per-worktree refs and worktree-specific config. This is the third of multiple changes to git-worktree.txt, restricted to the OPTIONS section. Signed-off-by: Derrick Stolee --- Documentation/git-worktree.txt | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 00edf343610..358325ac073 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -160,25 +160,25 @@ OPTIONS -f:: --force:: - By default, `add` refuses to create a new working tree when + By default, `add` refuses to create a new worktree when `` is a branch name and is already checked out by - another working tree, or if `` is already assigned to some - working tree but is missing (for instance, if `` was deleted + another worktree, or if `` is already assigned to some + worktree but is missing (for instance, if `` was deleted manually). This option overrides these safeguards. To add a missing but - locked working tree path, specify `--force` twice. + locked worktree path, specify `--force` twice. + -`move` refuses to move a locked working tree unless `--force` is specified -twice. If the destination is already assigned to some other working tree but is +`move` refuses to move a locked worktree unless `--force` is specified +twice. If the destination is already assigned to some other worktree but is missing (for instance, if `` was deleted manually), then `--force` allows the move to proceed; use `--force` twice if the destination is locked. + -`remove` refuses to remove an unclean working tree unless `--force` is used. -To remove a locked working tree, specify `--force` twice. +`remove` refuses to remove an unclean worktree unless `--force` is used. +To remove a locked worktree, specify `--force` twice. -b :: -B :: With `add`, create a new branch named `` starting at - ``, and check out `` into the new working tree. + ``, and check out `` into the new worktree. If `` is omitted, it defaults to `HEAD`. By default, `-b` refuses to create a new branch if it already exists. `-B` overrides this safeguard, resetting `` to @@ -186,7 +186,7 @@ To remove a locked working tree, specify `--force` twice. -d:: --detach:: - With `add`, detach `HEAD` in the new working tree. See "DETACHED HEAD" + With `add`, detach `HEAD` in the new worktree. See "DETACHED HEAD" in linkgit:git-checkout[1]. --[no-]checkout:: @@ -212,7 +212,7 @@ This can also be set up as the default behaviour by using the `--track` in linkgit:git-branch[1] for details. --lock:: - Keep the working tree locked after creation. This is the + Keep the worktree locked after creation. This is the equivalent of `git worktree lock` after `git worktree add`, but without a race condition. @@ -237,22 +237,22 @@ This can also be set up as the default behaviour by using the With `list`, output additional information about worktrees (see below). --expire