From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: Re: bug: transform a binary file into a symlink in one commit => invalid binary patch Date: Sun, 25 Jan 2009 23:37:21 -0800 Message-ID: <7vy6wy8qmm.fsf@gitster.siamese.dyndns.org> References: <20090126003556.GA19368@coredump.intra.peff.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Pixel , git@vger.kernel.org To: Jeff King X-From: git-owner@vger.kernel.org Mon Jan 26 08:39:40 2009 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1LRM48-0004Jk-OH for gcvg-git-2@gmane.org; Mon, 26 Jan 2009 08:39:29 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751301AbZAZHha (ORCPT ); Mon, 26 Jan 2009 02:37:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751263AbZAZHh3 (ORCPT ); Mon, 26 Jan 2009 02:37:29 -0500 Received: from a-sasl-fastnet.sasl.smtp.pobox.com ([207.106.133.19]:61330 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751101AbZAZHh3 (ORCPT ); Mon, 26 Jan 2009 02:37:29 -0500 Received: from localhost.localdomain (unknown [127.0.0.1]) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTP id A364093033; Mon, 26 Jan 2009 02:37:27 -0500 (EST) Received: from pobox.com (unknown [68.225.240.211]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-sasl-fastnet.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 48E2793032; Mon, 26 Jan 2009 02:37:22 -0500 (EST) In-Reply-To: <20090126003556.GA19368@coredump.intra.peff.net> (Jeff King's message of "Sun, 25 Jan 2009 19:35:56 -0500") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) X-Pobox-Relay-ID: 2E4C3388-EB7C-11DD-B4BC-5720C92D7133-77302942!a-sasl-fastnet.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Jeff King writes: > On Fri, Jan 23, 2009 at 01:25:30PM +0100, Pixel wrote: > >> i hit a bug (git 1.6.1): when you transform a binary file into a >> symlink in one commit, the binary patch can't be used in "git apply". >> Is it a known issue? > > Not that I know of. > > Below is a patch against the test suite that fairly neatly displays the > problem. I didn't get a chance to look into actually fixing it, though > (I'm not even sure the problem is in apply, and not in the generated > patch). The generated diff is wrong. A filepair that changes type must be split into deletion followed by creation, which means the "index" line should say 0{40} on the right hand side for the first half and then 0{40} on the left hand side for the second half. The patch generated by this step: > +test_expect_success 'create patch' ' > + git diff-tree --binary HEAD^ HEAD >patch > +' However says the blob contents change from "\0" to "file" on both. This is because diff.c::run_diff() computes "index" only once and reuses it for both halves.