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-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 3636C1F619 for ; Mon, 24 Feb 2020 19:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbgBXTNp (ORCPT ); Mon, 24 Feb 2020 14:13:45 -0500 Received: from pb-smtp2.pobox.com ([64.147.108.71]:56933 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727168AbgBXTNo (ORCPT ); Mon, 24 Feb 2020 14:13:44 -0500 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id CCACA47653; Mon, 24 Feb 2020 14:13:39 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=Tq2fcg96vh+6wBkUefRAjmhs//E=; b=mKJ/TK j18IqnrNUojpLTWS0znAdytVHh1IFlHnfvgFMlcULdFPTb+Yrdg53wwbnBN3xlLc YFbIzw3VO/iMZfOtTN8rmXd5jk9yMrJY/QK7ymJqwbArG0va4MlkxoFqdBcOl9UH BInRHHX942ghitlV7EdX2Gx2dCva/D2e3qMvo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=tv8Wv4gpYyx16vyIapgHvNCrBwmmHDIH O2M103u94Eftkj9sIgBqdiLepyna5RsW4w3ZxzqPXZyF5EHpkaN5YDKFTRdNlxTO pGAnNWt1LqJiAi997bYhe3w0ZmNALpZsP1UV2TsbbvElFCEVd79AmeAu9QrHpNyK 3iyv5D6U+2I= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id C4E8647652; Mon, 24 Feb 2020 14:13:39 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.76.80.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 2F60A47651; Mon, 24 Feb 2020 14:13:39 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: Hariom verma Cc: Eric Sunshine , git , johannes.schindelin@gmx.de Subject: Re: [PATCH v3 1/3] get_main_worktree(): allow it to be called in the Git directory References: <8718facbc951614f19407afa6ca8d6110507483d.1582484231.git.gitgitgadget@gmail.com> Date: Mon, 24 Feb 2020 11:13:37 -0800 In-Reply-To: (Hariom verma's message of "Mon, 24 Feb 2020 16:39:08 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: C37420D0-5739-11EA-B977-D1361DBA3BAF-77302942!pb-smtp2.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hariom verma writes: > Hi Eric, > > On Mon, Feb 24, 2020 at 7:12 AM Eric Sunshine wrote: >> >> This title is a bit too generic; it fails to explain what this patch >> is really fixing. Perhaps: >> >> get_main_worktree: correctly normalize worktree path when in .git dir >> >> or something. >> >> "Git directory" is imprecise. As a reader, I can't tell if this means >> the main worktree into which the project is checked out or the `.git` >> directory itself. Please write it instead as "`.git` directory". >> [...] >> This change makes the code unnecessarily confusing and effectively >> turns the final line into dead code. I would much rather see the three >> cases spelled out explicitly, perhaps like this: >> >> if (!strbuf_strip_suffix(&worktree_path, "/.git/.") && /* in .git dir */ >> !strbuf_strip_suffix(&worktree_path, "/.git/")) /* in worktree */ >> strbuf_strip_suffix(&worktree_path, "/."); /* in bare repo */ > > I'll implement these comments in the next revision for sure. > >> Also, please add a test to ensure that this behavior doesn't regress >> in the future. You can probably test it via the "git worktree list" >> command, so perhaps add the test to t/t2402-worktree-list.sh. > > There already exists tests in "t/t2402-worktree-list.sh" which lists and > verifies all worktrees. Does this make sense to write a new test that > also does kinda the same thing? I'd read Eric's suggestion as "please make sure we have a test to ensure...". If there already are tests that protects the behaviour we care about here, there is no need to duplicate it. Thanks for working on this topic.