From patchwork Thu Jul 7 15:23:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 1653666 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=WsDTOad8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lf0cZ1NNXz9s0w for ; Fri, 8 Jul 2022 01:26:22 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14AAD8455C; Thu, 7 Jul 2022 17:26:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="WsDTOad8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8E56384574; Thu, 7 Jul 2022 17:26:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0880884563 for ; Thu, 7 Jul 2022 17:26:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dianders@chromium.org Received: by mail-pf1-x42c.google.com with SMTP id b9so4047814pfp.10 for ; Thu, 07 Jul 2022 08:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IFTsrFHWVKsBaK/j9t8ukT3LqbnFzUd4GYANWpx/9dU=; b=WsDTOad8ah90qiL9hIKXi6Ju74/LzFZGWvquCnsQgHRRwaauiHm+NA5iYxwXS+kpKP O4vE4iMJlmhDF3xVbN0rCU6RkSaS0bI/LtlrVU39R7OVlZ4/RCUH8IoZF4DItyevkXjZ Y3c/zS0zzpuI92efnyrjujYuOJVCv+1Hy8+/M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IFTsrFHWVKsBaK/j9t8ukT3LqbnFzUd4GYANWpx/9dU=; b=wAe6y+0//ELJYhu/fPbgv39/XISxCSMNcBb8+9yKo53MYkaZGsVW9ysqPceZHAY3L1 DrN8yjbfevR0G4bdK1vNeeoOvRUzBJVfG17O0RhZmsY6HHk90hDkUUd1BkTkKnwO0tjd PkGYFsIZw/5uKwEibTWdpUXxK20/M5ywoQSGqUCJ7HIKFiLLtLuS8irhCJatd+0e1FPa hvFl6VBCUH5nka31zX0S7PrVIlbE/RtgXBvCbuQn+f8tQDMmRxdTeDCaPLSEibBcQOHS ae1hZFdz3wV2c5w3T3OlNnFJLxVq/wVPUdwWWaMG3iUrSaKr+SnwWUXOufiaF+oL6htx friA== X-Gm-Message-State: AJIora9rEoaS5fWD4l0ItA8P9EOr0sH7NPj48Se60CVWppkqXwPRn/Mo FZ9vDpzSCgldcfOfnFpZqpHABQ== X-Google-Smtp-Source: AGRyM1v1cdLEenBcGp6trfFfrUyqt+PgBsIwxA27pAQ/2O92q4pv5cCnGZ4WOPNwqXYsiD51/VR23w== X-Received: by 2002:a05:6a02:113:b0:412:a7c0:da8e with SMTP id bg19-20020a056a02011300b00412a7c0da8emr6950591pgb.113.1657207563153; Thu, 07 Jul 2022 08:26:03 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:2c8:c510:a4e9:5da3]) by smtp.gmail.com with ESMTPSA id na7-20020a17090b4c0700b001ecb5a6385bsm17146055pjb.36.2022.07.07.08.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 08:26:02 -0700 (PDT) From: Douglas Anderson To: sjg@chromium.org Cc: amstan@chromium.org, mka@chromium.org, Sean Anderson , briannorris@chromium.org, Douglas Anderson , u-boot@lists.denx.de Subject: [PATCH v3 1/5] patman: Fix implicit command inserting Date: Thu, 7 Jul 2022 08:23:49 -0700 Message-Id: <20220707082245.v3.1.I04290e8071b92140ad565ea7397ce8604de743fe@changeid> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220707152353.1854462-1-dianders@chromium.org> References: <20220707152353.1854462-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The logic to insert an implicit command has always been a bit broken but it was masked by another bug fixed in the patch ("patman: Don't look at sys.argv when parsing settings"). Specifically, imagine that you're just calling patman like this: patman -c1 After the parse_known_args() command then the "-c1" will have been parsed and we'll have no command. The "rest" variable will be an empty list. Going into the logic you can see that nargs = 0. The implicit insertion of send ideally would create an argument list of: ['-c1', 'send'] ...but it doesn't because argv[:-0] is the same as argv[:0] and that's an empty list. Let's fix this little glitch. Signed-off-by: Douglas Anderson Tested-by: Brian Norris Reviewed-by: Brian Norris Reviewed-by: Simon Glass Signed-off-by: Douglas Anderson Tested-by: Brian Norris Reviewed-by: Brian Norris Reviewed-by: Simon Glass --- (no changes since v1) tools/patman/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/patman/main.py b/tools/patman/main.py index 66d4806c8d8f..e868878ad5a7 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -119,7 +119,9 @@ else: # No command, so insert it after the known arguments and before the ones # that presumably relate to the 'send' subcommand nargs = len(rest) - argv = argv[:-nargs] + ['send'] + rest + if nargs: + argv = argv[:-nargs] + argv = argv + ['send'] + rest args = parser.parse_args(argv) if __name__ != "__main__": From patchwork Thu Jul 7 15:23:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 1653667 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Jl3roiRg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lf0cm1dZQz9s0w for ; Fri, 8 Jul 2022 01:26:32 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9D9F684576; Thu, 7 Jul 2022 17:26:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Jl3roiRg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4AA984576; Thu, 7 Jul 2022 17:26:08 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CAC118456B for ; Thu, 7 Jul 2022 17:26:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dianders@chromium.org Received: by mail-pg1-x52a.google.com with SMTP id s27so19107506pga.13 for ; Thu, 07 Jul 2022 08:26:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mjerIvCJd4QSoFugZ2oIBoKQvH3M7GFQDkpR9ZhAF08=; b=Jl3roiRgQw/W6B4MCp4+qehdakAz57pguyhujun5ieEf3Kf0cOwal9/WmlaKnwvtkM pjWSZBx037XKGGUoe+ccIBtcglcADEsQFxplERg7Qwx1tuRXa1Ooyt/3ZfN1gpxbZ3LD c8Tw6Y5pwA5Eqjh9E1FvS1mx/o6g6lXr/HQxI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mjerIvCJd4QSoFugZ2oIBoKQvH3M7GFQDkpR9ZhAF08=; b=Kq2InhJx46GVdY9S+mv1XPQmDsDoIJnyPVD8RVWqKLLu25QzEQGkS4T017BB6bHf64 ghHaVbcBq5+nNWuHz6nEXr4HVH/aQBDZCIQIYbLJgY6uKPbj22WRmfw9pLxrGJO1xsG9 jeykOQKuZRlPzq91lMlO/gUhxU5w/m57ij066bLAv6SHF83e0jd6W5wV+uFQZViHJhDj VUJPBcHNaGrCqkBFgEbS1WNdUP00gWBpKFtMOP1QNpuBBXB2n+PE9k9gDHKZ/Wm/sUh1 5EobaedYzMqHInDZqN71M67bmOMMP2FhLzoUrNsEB4gQuwxbCLq4mnxOoFF7QseJKkEQ CqTA== X-Gm-Message-State: AJIora/8MJFVa+MeGVPiNKr9Xgevb7xWtz/lRHhwsweWYEwIXnvWoyaL 2lunEhHdVo13qSg/ryfV9HZt3A== X-Google-Smtp-Source: AGRyM1tRliSsKNXPbmbPAavIgQvAEtO+Kw8NgFuGul1xAH39/2WvwMQhkKxRNpzRT5UJ08pIwwhqqw== X-Received: by 2002:a17:90b:48c7:b0:1ef:a692:9593 with SMTP id li7-20020a17090b48c700b001efa6929593mr5896107pjb.184.1657207564200; Thu, 07 Jul 2022 08:26:04 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:2c8:c510:a4e9:5da3]) by smtp.gmail.com with ESMTPSA id na7-20020a17090b4c0700b001ecb5a6385bsm17146055pjb.36.2022.07.07.08.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 08:26:03 -0700 (PDT) From: Douglas Anderson To: sjg@chromium.org Cc: amstan@chromium.org, mka@chromium.org, Sean Anderson , briannorris@chromium.org, Douglas Anderson , u-boot@lists.denx.de Subject: [PATCH v3 2/5] patman: Don't look at sys.argv when parsing settings Date: Thu, 7 Jul 2022 08:23:50 -0700 Message-Id: <20220707082245.v3.2.I7a1d18f39af70389a687dedef421cda4d0ae35a9@changeid> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220707152353.1854462-1-dianders@chromium.org> References: <20220707152353.1854462-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean If you call the parser and tell it to parse but don't pass arguments in then it will default to looking at sys.argv. This isn't really what was intended and seems to have some side effects. Let's not do it. NOTE: to see some of the side effects, note that this patch breaks "patman -c1" if you don't have the patch ("patman: Fix implicit command inserting") before it. Signed-off-by: Douglas Anderson Tested-by: Brian Norris Reviewed-by: Brian Norris Reviewed-by: Simon Glass Signed-off-by: Douglas Anderson Tested-by: Brian Norris Reviewed-by: Brian Norris Reviewed-by: Simon Glass --- Changes in v3: - Rebased atop ("patman: Fix defaults not propagating to subparsers") tools/patman/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/patman/settings.py b/tools/patman/settings.py index 4c847fe88fd4..6c5f6c8ed992 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -248,7 +248,7 @@ def _UpdateDefaults(main_parser, config): defaults = {} parser_defaults = [] for parser in parsers: - pdefs = parser.parse_known_args()[0] + pdefs = parser.parse_known_args([])[0] parser_defaults.append(pdefs) defaults.update(vars(pdefs)) From patchwork Thu Jul 7 15:23:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 1653668 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=bwye8gxz; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lf0cy5dF3z9s0w for ; Fri, 8 Jul 2022 01:26:42 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3117E84580; Thu, 7 Jul 2022 17:26:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bwye8gxz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D1E7D8456B; Thu, 7 Jul 2022 17:26:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A8D1382142 for ; Thu, 7 Jul 2022 17:26:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dianders@chromium.org Received: by mail-pf1-x430.google.com with SMTP id w185so16358909pfb.4 for ; Thu, 07 Jul 2022 08:26:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3/LMDTIpBc8rfqolJTXVSgNsQ5NtUDmg2yHvTYvS7/g=; b=bwye8gxz08/Hq1SvmMHNJSPcWLGtZIlOEP/y0PbsrKUBKtSHe1AcD5tF+OCu8KRUa1 Vklayj94abY+0hxYKB/0TeQ9heOBn9QCpDSpkhG10bi6lAcp4eqIwXqepH6a3Vvdvm1O mvKMXru+1nT7kyjKkWuelxZ0rVnQTUtstUZlo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3/LMDTIpBc8rfqolJTXVSgNsQ5NtUDmg2yHvTYvS7/g=; b=bRu8axqh9fP7YnsGx6CUN9oZSUExvcRfWtr88knoo/rKM+T4fW3D96F13/Zp2jZfgp 7p0BDNOdBwXvTbFFXl8S1AifK3UkFsJZRkfn5Vh5R2qEEWutb0KuSbDL54N98d2VjLQU NSQm1fQQAAWnMImUpXxElJ/9cz8uvq2eBwLEiGSKP2LsF//CSo0Pj27tXFF0663UonQy 1aGhFPNQEwEEEeIO4nybwIwvMGHiDJr9r6FO4X9H2KPPXv9FXmKwx29LX3XC+FND7YhG 7koIsRZIjSFAn26fqRvPT62kEaeYmSEZn4mhqwdiuMlPVbJX3OBpaZcBjvnCeiNrKtPO i0sA== X-Gm-Message-State: AJIora+ux8uAV+6U3ewl0i5VM4p3+NObmbuoow8dZCbW7Tq1zT91G/gn 8785OMqsUlIDIuWHSVOkFmJLog== X-Google-Smtp-Source: AGRyM1vtfU+SkejVLbyOyb02Ahql/s3lpT1S33iGp1zIhDFkHj72a037EeXPgCt1pmMXGqMGazGlZw== X-Received: by 2002:a63:8542:0:b0:415:3194:cc76 with SMTP id u63-20020a638542000000b004153194cc76mr1264807pgd.431.1657207565054; Thu, 07 Jul 2022 08:26:05 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:2c8:c510:a4e9:5da3]) by smtp.gmail.com with ESMTPSA id na7-20020a17090b4c0700b001ecb5a6385bsm17146055pjb.36.2022.07.07.08.26.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 08:26:04 -0700 (PDT) From: Douglas Anderson To: sjg@chromium.org Cc: amstan@chromium.org, mka@chromium.org, Sean Anderson , briannorris@chromium.org, Douglas Anderson , u-boot@lists.denx.de Subject: [PATCH v3 3/5] patman: Make most bool arguments BooleanOptionalAction Date: Thu, 7 Jul 2022 08:23:51 -0700 Message-Id: <20220707082245.v3.3.I6cb1a37e190dd759acc478beb2b0e0dc8e483923@changeid> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220707152353.1854462-1-dianders@chromium.org> References: <20220707152353.1854462-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean For boolean arguments it's convenient to be able to specify both the argument and its opposite on the command line. This is especially convenient because you can change the default via the settings file and being able express the opposite can be the only way to override things. Luckily python handles this well--we just need to specify things with BooleanOptionalAction. We'll do that for all options except "full-help" (where it feels silly). This uglifies the help text a little bit but does give maximum flexibility. Signed-off-by: Douglas Anderson Tested-by: Brian Norris Reviewed-by: Brian Norris Reviewed-by: Simon Glass --- (no changes since v2) Changes in v2: - Fix doc string for --ignore-bad-tags tools/patman/main.py | 55 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/tools/patman/main.py b/tools/patman/main.py index e868878ad5a7..56dcde1f9ef3 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -6,7 +6,7 @@ """See README for more information""" -from argparse import ArgumentParser +from argparse import ArgumentParser, BooleanOptionalAction import os import re import shutil @@ -39,7 +39,7 @@ parser.add_argument('-c', '--count', dest='count', type=int, default=-1, help='Automatically create patches from top n commits') parser.add_argument('-e', '--end', type=int, default=0, help='Commits to skip at end of patch list') -parser.add_argument('-D', '--debug', action='store_true', +parser.add_argument('-D', '--debug', action=BooleanOptionalAction, help='Enabling debugging (provides a full traceback on error)') parser.add_argument('-p', '--project', default=project.detect_project(), help="Project name; affects default option values and " @@ -49,42 +49,43 @@ parser.add_argument('-P', '--patchwork-url', help='URL of patchwork server [default: %(default)s]') parser.add_argument('-s', '--start', dest='start', type=int, default=0, help='Commit to start creating patches from (0 = HEAD)') -parser.add_argument('-v', '--verbose', action='store_true', dest='verbose', - default=False, help='Verbose output of errors and warnings') +parser.add_argument('-v', '--verbose', action=BooleanOptionalAction, + dest='verbose', default=False, + help='Verbose output of errors and warnings') parser.add_argument('-H', '--full-help', action='store_true', dest='full_help', default=False, help='Display the README file') subparsers = parser.add_subparsers(dest='cmd') send = subparsers.add_parser('send') -send.add_argument('-i', '--ignore-errors', action='store_true', - dest='ignore_errors', default=False, - help='Send patches email even if patch errors are found') +send.add_argument('-i', '--ignore-errors', action=BooleanOptionalAction, + dest='ignore_errors', default=False, + help='Send patches email even if patch errors are found') send.add_argument('-l', '--limit-cc', dest='limit', type=int, default=None, help='Limit the cc list to LIMIT entries [default: %(default)s]') -send.add_argument('-m', '--no-maintainers', action='store_false', - dest='add_maintainers', default=True, - help="Don't cc the file maintainers automatically") -send.add_argument('-n', '--dry-run', action='store_true', dest='dry_run', - default=False, help="Do a dry run (create but don't email patches)") +send.add_argument('-m', '--maintainers', action=BooleanOptionalAction, + dest='add_maintainers', default=True, + help="cc the file maintainers automatically") +send.add_argument('-n', '--dry-run', action=BooleanOptionalAction, + dest='dry_run', default=False, + help="Do a dry run (create but don't email patches)") send.add_argument('-r', '--in-reply-to', type=str, action='store', help="Message ID that this series is in reply to") -send.add_argument('-t', '--ignore-bad-tags', action='store_true', - default=False, - help='Ignore bad tags / aliases (default=warn)') -send.add_argument('-T', '--thread', action='store_true', dest='thread', +send.add_argument('-t', '--ignore-bad-tags', action=BooleanOptionalAction, + default=False, help='Ignore bad tags / aliases') +send.add_argument('-T', '--thread', action=BooleanOptionalAction, dest='thread', default=False, help='Create patches as a single thread') send.add_argument('--cc-cmd', dest='cc_cmd', type=str, action='store', default=None, help='Output cc list for patch file (used by git)') -send.add_argument('--no-binary', action='store_true', dest='ignore_binary', - default=False, - help="Do not output contents of changes in binary files") -send.add_argument('--no-check', action='store_false', dest='check_patch', +send.add_argument('--binary', action=BooleanOptionalAction, + dest='ignore_binary', default=False, + help="Output contents of changes in binary files") +send.add_argument('--check', action=BooleanOptionalAction, dest='check_patch', default=True, - help="Don't check for patch compliance") -send.add_argument('--no-tags', action='store_false', dest='process_tags', - default=True, help="Don't process subject tags as aliases") -send.add_argument('--no-signoff', action='store_false', dest='add_signoff', - default=True, help="Don't add Signed-off-by to patches") + help="Check for patch compliance") +send.add_argument('--tags', action=BooleanOptionalAction, dest='process_tags', + default=True, help="Process subject tags as aliases") +send.add_argument('--signoff', action=BooleanOptionalAction, dest='add_signoff', + default=True, help="Add Signed-off-by to patches") send.add_argument('--smtp-server', type=str, help="Specify the SMTP server to 'git send-email'") @@ -96,11 +97,11 @@ test_parser.add_argument('testname', type=str, default=None, nargs='?', status = subparsers.add_parser('status', help='Check status of patches in patchwork') -status.add_argument('-C', '--show-comments', action='store_true', +status.add_argument('-C', '--show-comments', action=BooleanOptionalAction, help='Show comments from each patch') status.add_argument('-d', '--dest-branch', type=str, help='Name of branch to create with collected responses') -status.add_argument('-f', '--force', action='store_true', +status.add_argument('-f', '--force', action=BooleanOptionalAction, help='Force overwriting an existing branch') # Parse options twice: first to get the project and second to handle From patchwork Thu Jul 7 15:23:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 1653669 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=BeiS4e5U; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lf0dB00xtz9s0w for ; Fri, 8 Jul 2022 01:26:53 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6BF4384578; Thu, 7 Jul 2022 17:26:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BeiS4e5U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6091D8456B; Thu, 7 Jul 2022 17:26:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7C7B084573 for ; Thu, 7 Jul 2022 17:26:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dianders@chromium.org Received: by mail-pf1-x433.google.com with SMTP id g126so5654260pfb.3 for ; Thu, 07 Jul 2022 08:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ryac+Xj+efBKFcrCFDK4Bh7+Br9hAVwHJXZxnfMueQQ=; b=BeiS4e5UI3xEYTD5ykTbSo2QWOwQBezVeUfTV2CqhpEJTCmLnOGCq5u3/hrODmI3/g fSNouX5cBeDQd3mi8lym3oIJ/x1eewYPgn/GpcvjTnjJI/Ou9BdD+CqbormtLe8PyV28 ia6LF5cq7zVWGJkCwxQSlqDOZs+WZT2KCghBw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ryac+Xj+efBKFcrCFDK4Bh7+Br9hAVwHJXZxnfMueQQ=; b=jaXs6MX5aFMShf/ETQXjL1A5E7PrnqJU3ScVveGFnHzoGmgJIh/dcN/YQMPF4fYxFp vH9sNvyo393IbTgXo5mooRXhR46G/EoZuHqjMl0V9BqLH+5jrmhOQ5HxO/Gl4vSAhPts PioKVsz915ek+8mSsy8T++GcKuI8gYfdAVpN/lY+Sovyi99zrKrpAzUO34ZmmXxAUhlX 7UgTswEWBYLcTQSzyRPb7FUQg897Eo6iyXNC/vOKvywdWkip4yUAL3P07sbNdQog60TW YdGfefqF5Lj+VLvsu6G6EmczQyrqHqDOOENZU9l+Vkw+wUbIciWqKtiuTX+ZG4V5FZ6N NK9A== X-Gm-Message-State: AJIora+8OIGW99YtnLEIPZLuYB2dtDy0d+OfALKP5bVS1LeI6spw5m4G E0XNPFhE39KYhQ3T086X5fzJFw== X-Google-Smtp-Source: AGRyM1syolJI2GnK1ARYwJYaSyNgUGuRQn77miwM5ZV2to/VFnp4XGyj3XGeIHjk49F9zPhxOIAy5Q== X-Received: by 2002:a63:1e49:0:b0:3fd:cf48:3694 with SMTP id p9-20020a631e49000000b003fdcf483694mr40477560pgm.275.1657207565887; Thu, 07 Jul 2022 08:26:05 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:2c8:c510:a4e9:5da3]) by smtp.gmail.com with ESMTPSA id na7-20020a17090b4c0700b001ecb5a6385bsm17146055pjb.36.2022.07.07.08.26.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 08:26:05 -0700 (PDT) From: Douglas Anderson To: sjg@chromium.org Cc: amstan@chromium.org, mka@chromium.org, Sean Anderson , briannorris@chromium.org, Douglas Anderson , u-boot@lists.denx.de Subject: [PATCH v3 4/5] patman: By default don't pass "--no-tree" to checkpatch for linux Date: Thu, 7 Jul 2022 08:23:52 -0700 Message-Id: <20220707082245.v3.4.I49504c16c5fc1e32629ab7c3e2a4702c79f3da11@changeid> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220707152353.1854462-1-dianders@chromium.org> References: <20220707152353.1854462-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean When you pass "--no-tree" to checkpatch it disables some extra checks that are important for Linux. Specifically I want checks like: warning: DT compatible string "boogie,woogie" appears un-documented check ./Documentation/devicetree/bindings/ Let's make the default for Linux to _not_ pass --no-tree. We'll have a config option and command line flag to override. Signed-off-by: Douglas Anderson Tested-by: Brian Norris Reviewed-by: Brian Norris Reviewed-by: Simon Glass --- (no changes since v1) tools/patman/checkpatch.py | 11 +++++++---- tools/patman/control.py | 7 ++++--- tools/patman/main.py | 3 +++ tools/patman/settings.py | 3 ++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py index 70ba561c2686..d1b902dd9627 100644 --- a/tools/patman/checkpatch.py +++ b/tools/patman/checkpatch.py @@ -186,7 +186,7 @@ def check_patch_parse(checkpatch_output, verbose=False): return result -def check_patch(fname, verbose=False, show_types=False): +def check_patch(fname, verbose=False, show_types=False, use_tree=False): """Run checkpatch.pl on a file and parse the results. Args: @@ -194,6 +194,7 @@ def check_patch(fname, verbose=False, show_types=False): verbose: True to print out every line of the checkpatch output as it is parsed show_types: Tell checkpatch to show the type (number) of each message + use_tree (bool): If False we'll pass '--no-tree' to checkpatch. Returns: namedtuple containing: @@ -210,7 +211,9 @@ def check_patch(fname, verbose=False, show_types=False): stdout: Full output of checkpatch """ chk = find_check_patch() - args = [chk, '--no-tree'] + args = [chk] + if not use_tree: + args.append('--no-tree') if show_types: args.append('--show-types') output = command.output(*args, fname, raise_on_error=False) @@ -236,13 +239,13 @@ def get_warning_msg(col, msg_type, fname, line, msg): line_str = '' if line is None else '%d' % line return '%s:%s: %s: %s\n' % (fname, line_str, msg_type, msg) -def check_patches(verbose, args): +def check_patches(verbose, args, use_tree): '''Run the checkpatch.pl script on each patch''' error_count, warning_count, check_count = 0, 0, 0 col = terminal.Color() for fname in args: - result = check_patch(fname, verbose) + result = check_patch(fname, verbose, use_tree=use_tree) if not result.ok: error_count += result.errors warning_count += result.warnings diff --git a/tools/patman/control.py b/tools/patman/control.py index b40382388e07..bf426cf7bcf4 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -64,7 +64,7 @@ def prepare_patches(col, branch, count, start, end, ignore_binary, signoff): patchstream.insert_cover_letter(cover_fname, series, to_do) return series, cover_fname, patch_files -def check_patches(series, patch_files, run_checkpatch, verbose): +def check_patches(series, patch_files, run_checkpatch, verbose, use_tree): """Run some checks on a set of patches This santiy-checks the patman tags like Series-version and runs the patches @@ -77,6 +77,7 @@ def check_patches(series, patch_files, run_checkpatch, verbose): run_checkpatch (bool): True to run checkpatch.pl verbose (bool): True to print out every line of the checkpatch output as it is parsed + use_tree (bool): If False we'll pass '--no-tree' to checkpatch. Returns: bool: True if the patches had no errors, False if they did @@ -86,7 +87,7 @@ def check_patches(series, patch_files, run_checkpatch, verbose): # Check the patches, and run them through 'git am' just to be sure if run_checkpatch: - ok = checkpatch.check_patches(verbose, patch_files) + ok = checkpatch.check_patches(verbose, patch_files, use_tree) else: ok = True return ok @@ -165,7 +166,7 @@ def send(args): col, args.branch, args.count, args.start, args.end, args.ignore_binary, args.add_signoff) ok = check_patches(series, patch_files, args.check_patch, - args.verbose) + args.verbose, args.check_patch_use_tree) ok = ok and gitutil.check_suppress_cc_config() diff --git a/tools/patman/main.py b/tools/patman/main.py index 56dcde1f9ef3..468ebf814fbc 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -82,6 +82,9 @@ send.add_argument('--binary', action=BooleanOptionalAction, send.add_argument('--check', action=BooleanOptionalAction, dest='check_patch', default=True, help="Check for patch compliance") +send.add_argument('--tree', action=BooleanOptionalAction, + dest='check_patch_use_tree', default=False, + help="If False, pass '--no-tree' to checkpatch") send.add_argument('--tags', action=BooleanOptionalAction, dest='process_tags', default=True, help="Process subject tags as aliases") send.add_argument('--signoff', action=BooleanOptionalAction, dest='add_signoff', diff --git a/tools/patman/settings.py b/tools/patman/settings.py index 6c5f6c8ed992..cee18bf01a65 100644 --- a/tools/patman/settings.py +++ b/tools/patman/settings.py @@ -23,6 +23,7 @@ _default_settings = { "u-boot": {}, "linux": { "process_tags": "False", + "check_patch_use_tree": "True", }, "gcc": { "process_tags": "False", @@ -71,7 +72,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser): >>> config = _ProjectConfigParser("linux") >>> config.readfp(StringIO(sample_config)) >>> sorted((str(a), str(b)) for (a, b) in config.items("settings")) - [('am_hero', 'True'), ('process_tags', 'False')] + [('am_hero', 'True'), ('check_patch_use_tree', 'True'), ('process_tags', 'False')] # Check to make sure that settings works with unknown project. >>> config = _ProjectConfigParser("unknown") From patchwork Thu Jul 7 15:23:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 1653670 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=O/COUg9T; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lf0dN1hJsz9s0w for ; Fri, 8 Jul 2022 01:27:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0446F84584; Thu, 7 Jul 2022 17:26:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="O/COUg9T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72F878456C; Thu, 7 Jul 2022 17:26:15 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4670B84572 for ; Thu, 7 Jul 2022 17:26:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dianders@chromium.org Received: by mail-pg1-x52d.google.com with SMTP id e132so19133937pgc.5 for ; Thu, 07 Jul 2022 08:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PVWwqKd3FciG4F9Ud4N4sMaoT7DvozXSS0PEqIo2yAY=; b=O/COUg9T5bVq5hDx7ZCKibpt+MlNV4g6zjgrkJpI8XMrKebru1JugpG4v2Yknk8l06 CVH67LP5oFy+sywcA9hWQAXX2WDNf14XhWgKDb3g01fKjHV540zpVv5mteAxm78n1eYw aK1uszJotSuxX4sTAb9TMGafJx43Bv19UqJHU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PVWwqKd3FciG4F9Ud4N4sMaoT7DvozXSS0PEqIo2yAY=; b=xfmYu3DikbvlFpJ2ZdpkmuXbEGBhHey8gBnUXpEuzGzOiLoImhzFQlipY4NCIV1sF5 VIefnPYWja/FtVgO1GpUitvUGqWZtV6I5eh9QFpBMstpVR1qyjl+ZUTkk6+cXlwRI27P H1yJJWxIQuLG6Hv6XhHQAamFFnaS2ToIlV2WRFejmKVBGpqf65RepjGg1SzJZyejFFpM SEyEKqVnS3U74TDZD0mbm6u0drOYmTFmijn6+/XwA1s9fIaJbT/xa1ECkLJ6gO0WG8xy Zm9Gx+Kp4SbicqngBOQ1ukYuaOOYs84Ul+4cfYtTmqd3p/fysCVgW083Hx8QscK0PNbg X/uQ== X-Gm-Message-State: AJIora+/wGb5Av8zsAzzLcWOBytKCg0eqKAAf5kT+WqGKmZ6BIh33kcf 5pANisylmB69CcU2uH3rg4K+/g== X-Google-Smtp-Source: AGRyM1ujuxvjC4qUFt0sDyqby287tjghPZHBTJAnlY1/TsMNXBROF5aE0rAmL7EXTjzxnC6pmEVnmg== X-Received: by 2002:a17:902:db0e:b0:16b:eba9:9364 with SMTP id m14-20020a170902db0e00b0016beba99364mr19219652plx.100.1657207566675; Thu, 07 Jul 2022 08:26:06 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:2c8:c510:a4e9:5da3]) by smtp.gmail.com with ESMTPSA id na7-20020a17090b4c0700b001ecb5a6385bsm17146055pjb.36.2022.07.07.08.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 08:26:06 -0700 (PDT) From: Douglas Anderson To: sjg@chromium.org Cc: amstan@chromium.org, mka@chromium.org, Sean Anderson , briannorris@chromium.org, Douglas Anderson , u-boot@lists.denx.de Subject: [PATCH v3 5/5] patman: Take project defaults into account for --help Date: Thu, 7 Jul 2022 08:23:53 -0700 Message-Id: <20220707082245.v3.5.I79b8a2fc40f11af2ba8108f0f8166c574ae5ab47@changeid> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog In-Reply-To: <20220707152353.1854462-1-dianders@chromium.org> References: <20220707152353.1854462-1-dianders@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean I'd like it so that when you do "patman send --help" and you're using Linux that it show it the proper defaults for Linux. Signed-off-by: Douglas Anderson Tested-by: Brian Norris Reviewed-by: Simon Glass Signed-off-by: Douglas Anderson Tested-by: Brian Norris Reviewed-by: Simon Glass --- (no changes since v2) Changes in v2: - Make comment about parsing three times less nonsensical. tools/patman/main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/patman/main.py b/tools/patman/main.py index 468ebf814fbc..ec70d9fa1439 100755 --- a/tools/patman/main.py +++ b/tools/patman/main.py @@ -107,14 +107,19 @@ status.add_argument('-d', '--dest-branch', type=str, status.add_argument('-f', '--force', action=BooleanOptionalAction, help='Force overwriting an existing branch') -# Parse options twice: first to get the project and second to handle -# defaults properly (which depends on project) -# Use parse_known_args() in case 'cmd' is omitted +# Parse options several times: +# - First to get the project. +# - Second to handle defaults properly (which depends on project). This +# makes help display the right defaults. +# - Finally after we have added an implicit command if necessary. +# +# Use parse_known_args() for the first two in case 'cmd' is omitted +argv = [arg for arg in sys.argv[1:] if arg not in ('-h', '--help')] +args, _ = parser.parse_known_args(argv) argv = sys.argv[1:] -args, rest = parser.parse_known_args(argv) if hasattr(args, 'project'): settings.Setup(gitutil, parser, args.project, '') - args, rest = parser.parse_known_args(argv) +args, rest = parser.parse_known_args(argv) # If we have a command, it is safe to parse all arguments if args.cmd: