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.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 5D2BE1F55B for ; Mon, 8 Jun 2020 22:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726864AbgFHWCO (ORCPT ); Mon, 8 Jun 2020 18:02:14 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:59069 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726723AbgFHWCO (ORCPT ); Mon, 8 Jun 2020 18:02:14 -0400 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 57ECA66740; Mon, 8 Jun 2020 18:02:12 -0400 (EDT) (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=qzyNly5p78TmjuXpliw1Ldhifu4=; b=Ecyp9+ NDMlAGavnwo3iv2HDZBZ6iUCR2E/yyeWAfru4kgIQ9iTmkfJuFK20NJLwZ4A3MeY 0VegUmaKSbvRYe9qAJbecGxDpWVeLsjTC+d8cLSgboslcY+FoesMHFwRvqd5MZZr c2llXnAeCkxd9NGA5FlbBXAH2soYX8+W8djaM= 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=YX9b/1sD6g6DuicHW//HVmvfDcyChp8w ARzewrZtk2RI7+5S5SbKzAFXaMBUQlKf+y2Nq6t9rBL16zFtaWiIf10PZG87Dw9A Bo/xero4Tmqk8hWsJ8y8jDEWlMTwMIRBD9vimnjOQrPUdAgpQT4/ZcnpADQeduSC zyDWc7eQ4cM= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 4FDE56673F; Mon, 8 Jun 2020 18:02:12 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [35.196.173.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id CA1CB6673E; Mon, 8 Jun 2020 18:02:11 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: Eric Sunshine Cc: git@vger.kernel.org, Duy Nguyen , Jonathan =?utf-8?Q?M=C3=BCller?= , Shourya Shukla Subject: Re: [PATCH 7/8] worktree: generalize candidate worktree path validation References: <20200608062356.40264-1-sunshine@sunshineco.com> <20200608062356.40264-8-sunshine@sunshineco.com> Date: Mon, 08 Jun 2020 15:02:11 -0700 In-Reply-To: <20200608062356.40264-8-sunshine@sunshineco.com> (Eric Sunshine's message of "Mon, 8 Jun 2020 02:23:55 -0400") 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: B46CD1D0-A9D3-11EA-BB04-C28CBED8090B-77302942!pb-smtp1.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Eric Sunshine writes: > "git worktree add" checks that the specified path is a valid location > for a new worktree by ensuring that the path does not already exist and > is not already registered to another worktree (a path can be registered > but missing, for instance, if it resides on removable media). Since "git > worktree add" is not the only command which should perform such > validation ("git worktree move" ought to also), generalize the the > validation function for use by other callers, as well. Makes sense. > - validate_worktree_add(path, opts); > + worktrees = get_worktrees(0); > + check_candidate_path(path, opts->force, worktrees, "add"); > + free_worktrees(worktrees); > + worktrees = NULL; It is somewhat unsatisfying that the libified helper still signals its displeasure by dying, but a faithful conversion that can be cleaned up later (if we wanted to) like this step is easier to reason about.