From patchwork Sun Feb 20 17:54:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12752798 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 49AE7C433F5 for ; Sun, 20 Feb 2022 17:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242127AbiBTRy6 (ORCPT ); Sun, 20 Feb 2022 12:54:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbiBTRyx (ORCPT ); Sun, 20 Feb 2022 12:54:53 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B99527F4 for ; Sun, 20 Feb 2022 09:54:31 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id d27so23279749wrc.6 for ; Sun, 20 Feb 2022 09:54:31 -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=VTGa+RFflIvFU1XkqcBSf9DFyYzlaAUWQ+MfiL8Ns1KbgAmOKznn6NzNf+et7ZJ29+ x36h2eYumbhnjB3vMIlpQWW4ksVO0SRUuIPTtHCNcP+Vxo3J0CwWI4DJXANsiOLGYqNf h/V99NS1ATI/AVL4tZxIvDDZSnygsOJb/oY1baImZgwDVleTAspw/EjytXtDc+zmi3Po NSdrEu/ru+JbQ04VOnyarCgCBMid8iaguXskgE8UKjQ6/HCrk0CZGQa5FqWLs2MGHVNH WgGk5l+TKdqMDHNDKbso4MzFbQQwevooSVCuukGd11n7wDygGIkVyV9riuaWsSWmzCVh xWjA== 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=D7ykQt1vT7zPbijFwFYegflkwjMwbCZ44dDnJ4klZqcyQjqbDpyxX+zTyl0gKAA/X2 +iyKXP0HFFRV4FoaaGsSsYGefqt31hAZDKbei7XeX4maAai7UDHTPDykPb9930Gm0rQl Vbtoh6gj7yD+P+LGLK+rfnvvZEwOkZ/YHN7ymxTwyRYrHir1K5uYrUW0SE4eOQVxvzgL vvNmrPCIhbWN8MZYGfwxpdmC+PQ/XcYXtayjpOW5a/FmxXVhuAob8FY5AovGF78CkEOj ud5B1ZFRpzTP2yYyAge58hdvR3SWLM2PgnsG3Ll0HGszy8Ehj7qWvHM721F3weW8rUs3 IrQQ== X-Gm-Message-State: AOAM531xpms5hfY59Ql2q/Aru5ZiBlanjbYKRvuCCSxNCUS6IqQNVpLP JwWfUL9B0bxCizcmbwdGrtI6FBmfrfs= X-Google-Smtp-Source: ABdhPJzZSZeoPHPEcljPN9033/1Za2yMeMZwR0zIi1I5BqIdZdzuZiT8caypGK5wM5HZmOO65UwlUw== X-Received: by 2002:a5d:4536:0:b0:1e5:64fb:a531 with SMTP id j22-20020a5d4536000000b001e564fba531mr12785476wra.264.1645379669879; Sun, 20 Feb 2022 09:54:29 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y10sm5163949wmi.47.2022.02.20.09.54.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:54:29 -0800 (PST) Message-Id: In-Reply-To: References: Date: Sun, 20 Feb 2022 17:54:17 +0000 Subject: [PATCH 01/11] worktree: combine two translatable messages MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: "mailto:sunshine@sunshineco.com" <[sunshine@sunshineco.com]@vger.kernel.org>, "mailto:gitster@pobox.com" <[gitster@pobox.com]@vger.kernel.org>, "Elijah Newren [ ]" , " =?utf-8?q?Jean-No=C3=ABl?= AVILA [ ]" , 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 Sun Feb 20 17:54:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12752800 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 86C9BC433F5 for ; Sun, 20 Feb 2022 17:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244268AbiBTRzB (ORCPT ); Sun, 20 Feb 2022 12:55:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233734AbiBTRyy (ORCPT ); Sun, 20 Feb 2022 12:54:54 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68A014D9EB for ; Sun, 20 Feb 2022 09:54:32 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id n8so8258582wms.3 for ; Sun, 20 Feb 2022 09:54:32 -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=f5RcEPm8kDN8lh5W3SyRJF5FTmxjzCgdgZpoCsIRXotTu7XZokByhHwS3zL/dZHXd8 j5G+sDoE/Jg7AN7jQnd0dycQvAp2rt6VJzBe7OJY8NhyFHwAtHQ4vwR62aqqBjtvQTI9 t6YxIqv+/QWMH/YUBmGpwyFyEy/Q8zEK/dlVuKU795FC5SgnFf+SpA7E+3/S5lQH20Qg Yz/S4f7Dm35diNtNfcsYQkxi6Nz7MUSUAhs7f8mVJwG27PVQsgRJtLGYpp8+SnBKeP+2 jfxCX/xNH3vFfLgtaEPPIthV7t3Z5IG9hz4J9HrLIWg4W9k9lYyxzpgMJswNa183of4F KBAQ== 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=2mtCYbMONVZu3qLnSHme+1pmKQKVmulpTGSTrYq6P0hEQ2Z970YAYHVDlo264WvV3A P/sx0K+znK/pTeU57Y/aCfhRPrTeNiHm2C0nKDP9phyutbz5tCYF4VQS03oWBt/dBuKn xSK/1teOT1mBf8rb64lcq6R7zSj+LCUeL/HKsltOUbXdrCtm2BZ8C0PciRuKsLW18tfw U62+YW1CIDEamgU9wBq2G+C8XUr5L4NO31aaCx1r9Oq2YRlNxORdmqVIN9NVeavDjvrC ypm55uY4jzcWlj+XMF1HGdCLnYEtzDLeHcc6KPjl55HpJVavfLomjJT5PL7qXoln10k2 BbTw== X-Gm-Message-State: AOAM53227yc4EBCW+yIVsDWF+b8R4REQWZer7+ys8LQdiYYjfF1PcXkR JYRSjY6b7+MjReldQujfp5Ob0OWiF2Y= X-Google-Smtp-Source: ABdhPJzqQJoJV0H0mLFgj4oQW63HSNG+t4Dhb5bu1Hv2HoTVXdzMu9GRUIklkHvRYwTIt12g2rI0dQ== X-Received: by 2002:a05:600c:4e13:b0:37b:e449:7afe with SMTP id b19-20020a05600c4e1300b0037be4497afemr15100468wmq.60.1645379670785; Sun, 20 Feb 2022 09:54:30 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c5sm3456843wrr.54.2022.02.20.09.54.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:54:30 -0800 (PST) Message-Id: In-Reply-To: References: Date: Sun, 20 Feb 2022 17:54:18 +0000 Subject: [PATCH 02/11] worktree: extract copy_filtered_worktree_config() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: "mailto:sunshine@sunshineco.com" <[sunshine@sunshineco.com]@vger.kernel.org>, "mailto:gitster@pobox.com" <[gitster@pobox.com]@vger.kernel.org>, "Elijah Newren [ ]" , " =?utf-8?q?Jean-No=C3=ABl?= AVILA [ ]" , 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 Sun Feb 20 17:54:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12752799 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 608F1C433FE for ; Sun, 20 Feb 2022 17:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242592AbiBTRy7 (ORCPT ); Sun, 20 Feb 2022 12:54:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234398AbiBTRyy (ORCPT ); Sun, 20 Feb 2022 12:54:54 -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 4C370527F2 for ; Sun, 20 Feb 2022 09:54:33 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id h6so23248890wrb.9 for ; Sun, 20 Feb 2022 09:54:33 -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=MLIBCiauXYpI3hQzFqU7lTJcRSsJgdNpuLoraPxvr1OyUpe2ZLIumoIrwC/YRVyP7q yXJ7IQoKK+OakVDTzPHZg32lgmq+4YGJVq7X8vhkIQM/zOnZOobixWFm8ut6mMgNKcsn C07aw/O6VT7aG4+p83SCWf7YuEanhbADghoOTvbHSw9skxm/4GWs2jpbK2tp+5A6vto2 nIJwZHSdBL1Z+S7dWK7vRP6QfJPBimrN4fajju5BZYyrc2GxK4dSRE9n3+HCpDXkuIai vLm2u3zu2idAjO/AkCDVLmz3FD4+zSemSkKZ2LFzGcw7NVh6xyTwNSUWZsGVeWRosn4D Zpgw== 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=Crc//RqbL8lhd5koV/ljF5fypw4vfxe+TPNeV0Dn6Y4/MvQiUeaJ2IA5Rsh8TY1fda vY9j+TQR5JjDTA2kHxAxPs98jT4l3r7ji6R7cho7IIXJ6d6R6L39RmqMdZLOYri+af3X 3H4SlcL4AtvH8n+yg5C2bAAzv7M/Tq5Kwx1snouRf/Tvqf6H88iMe7xA9G35B0kyWny+ QVoRno4lBK5eTYdsBzKcC6wB0HyLkmmT6egcFgP7bG+diRVZBtCVxksAWTBF8YZF+mmv +BcCb3e4CZ5m14Ga6fraA60c7KA12Vjctlq9sDhexbfR+vdZk9njc466Hbad1JgN8nk/ wZow== X-Gm-Message-State: AOAM533sY1OfH3UykpuNeG2//s8CDrc3LhEysYeINa88ML+EybjBkDg5 PiSZtGB6ffdtSMeqDuRMgc6juZFk4qk= X-Google-Smtp-Source: ABdhPJzy2T9mG3OOhCnbsWPLv7JbNuFTFha+tOpYBYlaNwnEVUH+ZFhRivhqx/h3QsOOEm2i+qsNlQ== X-Received: by 2002:a5d:64e6:0:b0:1e4:a576:5800 with SMTP id g6-20020a5d64e6000000b001e4a5765800mr12732434wri.49.1645379671618; Sun, 20 Feb 2022 09:54:31 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g5sm5204380wmk.38.2022.02.20.09.54.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:54:31 -0800 (PST) Message-Id: In-Reply-To: References: Date: Sun, 20 Feb 2022 17:54:19 +0000 Subject: [PATCH 03/11] worktree: extract copy_sparse_checkout() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: "mailto:sunshine@sunshineco.com" <[sunshine@sunshineco.com]@vger.kernel.org>, "mailto:gitster@pobox.com" <[gitster@pobox.com]@vger.kernel.org>, "Elijah Newren [ ]" , " =?utf-8?q?Jean-No=C3=ABl?= AVILA [ ]" , 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 Sun Feb 20 17:54:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12752801 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 8AD35C433EF for ; Sun, 20 Feb 2022 17:54:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244306AbiBTRzD (ORCPT ); Sun, 20 Feb 2022 12:55:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240203AbiBTRy4 (ORCPT ); Sun, 20 Feb 2022 12:54:56 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363F94D9EA for ; Sun, 20 Feb 2022 09:54:34 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id p9so23231701wra.12 for ; Sun, 20 Feb 2022 09:54:34 -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=MrmvVl9EhyxSZ/1a0LmbZKpmhGmym2rspTwVOGC0z0son8WsK0oNWhVrqLeREObncU DT8qbnpPIHuX8CHUzVPWBQ8otQM2W0drCjKAS0hIfK7Nb9Hi3d3sdjQDrdlbEMpvhiEY 9wJ3xO0gjigSHVQAXwcyL1f5OovCXMUkLZfZV07aUSdm5/h7bFF2pI8R3ISepZlH9xjF mDkKvAervxSPu2TZvhaqMMea63VWnlz7vk12d3Y7Znka7cojTuIRYWo5jIdcFDv63LDq MnSyV+Q9ICov8mgTwcXogwuXIEphd0zvsx2Bp/p0IZILJKHqqteg6TDi/PG/kTFH4rne Oogg== 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=e3Bw0McKrVcMQATPFRnSlrSXOT9Oarur8z6/lyG5dAclTR+lmEPQbHvPgqbXcoH4UI NoAG4vrWZBbKUpXvRc/icHwmhyeLDERlDPptMPGuPgb1oMAW2Hf0/vUTCqdsQ+PjoHyk ySXvhEWkV9Gi34dKnZQPXp/B0WEyU5DaumirNRu+E5zT7tuJuk3oNJuu1m7kI4FlrwFj PDHlYu48wsbajzYPWTkKmeN9pmxZ/RPhi1B7/1hg9/y7nmgkHYchABhWFkqduIEx5tpA QAjeNgCkKf5u63beCSGwKTRSLS3fSesvtPJP2v0H93r+SWl6dyZLSn07/Kx7ngH2s/hG 4gDQ== X-Gm-Message-State: AOAM531r2akwPjRCNu8Sm7IJK+1vdzr22bcog6W0lWBWoGN9xljG5zue a7MonEGz2Bk+VmDKaoKyT44NzBHXVXc= X-Google-Smtp-Source: ABdhPJwSUVJznPWgmPb+RUjdcrX+f4205hlkM1Cf7Q83rPl/7B/N9m+YlSo+b+BhA+QN53A8PltIqQ== X-Received: by 2002:adf:ee8f:0:b0:1e4:a642:5c0 with SMTP id b15-20020adfee8f000000b001e4a64205c0mr12605718wro.146.1645379672628; Sun, 20 Feb 2022 09:54:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t1sm57534336wre.45.2022.02.20.09.54.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:54:32 -0800 (PST) Message-Id: <1e62e4e4fa1a543ad134d70d97740cac5826e587.1645379667.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 20 Feb 2022 17:54:20 +0000 Subject: [PATCH 04/11] worktree: extract checkout_worktree() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: "mailto:sunshine@sunshineco.com" <[sunshine@sunshineco.com]@vger.kernel.org>, "mailto:gitster@pobox.com" <[gitster@pobox.com]@vger.kernel.org>, "Elijah Newren [ ]" , " =?utf-8?q?Jean-No=C3=ABl?= AVILA [ ]" , 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 Sun Feb 20 17:54:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12752802 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 570DEC433EF for ; Sun, 20 Feb 2022 17:54:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244365AbiBTRzF (ORCPT ); Sun, 20 Feb 2022 12:55:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232701AbiBTRy4 (ORCPT ); Sun, 20 Feb 2022 12:54:56 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D7DF4D9EB for ; Sun, 20 Feb 2022 09:54:35 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id x5so18413039wrg.13 for ; Sun, 20 Feb 2022 09:54:35 -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=qaswKm2FOW/d3DPi0HCFCNt2vonz7RYKAFT/RooHawA=; b=deWYjPvUodIQW8FcGAz9SBmx3NT/o806yTYpJcJ5UkJcbg4MhXTUAj//hms9cZPPDJ 9e01NfqfsVmC1SIUyHje/tV0gZ9sD0SWgL3L3ln/OwLtT32x8hUMTd2VMyfuzUyxRBaZ E6d9hWRCnnXj+nGG3GWpJoUSkDsxbM+znFMkOL32kM19ujPn1/8lgoYOVgYvIylZFEEx qQ6YpvsaN9CUMe+hgCkLDEtj/K7IBJhBEhekRZktl+iYWUIkZDu857lV9PBK7cKBmr1c xyAHxN/KOaxdtF1U1Mo/p2yP00IjEDDHFxNSgzm0mtJrNzUqOhQx+tHOViToBACCyvSy VaxA== 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=qaswKm2FOW/d3DPi0HCFCNt2vonz7RYKAFT/RooHawA=; b=SPnyaVyKPXyTi7ZzvrvpkuMo7GD1IhSspIHLblIddEUTU1uOhcmqvnFmY/F7WGaXtu UN5Bt7qXtKyczlPZWwIykqutSY3vhhrJ6mq9Q47kZpgns090DSbjTdVC1g8gpCL7k+40 CydgjizonyMmzztqcRHy9WPIdvrzprU021ehOOscUUX0J2kwuloX4xmU2lpY3twmIOe6 o5xvHpWrUf2a3mpoTFlSqSV3d0gi9CZVCmeO+/5uUlBKjIXmUjL7NKo9FYAATonwa8dz 2mX3IvjjBOy15F7GzH/6z91b/rFvgMG5lD9yfqimFHMsksSNErMs2ACWMrIqjh3FIWtY DfzQ== X-Gm-Message-State: AOAM530VTtbZivKMSNGgCwDfBvS2fPtf4+RW4bVTMTzURwPdeaQNJwn2 /EJB3d3H6/5eWrndoJhjpax9p/70h3I= X-Google-Smtp-Source: ABdhPJyzIVxFYZ1/GXlkf3n/kmYyBJr+MeyhIOAh338FrGlVxLmMKLQ2EkumBg5NaI0es2elDY/LfA== X-Received: by 2002:a5d:6a43:0:b0:1e3:1830:802f with SMTP id t3-20020a5d6a43000000b001e31830802fmr12521864wrw.485.1645379673420; Sun, 20 Feb 2022 09:54:33 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v18sm43063073wrm.105.2022.02.20.09.54.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:54:33 -0800 (PST) Message-Id: In-Reply-To: References: Date: Sun, 20 Feb 2022 17:54:21 +0000 Subject: [PATCH 05/11] worktree: use 'worktree' over 'working tree' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: "mailto:sunshine@sunshineco.com" <[sunshine@sunshineco.com]@vger.kernel.org>, "mailto:gitster@pobox.com" <[gitster@pobox.com]@vger.kernel.org>, "Elijah Newren [ ]" , " =?utf-8?q?Jean-No=C3=ABl?= AVILA [ ]" , 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. Signed-off-by: Derrick Stolee --- Documentation/git-worktree.txt | 53 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index b8d53c48303..d9705062e9d 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -25,45 +25,48 @@ 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. - -If a working tree is deleted without using `git worktree remove`, then +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 worktree 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 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 `` 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 Sun Feb 20 17:54:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12752804 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 EFB5DC433FE for ; Sun, 20 Feb 2022 17:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243487AbiBTRzJ (ORCPT ); Sun, 20 Feb 2022 12:55:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241597AbiBTRy5 (ORCPT ); Sun, 20 Feb 2022 12:54:57 -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 2A9E84D9EA for ; Sun, 20 Feb 2022 09:54:36 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id d3so7625074wrf.1 for ; Sun, 20 Feb 2022 09:54:36 -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=RTwt2oul/T9cuX1Aq7OX8wSa7v5hSVJ9F6TWOKAFUOQ=; b=O36mk0qQ29e8ysSD4X/HSD4zADRwy+PVTUOG5Py8emDgWt6H1qr81OLN083AxwJw43 LE7AKhHM1FncP2q/Xdxtng9VGl5zM3NpTjUjB24KfvdD7R/1y6YjRkkKUL34aSZIlGnr hr+RYZTdibkcJ4HLH8kbb4G2uac+3kwVCyvkKQDyWqetU5WUNnI1upYQPOz/e8D2E4Ra 6g99/iVrtzXy9iWJxpu51KvuhcSI2ag4pkk+UX6IU+3uavJEG8KyIzzsfO+yOvoZE2UJ JIF8CpTIJ+KX7wrcxfSJ1SuIxlxk/SfWE9J97SafIKtSv8Ri08e4CRNXWV51NeDmzrVu xYKw== 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=RTwt2oul/T9cuX1Aq7OX8wSa7v5hSVJ9F6TWOKAFUOQ=; b=k0HGdgj2lSWdYHDxtp4U4o6lHCcazWkaBf+U0YdsVfqpRab+WmJRdsSsxu4o/yh038 4wiQKQW23Ge4ccTWSFU23zi/p90FwCaPuR9pfx2vDWmeaW+DsK2ha0K2ZikI0x56Nzb6 Knv+uKIGIZIuQDyfZxoak0RGmFi4Eq65+1x7V90XQFzZE/Xnz9tprLlH8PU8G5O9XULY BjmKvZzOgunuA9qt31Ss/6Jorr7GBQZkGc4WOyx4LkLroWkWz04N3M8bFqanxaY0snBg 52SY71HYh56JPiGFxQclDFSwlvAJvkaYUKe9aZya15N5Y3Byo2KTdnKnCwFp6Jx8UBId OpCg== X-Gm-Message-State: AOAM5327DFW8a4qxoMZyzgDwmfvTlntyPWMAmW6tQHu/ICL7cOE2AWny /7ZMPsEpl2WZRR7hfS9r0IeKOHBRRwU= X-Google-Smtp-Source: ABdhPJwXSHVC7jsq1F3XK8QvDKzjZXzJ0wxpqvvAazQEkipgyasV6b2ZmUJuQZEcPfExlNxTB7V0Iw== X-Received: by 2002:a05:6000:1089:b0:1e6:339c:f2f8 with SMTP id y9-20020a056000108900b001e6339cf2f8mr12766519wrw.370.1645379674393; Sun, 20 Feb 2022 09:54:34 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l31sm5636816wms.0.2022.02.20.09.54.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:54:33 -0800 (PST) Message-Id: <1fc4a98dc7aac79a22b25670074f68a135b79ef3.1645379667.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 20 Feb 2022 17:54:22 +0000 Subject: [PATCH 06/11] worktree: use 'worktree' over 'working tree' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: "mailto:sunshine@sunshineco.com" <[sunshine@sunshineco.com]@vger.kernel.org>, "mailto:gitster@pobox.com" <[gitster@pobox.com]@vger.kernel.org>, "Elijah Newren [ ]" , " =?utf-8?q?Jean-No=C3=ABl?= AVILA [ ]" , 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. 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 d9705062e9d..e9ba58fb8bc 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -87,75 +87,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 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 Sun Feb 20 17:54:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12752803 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 5D7F8C433EF for ; Sun, 20 Feb 2022 17:54:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244423AbiBTRzH (ORCPT ); Sun, 20 Feb 2022 12:55:07 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242485AbiBTRy7 (ORCPT ); Sun, 20 Feb 2022 12:54:59 -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 3359C4D9EB for ; Sun, 20 Feb 2022 09:54:37 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id d3so7625112wrf.1 for ; Sun, 20 Feb 2022 09:54:37 -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=vC1TkCW+XO48wkGTn+/eQuGlj2/Ui8jqQMIkeWhcDhk=; b=CCWz+X6s7cFhVobhLSY6RYowIyUR4jcq5w1F5FjxcwWzynSdWQq61ilTA6/FwpbAdI 8KaavEjXPMQYwzFH2Y39wEt4GhRGHF3Jp6TzlISudphLM4LW16mqwX2gekNni9MIDmQ+ AFI3ROJ+StkhtDQ5piMXx99nFQs5dU/t5ZhC50e3aQH7qzRXddqt6kESlsTnG4FjRKJQ RKbw5P42WzRTG4aNAzA/DLzulCvFE++LyhV+5UsnG0Lx2BEB/PNV4O5quaf1dKYqSLuk GI3qVxP9P7MmYzN667134hiLKXPleuZmoICn+516i2Joa/abbirDJOzRposMChHnh+Z6 +2FQ== 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=vC1TkCW+XO48wkGTn+/eQuGlj2/Ui8jqQMIkeWhcDhk=; b=0lMxE/oGHix2nsZzFIacHu9XOsXGoqLlX9qd/+h6jUgdcwz93r3xCmfD05P20xUi7x Bx4+V7+Vkv/TT9vQsEfQLL9aJowH6b9Am9q6ImyYsetSDZ0/GQAPyd8MODXdDsecaGY0 46Tzox/WIQvvfy3ic1SZ9GpTECRvHx1WPkTvqR3jkxBM4GId2n1miILkfEHgOVZ6iaUv 8ZKKm1Roa2mtifOG2xV6nLpWawHNEJlyD6fUqQ7HWNgOgbcAOmGmOgVk0h3XOce9Az5B ZLOhGBu5/QFG5lB0ZyE7jw3J+PNEnYy5uV3GEf3PnSPfrrOF+nd8T0YfEOMk1vQVEvmL oU0g== X-Gm-Message-State: AOAM5315XMoCIQGeI8HkcV0tq6HyFNmihic4OFukoiyZW07cR/WNv8a7 9tSktq63frQVs9z3LXNANSli87zfey0= X-Google-Smtp-Source: ABdhPJzgd7/G2OQI3b3YiRjqEpwg5sYGWd0CDGiiBsS8KK/W59GUS3rsrIFdvJ/ENxRlVxeBp3E2uQ== X-Received: by 2002:a5d:47a1:0:b0:1e8:f787:b7bf with SMTP id 1-20020a5d47a1000000b001e8f787b7bfmr12078934wrb.101.1645379675437; Sun, 20 Feb 2022 09:54:35 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n4-20020a7bc5c4000000b0037e0c62604fsm5268138wmk.14.2022.02.20.09.54.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Feb 2022 09:54:34 -0800 (PST) Message-Id: <00d261d0a2a4e87e774990d1cef3b875dde373d5.1645379667.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Sun, 20 Feb 2022 17:54:23 +0000 Subject: [PATCH 07/11] worktree: use 'worktree' over 'working tree' Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: "mailto:sunshine@sunshineco.com" <[sunshine@sunshineco.com]@vger.kernel.org>, "mailto:gitster@pobox.com" <[gitster@pobox.com]@vger.kernel.org>, "Elijah Newren [ ]" , " =?utf-8?q?Jean-No=C3=ABl?= AVILA [ ]" , 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 e9ba58fb8bc..10021c85e77 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -159,25 +159,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 @@ -185,7 +185,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:: @@ -211,7 +211,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. @@ -236,22 +236,22 @@ This can also be set up as the default behaviour by using the With `list`, output additional information about worktrees (see below). --expire