From patchwork Thu Mar 31 22:41:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 12797766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D47B0C433F5 for ; Thu, 31 Mar 2022 22:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242404AbiCaWnL (ORCPT ); Thu, 31 Mar 2022 18:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233865AbiCaWnK (ORCPT ); Thu, 31 Mar 2022 18:43:10 -0400 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C9B72156E4 for ; Thu, 31 Mar 2022 15:41:21 -0700 (PDT) Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 7EF58126814; Thu, 31 Mar 2022 18:41:20 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=sasl; bh=KaqhtwE+804U4nWWEtoJm00tG kYheuLEE0KhF35lRkg=; b=ZKeZ9ZirGPT59wCuARsStOgj97HQNKPxlF4VQL5BF jnldlmfuvtRZklWbtY3RCWKZjWqsWGbjWGEjlBzAfRijOuWDuYm5ZOYcYmnGDom9 ANKR4iDoAPqk1EH8zlc7TmHHrxaYT450PUBsyg2AGD7AV8tdhu3jRVdkwX9wfL3u hk= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 72343126813; Thu, 31 Mar 2022 18:41:20 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [35.227.145.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id D5AC5126812; Thu, 31 Mar 2022 18:41:19 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Cc: Glen Choo Subject: [PATCH 1/2] branch: rework comments for future developers Date: Thu, 31 Mar 2022 15:41:17 -0700 Message-Id: <20220331224118.3014407-1-gitster@pobox.com> X-Mailer: git-send-email 2.35.1-917-g7c4048624a In-Reply-To: References: MIME-Version: 1.0 X-Pobox-Relay-ID: AF050F68-B143-11EC-A806-CB998F0A682E-77302942!pb-smtp2.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo For two cases in which we do not explicitly pass --track= option down to the submodule--helper subprocess, we have comments that say "we do not have to pass --track", but in fact we not just do not have to, but it would be incorrect to pass any --track option to the subprocess (instead, the correct behaviour is to let the subprocess figure out what is the appropriate tracking mode to use). Signed-off-by: Glen Choo --- branch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/branch.c b/branch.c index ed6f993aa6..8ee9f43539 100644 --- a/branch.c +++ b/branch.c @@ -549,9 +549,9 @@ static int submodule_create_branch(struct repository *r, strvec_push(&child.args, "--track=inherit"); break; case BRANCH_TRACK_UNSPECIFIED: - /* Default for "git checkout". No need to pass --track. */ + /* Default for "git checkout". Do not pass --track. */ case BRANCH_TRACK_REMOTE: - /* Default for "git branch". No need to pass --track. */ + /* Default for "git branch". Do not pass --track. */ break; } From patchwork Thu Mar 31 22:41:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 12797767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18AA6C433FE for ; Thu, 31 Mar 2022 22:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242614AbiCaWnL (ORCPT ); Thu, 31 Mar 2022 18:43:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239631AbiCaWnK (ORCPT ); Thu, 31 Mar 2022 18:43:10 -0400 Received: from pb-smtp1.pobox.com (pb-smtp1.pobox.com [64.147.108.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 241282156E4 for ; Thu, 31 Mar 2022 15:41:22 -0700 (PDT) Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 067E9115663; Thu, 31 Mar 2022 18:41:22 -0400 (EDT) (envelope-from gitster@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=sasl; bh=LAl4DuaJcsJf fiB0nlCmOZzrqbvjWEGHRf9gOUOnCYg=; b=V5ssBmsWf6KZE0zPy7bMIn1KzCf8 926/Kd0N/MbWBK58Mt5HUpStwQs/ahsglFu4anZKSs+AOTwxZ373v4Ymh37ITnp9 IjggqeNHHqVKYZZvJyP+bwwuIgc5Wf9tSxDESirXpqhQqbJqjCRhW7hswZqyNNcx StkjpXw72cL6g5U= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id E9DDB115662; Thu, 31 Mar 2022 18:41:21 -0400 (EDT) (envelope-from gitster@pobox.com) Received: from pobox.com (unknown [35.227.145.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 59340115660; Thu, 31 Mar 2022 18:41:21 -0400 (EDT) (envelope-from gitster@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Cc: Glen Choo , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFy?= =?utf-8?b?bWFzb24=?= Subject: [PATCH 2/2] branch.c: simplify advice-and-die sequence Date: Thu, 31 Mar 2022 15:41:18 -0700 Message-Id: <20220331224118.3014407-2-gitster@pobox.com> X-Mailer: git-send-email 2.35.1-917-g7c4048624a In-Reply-To: <20220331224118.3014407-1-gitster@pobox.com> References: <20220331224118.3014407-1-gitster@pobox.com> MIME-Version: 1.0 X-Pobox-Relay-ID: AFE85480-B143-11EC-A0BB-5E84C8D8090B-77302942!pb-smtp1.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo In the dwim_branch_start(), when we cannot find an appropriate upstream, we will die with the same message anyway, whether we issue an advice message. Flip the code around a bit and simplify the flow using advise_if_enabled() function. Helped-by: Ævar Arnfjörð Bjarmason Signed-off-by: Glen Choo --- branch.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/branch.c b/branch.c index 8ee9f43539..b673143cbe 100644 --- a/branch.c +++ b/branch.c @@ -383,13 +383,10 @@ static void dwim_branch_start(struct repository *r, const char *start_name, real_ref = NULL; if (get_oid_mb(start_name, &oid)) { if (explicit_tracking) { - if (advice_enabled(ADVICE_SET_UPSTREAM_FAILURE)) { - int code = die_message(_(upstream_missing), - start_name); - advise(_(upstream_advice)); - exit(code); - } - die(_(upstream_missing), start_name); + int code = die_message(_(upstream_missing), start_name); + advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE, + _(upstream_advice)); + exit(code); } die(_("Not a valid object name: '%s'."), start_name); }