From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 55F1D1F4B4 for ; Tue, 8 Dec 2020 20:43:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729618AbgLHUmX convert rfc822-to-8bit (ORCPT ); Tue, 8 Dec 2020 15:42:23 -0500 Received: from mail-ej1-f43.google.com ([209.85.218.43]:34358 "EHLO mail-ej1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728064AbgLHUmX (ORCPT ); Tue, 8 Dec 2020 15:42:23 -0500 Received: by mail-ej1-f43.google.com with SMTP id g20so26598230ejb.1 for ; Tue, 08 Dec 2020 12:42:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=7TFAPEXRQNGwDeD8B09km7UMFfamOaR7wd8lcLJ5ans=; b=NY57+6PZfG8ok1Varv11mplI+2SUskBAXV2w97Zunup6slBJebhSbqm9Zpzkx2DCec GKe0KrI8dOCn9jWgICKig8ECDLrTcVK2q2TzEY4IwitmIe/Z+vSmwDNWp/GUAYmuzmDv O0tXcH11XyvUi0HJnONup2p6cATNZcPPHFT2GlFo/up5I+AIyU6O3XhICA3NH0B/NMM3 SOmeysy9joY9k2tRi5Es3YXLN7y4qfh4+V/IHlvfHwcQ5NG8kzXtI/eiA5r0yJZ9Vvrw SzIRxWTv0zQDy/6aVNe+nSS3428NSVEs6bFksQqZnELIDYudor0zRMkfqZuPQ5brsfkR 58MQ== X-Gm-Message-State: AOAM5313nYDhEN0ZWCCF8uhlN3SG2dGfS1sLdXjZCa8YRFaOcgW6xatS erAPmyU/qiGMlf6nZQujfZbATniuKf5mbAYNy/P62sWdvoo= X-Google-Smtp-Source: ABdhPJysljQ96WdtKMCtXCOr0UHSEWAq6BCdwZlaxXCadMcnCzNu9MR568iVsZinZ0NaLCAVS6fHs0hxelswWL45ocM= X-Received: by 2002:a05:6402:46:: with SMTP id f6mr11794299edu.163.1607455665693; Tue, 08 Dec 2020 11:27:45 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Eric Sunshine Date: Tue, 8 Dec 2020 14:27:34 -0500 Message-ID: Subject: Re: GIT_DIR output from git worktree list To: =?UTF-8?Q?Ganriel_N=C3=BCtzi?= Cc: Git List , =?UTF-8?B?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Dec 7, 2020 at 2:28 AM Ganriel Nützi wrote: > As of your rational, wouldn‘t it be good anyway to have a file > „worktree“ inside the .git dir (of the worktree) containing the path > to the main worktree? So to speak any worktree always has a .git dir > with a back link to its main worktree (the existence of the git dir > might pose other problems?) I'm having trouble understanding your proposal. Secondary worktrees don't have a .git/ directory; instead they have a "gitfile" named .git which is just a pointer to the worktree's administrative directory within the repository (specifically, /worktrees//, where might be a bare repository or the .git/ directory of the main worktree). So a secondary worktree's back-link is a pointer into the repository; it's not necessarily pointing at the main worktree, as you discovered and reported in the email which started this thread. What I was suggesting was that it might be the case that the only way to solve this would be to store the location of the main worktree somewhere within in some file, and then `git worktree list` would consult that file to learn the location of the main worktree. This is complicated by the fact that that file would have to be updated automatically if the main worktree directory is ever moved. It also needs to be done in such a way that it is easy for other Git implementations to understand and not trip over. So, it's certainly possible, but it's something which requires more thought, and there might be alternate and better solutions I'm overlooking.