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, 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 15FE01F66F for ; Wed, 4 Nov 2020 13:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729089AbgKDNYa (ORCPT ); Wed, 4 Nov 2020 08:24:30 -0500 Received: from cloud.peff.net ([104.130.231.41]:47126 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728523AbgKDNY3 (ORCPT ); Wed, 4 Nov 2020 08:24:29 -0500 Received: (qmail 9699 invoked by uid 109); 4 Nov 2020 13:24:29 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 04 Nov 2020 13:24:29 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 10113 invoked by uid 111); 4 Nov 2020 13:24:28 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 04 Nov 2020 08:24:28 -0500 Authentication-Results: peff.net; auth=none Date: Wed, 4 Nov 2020 08:24:28 -0500 From: Jeff King To: Johannes Postler Cc: git@vger.kernel.org Subject: Re: [Bug report] Crash when creating patch Message-ID: <20201104132428.GA2491189@coredump.intra.peff.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Wed, Nov 04, 2020 at 11:18:10AM +0100, Johannes Postler wrote: > [josi@localhost typescript]$ git format-patch -1 236a9 > --output=/home/josi/tmp/patches/txt-6117.patch > 0001-Txture-Core-Implemented-whitelisting-for-groovy-scri.patch > free(): invalid pointer > Aborted (core dumped) Thanks for the report. I was able to reproduce the problem here. The issue is that "--output" was never supposed to work with format-patch. But a subtle change in the option parsing a while back caused it to be respected. And as you noticed, the documentation mistakenly mentions the option, since format-patch includes the standard diff-options text. So one obvious fix would be to forbid it and adjust the documentation. But because of the way the option parsers interact, it's surprisingly hard to do so cleanly. It's actually easier to just make it do something useful (i.e., behave like --stdout but sent to a file). So I did that instead. [1/3]: format-patch: refactor output selection [2/3]: format-patch: tie file-opening logic to output_directory [3/3]: format-patch: support --output option builtin/log.c | 37 ++++++++++++++++++++++--------------- t/t4014-format-patch.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 15 deletions(-) -Peff