From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthieu Moy Subject: Re: [PATCH] send-pack: use buffered I/O to talk to pack-objects Date: Thu, 09 Jun 2016 19:22:21 +0200 Message-ID: References: <20160606151340.22424-1-william.duclot@ensimag.grenoble-inp.fr> <20160606151340.22424-4-william.duclot@ensimag.grenoble-inp.fr> <20160606203901.GA7667@Messiaen> <20160606225847.GA22756@sigill.intra.peff.net> <20160607090653.GA4665@Messiaen> <575845D9.2010604@alum.mit.edu> <20160608191918.GB19572@sigill.intra.peff.net> <20160608194216.GA3731@sigill.intra.peff.net> Mime-Version: 1.0 Content-Type: text/plain Cc: Jeff King , Michael Haggerty , William Duclot , git@vger.kernel.org, antoine.queru@ensimag.grenoble-inp.fr, francois.beutin@ensimag.grenoble-inp.fr, Johannes.Schindelin@gmx.de, mh@glandium.org To: Junio C Hamano X-From: git-owner@vger.kernel.org Thu Jun 09 19:22:49 2016 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bB3fM-0008UL-PT for gcvg-git-2@plane.gmane.org; Thu, 09 Jun 2016 19:22:49 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932594AbcFIRWj (ORCPT ); Thu, 9 Jun 2016 13:22:39 -0400 Received: from mx2.imag.fr ([129.88.30.17]:46551 "EHLO mx2.imag.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932249AbcFIRWj (ORCPT ); Thu, 9 Jun 2016 13:22:39 -0400 Received: from clopinette.imag.fr (clopinette.imag.fr [129.88.34.215]) by mx2.imag.fr (8.13.8/8.13.8) with ESMTP id u59HMJjZ012596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 9 Jun 2016 19:22:19 +0200 Received: from anie (anie.imag.fr [129.88.42.32]) by clopinette.imag.fr (8.13.8/8.13.8) with ESMTP id u59HMLYl010324; Thu, 9 Jun 2016 19:22:21 +0200 In-Reply-To: (Junio C. Hamano's message of "Thu, 09 Jun 2016 09:40:42 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (mx2.imag.fr [129.88.30.17]); Thu, 09 Jun 2016 19:22:20 +0200 (CEST) X-IMAG-MailScanner-Information: Please contact MI2S MIM for more information X-MailScanner-ID: u59HMJjZ012596 X-IMAG-MailScanner: Found to be clean X-IMAG-MailScanner-SpamCheck: X-IMAG-MailScanner-From: matthieu.moy@grenoble-inp.fr MailScanner-NULL-Check: 1466097743.15532@2y4wUSuQd/8kGENCz2/Lnw Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Junio C Hamano writes: > Matthieu Moy writes: > >> Jeff King writes: >> >>> --- a/send-pack.c >>> +++ b/send-pack.c >>> @@ -36,18 +36,15 @@ int option_parse_push_signed(const struct option *opt, >>> die("bad %s argument: %s", opt->long_name, arg); >>> } >>> >>> -static int feed_object(const unsigned char *sha1, int fd, int negative) >>> +static void feed_object(const unsigned char *sha1, FILE *fh, int negative) >>> { >>> - char buf[42]; >>> - >>> if (negative && !has_sha1_file(sha1)) >>> - return 1; >>> + return; >> [...] >>> @@ -97,21 +95,22 @@ static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, stru >> [...] >>> for (i = 0; i < extra->nr; i++) >>> - if (!feed_object(extra->sha1[i], po.in, 1)) >>> - break; >>> + feed_object(extra->sha1[i], po_in, 1); >> >> I may have missed the obvious, but doesn't this change the behavior when >> "negative && !has_sha1_file(sha1)" happens? I understand that you don't >> need write_or_whine anymore, but don't understand how you get rid of the >> "return 1" here. > > The original feed_object() has somewhat strange interface in that a > non-zero return from it is "Everything went alright!", and zero > means "Oops, something went wrong". Indeed, this is the "obvious" I've missed. So, indeed, the new "return" does the same thing as the old "return 1". -- Matthieu Moy http://www-verimag.imag.fr/~moy/