From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: Re: [PATCH] apply: refuse touching a file beyond symlink Date: Fri, 30 Jan 2015 12:32:07 -0800 Message-ID: References: <20150130181153.GA25513@peff.net> <20150130200731.GC30738@peff.net> Mime-Version: 1.0 Content-Type: text/plain Cc: Git Mailing List , Josh Boyer , "Linux-Kernel\@Vger. Kernel. Org" , twaugh@redhat.com, Linus Torvalds To: Jeff King X-From: linux-kernel-owner@vger.kernel.org Fri Jan 30 21:32:22 2015 Return-path: Envelope-to: glk-linux-kernel-3@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YHIEn-0000L1-J0 for glk-linux-kernel-3@plane.gmane.org; Fri, 30 Jan 2015 21:32:21 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759611AbbA3UcL (ORCPT ); Fri, 30 Jan 2015 15:32:11 -0500 Received: from pb-smtp1.int.icgroup.com ([208.72.237.35]:59614 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753005AbbA3UcJ (ORCPT ); Fri, 30 Jan 2015 15:32:09 -0500 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 05A3732237; Fri, 30 Jan 2015 15:32:09 -0500 (EST) 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=BdWnpIdH81axjIRylWPWotvEqMQ=; b=S8CO60 tNDShukFWUyYgoez3MYMNrCTWC1FHjV/bEnA0spz3xBnGiSawgfoY0JKTorpTm+c S99WXe2RKGFLagqypFeafxWQTx/i7ER84NWvPzOXcthj/5Nz0t5IqpGac3f0rK8e lXEl1mw1waoHxkREHZ4ha+qpCTHMMaunvflAk= 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=cQ2DEhILWTx/CgWqQx52GI93hmIFUcOL RNSwsikFfw5zSJjf4TjAx9dkUZvqCHI5tGq8TKpdV4AbI40lbqyTbraE4c67NN5y mdS+vZXvKJ0/am5K5zBTQuvbWdBjFHjHRKUhby32uT3BpobWvjItTmcEZnETXQ9x 7DZZYTn2kuU= Received: from pb-smtp1.int.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id EF91932236; Fri, 30 Jan 2015 15:32:08 -0500 (EST) Received: from pobox.com (unknown [72.14.226.9]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 5A4F032230; Fri, 30 Jan 2015 15:32:08 -0500 (EST) In-Reply-To: <20150130200731.GC30738@peff.net> (Jeff King's message of "Fri, 30 Jan 2015 15:07:32 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Pobox-Relay-ID: 0FC1089C-A8BF-11E4-988F-7BA29F42C9D4-77302942!pb-smtp1.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Archived-At: Jeff King writes: > Hrm. That only works in the current code because we apply the deletion > in the directory (and then clean up the now-empty directory) first. So I > think you would need to check the paths progressively as you apply them, > since those other parts of the diff "haven't happened yet". Just to make sure that I am not hallucinating, I added this one: diff --git a/t/t4114-apply-typechange.sh b/t/t4114-apply-typechange.sh index ebadbc3..83ddf62 100755 --- a/t/t4114-apply-typechange.sh +++ b/t/t4114-apply-typechange.sh @@ -119,4 +119,12 @@ test_expect_success 'directory becomes symlink' ' test_debug 'cat patch' +test_expect_success 'directory becomes symlink' ' + git checkout -f foo-becomes-a-directory && + printf "%s\n" foo/baz foo >order && + git diff-tree -Oorder -p HEAD foo-symlinked-to-bar >patch && + git apply --index