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: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 AFAB61F5AE for ; Tue, 27 Apr 2021 05:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230039AbhD0FrS (ORCPT ); Tue, 27 Apr 2021 01:47:18 -0400 Received: from dcvr.yhbt.net ([64.71.152.64]:42162 "EHLO dcvr.yhbt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbhD0FrR (ORCPT ); Tue, 27 Apr 2021 01:47:17 -0400 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5A6371F5AE; Tue, 27 Apr 2021 05:46:32 +0000 (UTC) Date: Tue, 27 Apr 2021 05:46:32 +0000 From: Eric Wong To: Jerry Zhang Cc: git@vger.kernel.org, gitster@pobox.com, ross@skydio.com, abe@skydio.com, brian.kubisiak@skydio.com Subject: Re: [PATCH] git-apply: allow empty patch text Message-ID: <20210427054632.GA31347@dcvr> References: <20210427011246.28054-1-jerry@skydio.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210427011246.28054-1-jerry@skydio.com> Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Jerry Zhang wrote: > "git diff" produces no patch text if > there is no diff, but "git apply" exits > with code 128 if the patch text is empty. > > Since every valid "git diff" should > result in a successful patch application > when applied to the same preimage as > the diff, Should it result in successful patch application? (Why?) I fear this change can cause errors in pipelines to go undetected (since "set -o pipefail" is not POSIX). In my experience, zero-byte files is also a common failure mode for some filesystems, even after fsck marked them as clean. Perhaps guarding this behavior with --allow-empty (as commit and cherry-pick do) is safer. > diff --git a/t/t4126-apply-empty.sh b/t/t4126-apply-empty.sh > index ceb6a79fe0..37351be609 100755 > --- a/t/t4126-apply-empty.sh > +++ b/t/t4126-apply-empty.sh > @@ -31,6 +31,13 @@ test_expect_success 'apply empty' ' > test_cmp expect empty > ' > > +test_expect_success 'apply empty diff' ' > + git reset --hard && > + git diff >empty.patch && > + git apply empty.patch && > + git diff | git apply - > +' It shouldn't be necessary to use "git diff" to generate empty output. Tests are too slow for me on Linux, even. Something like: >empty.patch && git apply empty.patch && git apply -