From patchwork Tue Jan 22 00:26:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10774737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7207F746 for ; Tue, 22 Jan 2019 00:26:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62AF32AA3B for ; Tue, 22 Jan 2019 00:26:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 564DF2AA33; Tue, 22 Jan 2019 00:26:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2A662AA33 for ; Tue, 22 Jan 2019 00:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726451AbfAVA0o (ORCPT ); Mon, 21 Jan 2019 19:26:44 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:46743 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfAVA0n (ORCPT ); Mon, 21 Jan 2019 19:26:43 -0500 Received: by mail-pg1-f195.google.com with SMTP id w7so10157438pgp.13 for ; Mon, 21 Jan 2019 16:26:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vDuiZrbB0ahKTNzPP967r6ifOxUzBiA8g+PSGUTJRB8=; b=NenAJNNxaju+l6vNB/nwnzRRTbepm4xDmQ26pBAkisrOQ4qC+i0VonM8U6WCWcZ/5K pvTg87Jf3+5oayaJn4Qj6VYGXG5cKnOxyn7kRR+LdByDTDRaC79nofUap/9egHP/IRy8 iseiifGUtjiJ9BYlkqZkJZ39i6MtJygRiLSD5q/mTCYl1OLC7Dk3/ecP5UEClA2o9kTi OvfnrLJGb8ey2AOfKZ5lqQkMqMMawP+R4YpFD7o0Y0E4RT+W5TpKycTnBf8ni+qHnZbs RybFnrHodF4HPr+KI9/qXkynIcBVF+Fj84EqEDIEAaOPz2dTQHhy6FI7lVBTdC6jMTp9 DQ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vDuiZrbB0ahKTNzPP967r6ifOxUzBiA8g+PSGUTJRB8=; b=XSoT3Gt7Jhp/zLTq8bX0obQvpZFmr8Gm7vggsKax6Sm6MJk/B+2eHA3AG7PtF8MP9Z QB62wbGPZOJl4pilytNjHAR+ZVqQgfTYH+ylT8z+quz6PKtjc7j5Y5QVCiXE9viwsiv7 Y4DUBIiZj05GZYi887mbebXvPbTz7D6f8lIEcxibGfIHfxSi6fi0K9QO+BuuiH+vseUB 7T1vz0LcpyzSkz+4Crn+LOoaWV/2nioE/HDNl0hXnOfkCBvLQJ/lOH7t1kzSG2h0p6Iz v41LRJubACX6+G6dqclv9qkxmBiqdYlq0G/31JJ1gi43+9pBVD1O4GsyHIBV1hv28iST LpEA== X-Gm-Message-State: AJcUukdsBPqLncH9oGbtrP8FaLfx9v1w79esEwyfAQIuYqNqnjbj3ZsB +61lLDgXi0olhzIy12551sD4f+nO X-Google-Smtp-Source: ALg8bN6ENK3se5hkmE7+7UikmYFZ52iRmyW162XJdUabBtvir5pXZx75iz2ULoBXLkDdJSlXsRN1oA== X-Received: by 2002:a63:b81a:: with SMTP id p26mr30402608pge.433.1548116802464; Mon, 21 Jan 2019 16:26:42 -0800 (PST) Received: from dektop.dek-tpc.internal ([14.161.14.188]) by smtp.gmail.com with ESMTPSA id u123sm21306640pfb.1.2019.01.21.16.26.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 16:26:41 -0800 (PST) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Stefan Beller , =?utf-8?q?SZEDER_G=C3=A1bor?= , Johannes Schindelin , =?utf-8?b?Tmd1eeG7hW4g?= =?utf-8?b?VGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 1/3] Revert "parse-options: allow keep-unknown + stop-at-non-opt combination" Date: Tue, 22 Jan 2019 07:26:33 +0700 Message-Id: <20190122002635.9411-2-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.560.g70ca8b83ee In-Reply-To: <20190122002635.9411-1-pclouds@gmail.com> References: <20190122002635.9411-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit a85e5a01080e35da0f94bf98f5f334c64e214ce3, which is a revert of 0d260f9a09 (parseopt: prevent KEEP_UNKNOWN and STOP_AT_NON_OPTION from being used together - 2009-03-09). As described in 0d260f9a09, this option combination is tricky to get right and should be prevented unless you know what you're doing. In the one-shot mode, the diff and revision parsers are very well aware of remaining arguments being potentially unknown options or revisions and should handle the combination safely. Reinstate the check added by 0d260f9a09. Modify it a bit to let one-shot mode through. Noticed-by: Stefan Beller --- parse-options.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parse-options.c b/parse-options.c index a0ff8ea225..cec74522e5 100644 --- a/parse-options.c +++ b/parse-options.c @@ -466,6 +466,10 @@ void parse_options_start(struct parse_opt_ctx_t *ctx, ctx->prefix = prefix; ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0); ctx->flags = flags; + if ((flags & PARSE_OPT_KEEP_UNKNOWN) && + (flags & PARSE_OPT_STOP_AT_NON_OPTION) && + !(flags & PARSE_OPT_ONE_SHOT)) + BUG("STOP_AT_NON_OPTION and KEEP_UNKNOWN don't go together"); if ((flags & PARSE_OPT_ONE_SHOT) && (flags & PARSE_OPT_KEEP_ARGV0)) BUG("Can't keep argv0 if you don't have it"); From patchwork Tue Jan 22 00:26:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10774741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 56C50746 for ; Tue, 22 Jan 2019 00:26:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47CC22AA33 for ; Tue, 22 Jan 2019 00:26:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 398072AA3C; Tue, 22 Jan 2019 00:26:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D081D2AA33 for ; Tue, 22 Jan 2019 00:26:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbfAVA0q (ORCPT ); Mon, 21 Jan 2019 19:26:46 -0500 Received: from mail-pl1-f176.google.com ([209.85.214.176]:39532 "EHLO mail-pl1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfAVA0p (ORCPT ); Mon, 21 Jan 2019 19:26:45 -0500 Received: by mail-pl1-f176.google.com with SMTP id 101so10533667pld.6 for ; Mon, 21 Jan 2019 16:26:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nyqyKDWSpGUairiQnX03WBCZhkh/w4K549wITrlKrIM=; b=P9LLvnyo7ryEnrUc8qRfDUGLjEXqCf/kbpsA8pR9+ShCdP6gJUh4jAD7mzXaGbWfH7 SWiQR2OcBQ/Pdx+XRUwLAaX+3NMrZeyWHMfH5bsYmGW9ExAe6k+PzNo/M6X1XaDKuQ6u bzarWXHe/bEP5IN9cl4idJ2BX8C0mR/ncKAJ+xk2hcBedROGbKpNt0gM3pRKPmNmpfq7 FB880Q8E3ipRnwCprLLmJw5WLB5+5M++8HwxYiJpliTwEk/jEK2Mga7crbc59IU5ki4V UktDZXqW601iQnjrKp406u3cboYKpEhiwv+mBMdd8zjJMLoE/VkVGtn7C3kEJwmUHNkx Da0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nyqyKDWSpGUairiQnX03WBCZhkh/w4K549wITrlKrIM=; b=qC2ny3bcXz65Eba3zzbuP80cHxSl44HZEm8Aowqa9/la9pS/T0WYUo0IVxvtIxzIDY 87RTLUKnw99IFiK+38MrPcNW+ajm22zOZa7o/X8DEYKc4aURfQ81BHYbQvuPhJ1RBW4m 8fpMbkcRbC/9NZDgk1NzJvxy98bt7DaR2F+20jIucnO1SB1Gj8dDylvx0FSQDnTlLIoK uslcL9OFsTwVErFDzlG/YmfH6fLxhIPvziwcTZL3bDBOKqn9MmF5pmHGWJKtHZySbVRk 6k4e6MBUCJaPY4O8QtxJ2E6TMNQinVXVLmlTFzzl0TP5vp057pxuDuNxR17A06gcMU16 vjaw== X-Gm-Message-State: AJcUuke3uj0QIW4j6pI0FddDqf8zfAI27UWoydqNndZ5d0T9K5Q+OIr+ JTu+JwOPlMBm9HKvtBcGmYKfRFwp X-Google-Smtp-Source: ALg8bN5eLe8rWZFPrS3MvpB54cFaZl3GuhB9ojksTEZMvQgWSSzhP7Tqor2UD9kperGxNS71nPqNog== X-Received: by 2002:a17:902:8f83:: with SMTP id z3mr31252960plo.328.1548116804540; Mon, 21 Jan 2019 16:26:44 -0800 (PST) Received: from dektop.dek-tpc.internal ([14.161.14.188]) by smtp.gmail.com with ESMTPSA id u123sm21306640pfb.1.2019.01.21.16.26.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 16:26:44 -0800 (PST) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Stefan Beller , =?utf-8?q?SZEDER_G=C3=A1bor?= , Johannes Schindelin , =?utf-8?b?Tmd1eeG7hW4g?= =?utf-8?b?VGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 2/3] diff.c: delete unused functions Date: Tue, 22 Jan 2019 07:26:34 +0700 Message-Id: <20190122002635.9411-3-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.560.g70ca8b83ee In-Reply-To: <20190122002635.9411-1-pclouds@gmail.com> References: <20190122002635.9411-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After the parseopt conversion, a few functions are no longer needed. Delete them. Noticed-by: SZEDER Gábor Noticed-by: Johannes Schindelin --- diff.c | 65 ---------------------------------------------------------- 1 file changed, 65 deletions(-) diff --git a/diff.c b/diff.c index 747e691190..da5ba835ce 100644 --- a/diff.c +++ b/diff.c @@ -104,11 +104,6 @@ static const char *color_diff_slots[] = { [DIFF_FILE_NEW_BOLD] = "newBold", }; -static NORETURN void die_want_option(const char *option_name) -{ - die(_("option '%s' requires a value"), option_name); -} - define_list_config_array_extra(color_diff_slots, {"plain"}); static int parse_diff_color_slot(const char *var) @@ -4578,66 +4573,6 @@ void diff_setup_done(struct diff_options *options) FREE_AND_NULL(options->parseopts); } -static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val) -{ - char c, *eq; - int len; - - if (*arg != '-') - return 0; - c = *++arg; - if (!c) - return 0; - if (c == arg_short) { - c = *++arg; - if (!c) - return 1; - if (val && isdigit(c)) { - char *end; - int n = strtoul(arg, &end, 10); - if (*end) - return 0; - *val = n; - return 1; - } - return 0; - } - if (c != '-') - return 0; - arg++; - eq = strchrnul(arg, '='); - len = eq - arg; - if (!len || strncmp(arg, arg_long, len)) - return 0; - if (*eq) { - int n; - char *end; - if (!isdigit(*++eq)) - return 0; - n = strtoul(eq, &end, 10); - if (*end) - return 0; - *val = n; - } - return 1; -} - -static inline int short_opt(char opt, const char **argv, - const char **optarg) -{ - const char *arg = argv[0]; - if (arg[0] != '-' || arg[1] != opt) - return 0; - if (arg[2] != '\0') { - *optarg = arg + 2; - return 1; - } - if (!argv[1]) - die("Option '%c' requires a value", opt); - *optarg = argv[1]; - return 2; -} - int parse_long_opt(const char *opt, const char **argv, const char **optarg) { From patchwork Tue Jan 22 00:26:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10774739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D95676C2 for ; Tue, 22 Jan 2019 00:26:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C973E2AA33 for ; Tue, 22 Jan 2019 00:26:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD89C2AA3C; Tue, 22 Jan 2019 00:26:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7834C2AA33 for ; Tue, 22 Jan 2019 00:26:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726682AbfAVA0s (ORCPT ); Mon, 21 Jan 2019 19:26:48 -0500 Received: from mail-pl1-f175.google.com ([209.85.214.175]:46947 "EHLO mail-pl1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbfAVA0r (ORCPT ); Mon, 21 Jan 2019 19:26:47 -0500 Received: by mail-pl1-f175.google.com with SMTP id t13so10527798ply.13 for ; Mon, 21 Jan 2019 16:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XaCP/E5Z++2qkz2B4bFDcEhzeP6npECxKatP+i0FYOk=; b=d5A13q3GRhvJ56ThI5GsypumOD2rPc85pwpts2EHbhyRUpzsEJWLit/xlBmSc15QF3 Rp+hEae31UptxpFxeVjIu0AHfZMOfQqCNFPW0hNMFzZPyQqO3k0Hwn2OlhSP3zM+Sn/j A0wYinhBUav1+D7TKKrgOfHIl0vECBybc9j7MltY65M5dxboxHu3RP/KvbW/yBqN0BTN /lJ9dnD/v5UkvQCjqms4ETHCJdNk5fBxm0hesLL3aMnmwxG+jhozKpzZCC5Qk5DymYdF En6p8VvTTjN/dPgJ4Mj+imQ+cIa5/BCB3eK/6+6SpYbgpXHGFSH09h0QBqdrYou43qfj USrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XaCP/E5Z++2qkz2B4bFDcEhzeP6npECxKatP+i0FYOk=; b=lshMcHqcv1LsOzt9uPxkLuuCOxxGjLTM6M5gATiZ6tDkL8qaZ4Wxy5RpDMzpLen4/C /1rgKEuBJZ3le1RHGNAuangCPiC4RXTB45v/FoNprXsQ47wXOR8cWIDplNzFuBJ/hvWH kh4P3+xC8nhtupEvncPZBCgW0VlZtrujP3AwiOlfoXXN51tYInfgr7Dtcf1JuWW5knMK yAjmHKbWMWZgqKALh8tEZQFl4QIHW/OTuhyS5EGdFxX8CizPuZYavmJGL175VkMfTxl/ S0xg214QaCCo3cvASAxpSTLPFqos02vQNeIy22gX9/lwv4hopSu/XHMRMJT+WeOw3wJe dWIw== X-Gm-Message-State: AJcUukcwngWQIeL2A45dMlNSvxG25n5vrqW+eI8IK4aXFArOomp/VGag guibeFY59V1yRySUbcJ62vhy6fUG X-Google-Smtp-Source: ALg8bN40gjrxRwvgNccaVY+Dv0NJ0ffPUxRXP2rUlPvC2MGsOmsiUbOKdEBsLAFWOePf2RC2BTyu3A== X-Received: by 2002:a17:902:a58a:: with SMTP id az10mr32631873plb.10.1548116806761; Mon, 21 Jan 2019 16:26:46 -0800 (PST) Received: from dektop.dek-tpc.internal ([14.161.14.188]) by smtp.gmail.com with ESMTPSA id u123sm21306640pfb.1.2019.01.21.16.26.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 16:26:46 -0800 (PST) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Stefan Beller , =?utf-8?q?SZEDER_G=C3=A1bor?= , Johannes Schindelin , =?utf-8?b?Tmd1eeG7hW4g?= =?utf-8?b?VGjDoWkgTmfhu41jIER1eQ==?= Subject: [PATCH 3/3] diff.c: simplify diff_opt_break_rewrites() Date: Tue, 22 Jan 2019 07:26:35 +0700 Message-Id: <20190122002635.9411-4-pclouds@gmail.com> X-Mailer: git-send-email 2.20.1.560.g70ca8b83ee In-Reply-To: <20190122002635.9411-1-pclouds@gmail.com> References: <20190122002635.9411-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Helped-by: Johannes Schindelin --- diff.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/diff.c b/diff.c index da5ba835ce..2351571251 100644 --- a/diff.c +++ b/diff.c @@ -4814,20 +4814,15 @@ static int diff_opt_break_rewrites(const struct option *opt, const char *arg, int unset) { int *break_opt = opt->value; - int opt1, opt2; + int opt1, opt2 = 0; BUG_ON_OPT_NEG(unset); if (!arg) arg = ""; opt1 = parse_rename_score(&arg); - switch (*arg) { - case '\0': - opt2 = 0; - break; - case '/': + if (*arg == '/') { arg++; opt2 = parse_rename_score(&arg); - break; } if (*arg != 0) return error(_("%s expects / form"), opt->long_name);