From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2059634D4E2 for ; Thu, 23 Jul 2026 23:28:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.155 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784849305; cv=none; b=bJl4ERr+rLnzqnh5z82vQQOR1RGjydz9urlKG6cqiNvURVvqL8r9BoIX42X61pxfi2CwrRj/90J/AVmPXb279MNFqs6eI5Uq84HORcgYjsr6sgmDY9LtNMovWVHT57f+wKEVBC0Op1ESiX9sBEruTsL6PlxGhmTfVNDcNQDTMKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784849305; c=relaxed/simple; bh=y/eS9RqQn/pn1el7Zv+b/DpDC1aXBBzQr3U6DTal0SY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=P1MVSFfPPYuzWhkaNcATshmHzvWTbhw9NUp6/qHDfxz/d2dJYzI7w5dszWa6Ve7m41IuFt3yn4u83ed2TzUOGzSxRmf6oh7Ll5bTad8QduqVBguRkpcmyqq1jUI8CZIgwPurYrtsbb42BOjoE9OmXuBv603kqoOkrgyxzIKuA10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=J72434Tj; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=GBgxqDOf; arc=none smtp.client-ip=202.12.124.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="J72434Tj"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GBgxqDOf" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 2FFAC7A00F4; Thu, 23 Jul 2026 19:28:23 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-05.internal (MEProxy); Thu, 23 Jul 2026 19:28:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1784849303; x=1784935703; bh=Mpl8xWWh4a cgF3NEkiQtIpRjDKj7DkThM5fekETVdJo=; b=J72434Tjc78jwT51Euu/TI4W2s vx+ZeOWYJebNMmGfqEHnUVrTc2MnbzfXMvPxEstsgd7hZCl50DD2StFMPAjNr+RT 9MVH9rPU0u7kfylak73ys8jwV5MifPw/eMhdxvodpyMocRGZL14Q4u725+ejLIep eFu/It9VUZfH2l+9WaQnW1XNtRPtz9AJtiX1mCANylOhwMpxNCOMnCUewDFe/OEN MFLH/Y0PhoKBVki8HmD8B6k7YM8yd1R50Z+GBQ2BPFU3eUDhcBJFtDYVpIGxVe1M SoKpZpOdt+jI11gaM3GCG7yTHqtoV6Nf4mh7dSzxxxKuM5n2No1+pcfSr0IQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1784849303; x=1784935703; bh=Mpl8xWWh4acgF3NEkiQtIpRjD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OFVRyOJs4pi34CTiGgLjfFag X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 23 Jul 2026 19:28:22 -0400 (EDT) From: Junio C Hamano To: Lucas Zamboni Orioli Cc: Lucas Zamboni Orioli via GitGitGadget , git@vger.kernel.org, Ben Knoble Subject: Re: [PATCH v2 2/2] mv: check for missing destination directory before renaming In-Reply-To: (Lucas Zamboni Orioli's message of "Thu, 23 Jul 2026 18:38:18 -0300") References: <1a790e001610d3324ec45d86ac67ca5720678cb8.1784812390.git.gitgitgadget@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Thu, 23 Jul 2026 16:28:20 -0700 Message-ID: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Lucas Zamboni Orioli writes: >> lstat() can succeed and 'dir_st' may indicate something other than a >> directory (for example, a symbolic link or a regular file). >> Alternatively, it can fail with ENOTDIR when, for example, 'dst_dir' >> is 'a/b/c' and 'a/b' is a file rather than a directory. >> >> Both cases will cause 'git mv' into a path assumed to be a directory >> to fail. Shouldn't we handle these conditions as well? > > Yes, agreed, both should be handled. For v3 I switched from lstat() > to stat() so that the check follows symlinks the same way rename() > does, and I handle the non-directory cases: Generally, a symbolic link in a Git-managed working tree should not be followed. Following a symbolic link would mean that 'git mv x y' could move 'x' outside the working tree if 'y' is a tracked symbolic link pointing to a directory outside the working tree. 'git apply', for example, avoids being fooled by a symbolic link for the same reason. I doubt that using stat() instead of lstat() is the right approach. Doing so essentially amounts to ignoring the presence of symbolic links.