From patchwork Thu Mar 31 18:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12797592 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 CCEC7C433F5 for ; Thu, 31 Mar 2022 18:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237160AbiCaSv4 (ORCPT ); Thu, 31 Mar 2022 14:51:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237019AbiCaSvx (ORCPT ); Thu, 31 Mar 2022 14:51:53 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65AE216E7CD for ; Thu, 31 Mar 2022 11:50:05 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id h4so972732wrc.13 for ; Thu, 31 Mar 2022 11:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=QhIZ6ViwWoJZrXihwgpbUJCt7CyAtmgWKKrcYxuljSY=; b=lYPFDyTEoKuc3WtAhjCfWp4AH8xgoe9VQ0yh9169JMMAbOMlbP/3KlP+9X1Fjn6xgS OXGffMhzBQxzdGeGHQMe+csusYdNewb7m6lEcOCid8xTAaWSSJ/M9evWpL4QQb3O4+PY vvPkRnVTzqrRICmjEWwyov2P+s5TeIgGjq5EjpcDrChRJCFBGhTToRkIDvwPVGlTc56n spavW4EFY9YaLUcJbi4be6rOnpu/52PYd9shmidPA7qbmMl4k/mfmZ2XvJr1/tuDJ9rZ U07JAtIEK8vqgZdqPXEbnNx3uNzP+d+Du5B3pGHnmJ3RZ3bG6nVm0WGOUnhJkPfSYlrs RcLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=QhIZ6ViwWoJZrXihwgpbUJCt7CyAtmgWKKrcYxuljSY=; b=UbkKyR9xVb3biwBMaqyRpMRkOlexinyPETZmLd42mVIdGIq7jGUM9q5/EPfgOBiKM9 YEASPhEc+dJ7cYgqxTfavNTccHZObGMGYrhQKsErz+Kl+C21BlXGbG2CaBgYL2Bmz1Mz 0JmDNHHJituTRBugcDEBdrCShZxfiAX5hSAzFqyJaWBuGU1SYTerzA4Qf5zZNys4J+y3 cIsVRlWis0nZMo//NHM7D9JZfH2qrGbYs6LH8pNtp2IcjUdZIxn0sOcbeReDj0EAVhcz TqrYfMEhcxIVVX84rszzf6YNm/DfFqd8noxc1UMR+BhG8wMU4Kw51zLznNMiScM7rZzz xOTA== X-Gm-Message-State: AOAM532+WUb+cu/xlmJYprgWMMYkrwA672WEQADXxbAmzah0LwX7lNvL 0TDCxNwR0r/ZGWYOvu1J/JV03xXREvg= X-Google-Smtp-Source: ABdhPJzEzulQsjBfTxqWMvacEZIx8rrpK/kCKYmWT8Xh/PKx3+yw8QaGTH0RoWWMy2aNUKsR/asXNQ== X-Received: by 2002:a05:6000:178a:b0:205:c5e1:df07 with SMTP id e10-20020a056000178a00b00205c5e1df07mr5061464wrg.703.1648752603624; Thu, 31 Mar 2022 11:50:03 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k5-20020a5d66c5000000b00203fd25f4ecsm184026wrw.16.2022.03.31.11.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 11:50:03 -0700 (PDT) Message-Id: <5e96a09199fab0be35d26eab8e73d7cd803032c8.1648752601.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 31 Mar 2022 18:49:58 +0000 Subject: [PATCH v2 1/4] branch: support more tracking modes when recursing Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jonathan Tan , Junio C Hamano , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo "git branch --recurse-submodules" does not propagate "--track=inherit" or "--no-track" to submodules, which causes submodule branches to use the wrong tracking mode [1]. To fix this, pass the correct options to the "submodule--helper create-branch" child process and test for it. While we are refactoring the same code, replace "--track" with the synonymous, but more consistent-looking "--track=direct" option (introduced at the same time as "--track=inherit", d3115660b4 (branch: add flags and config to inherit tracking, 2021-12-20)). [1] This bug is partially a timing issue: "branch --recurse-submodules" was introduced around the same time as "--track=inherit", and even though I rebased "branch --recurse-submodules" on top of that, I had neglected to support the new tracking mode. Omitting "--no-track" was just a plain old mistake, though. Signed-off-by: Glen Choo --- branch.c | 29 +++++++++++++++++++++++++--- builtin/submodule--helper.c | 7 ++++--- t/t3207-branch-submodule.sh | 38 ++++++++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/branch.c b/branch.c index 6b31df539a5..aac24591d22 100644 --- a/branch.c +++ b/branch.c @@ -233,6 +233,9 @@ static void setup_tracking(const char *new_ref, const char *orig_ref, struct string_list tracking_srcs = STRING_LIST_INIT_DUP; int config_flags = quiet ? 0 : BRANCH_CONFIG_VERBOSE; + if (!track) + BUG("asked to set up tracking, but tracking is disallowed"); + memset(&tracking, 0, sizeof(tracking)); tracking.spec.dst = (char *)orig_ref; tracking.srcs = &tracking_srcs; @@ -534,8 +537,27 @@ static int submodule_create_branch(struct repository *r, strvec_push(&child.args, "--quiet"); if (reflog) strvec_push(&child.args, "--create-reflog"); - if (track == BRANCH_TRACK_ALWAYS || track == BRANCH_TRACK_EXPLICIT) - strvec_push(&child.args, "--track"); + + switch (track) { + case BRANCH_TRACK_NEVER: + strvec_push(&child.args, "--no-track"); + break; + case BRANCH_TRACK_ALWAYS: + case BRANCH_TRACK_EXPLICIT: + strvec_push(&child.args, "--track=direct"); + break; + case BRANCH_TRACK_OVERRIDE: + BUG("BRANCH_TRACK_OVERRIDE cannot be used when creating a branch."); + break; + case BRANCH_TRACK_INHERIT: + strvec_push(&child.args, "--track=inherit"); + break; + case BRANCH_TRACK_UNSPECIFIED: + /* Default for "git checkout". Do not pass --track. */ + case BRANCH_TRACK_REMOTE: + /* Default for "git branch". Do not pass --track. */ + break; + } strvec_pushl(&child.args, name, start_oid, tracking_name, NULL); @@ -614,7 +636,8 @@ void create_branches_recursively(struct repository *r, const char *name, * tedious to determine whether or not tracking was set up in the * superproject. */ - setup_tracking(name, tracking_name, track, quiet); + if (track) + setup_tracking(name, tracking_name, track, quiet); for (i = 0; i < submodule_entry_list.entry_nr; i++) { if (submodule_create_branch( diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 5301612d24b..081c8267c33 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -3021,9 +3021,10 @@ static int module_create_branch(int argc, const char **argv, const char *prefix) OPT__FORCE(&force, N_("force creation"), 0), OPT_BOOL(0, "create-reflog", &reflog, N_("create the branch's reflog")), - OPT_SET_INT('t', "track", &track, - N_("set up tracking mode (see git-pull(1))"), - BRANCH_TRACK_EXPLICIT), + OPT_CALLBACK_F('t', "track", &track, "(direct|inherit)", + N_("set branch tracking configuration"), + PARSE_OPT_OPTARG, + parse_opt_tracking_mode), OPT__DRY_RUN(&dry_run, N_("show whether the branch would be created")), OPT_END() diff --git a/t/t3207-branch-submodule.sh b/t/t3207-branch-submodule.sh index 0d93f7516c9..cfde6b237f5 100755 --- a/t/t3207-branch-submodule.sh +++ b/t/t3207-branch-submodule.sh @@ -260,7 +260,7 @@ test_expect_success 'should get fatal error upon branch creation when submodule ) ' -test_expect_success 'should set up tracking of remote-tracking branches' ' +test_expect_success 'should set up tracking of remote-tracking branches by default' ' test_when_finished "reset_remote_test" && ( cd super-clone && @@ -289,4 +289,40 @@ test_expect_success 'should not fail when unable to set up tracking in submodule ) ' +test_expect_success '--track=inherit should set up tracking correctly' ' + test_when_finished "reset_remote_test" && + ( + cd super-clone && + git branch --recurse-submodules branch-a origin/branch-a && + # Set this manually instead of using branch --set-upstream-to + # to circumvent the "nonexistent upstream" check. + git -C sub config branch.branch-a.remote origin && + git -C sub config branch.branch-a.merge refs/heads/sub-branch-a && + git -C sub/sub-sub config branch.branch-a.remote other && + git -C sub/sub-sub config branch.branch-a.merge refs/heads/sub-sub-branch-a && + + git branch --recurse-submodules --track=inherit branch-b branch-a && + test_cmp_config origin branch.branch-b.remote && + test_cmp_config refs/heads/branch-a branch.branch-b.merge && + test_cmp_config -C sub origin branch.branch-b.remote && + test_cmp_config -C sub refs/heads/sub-branch-a branch.branch-b.merge && + test_cmp_config -C sub/sub-sub other branch.branch-b.remote && + test_cmp_config -C sub/sub-sub refs/heads/sub-sub-branch-a branch.branch-b.merge + ) +' + +test_expect_success '--no-track should not set up tracking' ' + test_when_finished "reset_remote_test" && + ( + cd super-clone && + git branch --recurse-submodules --no-track branch-a origin/branch-a && + test_cmp_config "" --default "" branch.branch-a.remote && + test_cmp_config "" --default "" branch.branch-a.merge && + test_cmp_config -C sub "" --default "" branch.branch-a.remote && + test_cmp_config -C sub "" --default "" branch.branch-a.merge && + test_cmp_config -C sub/sub-sub "" --default "" branch.branch-a.remote && + test_cmp_config -C sub/sub-sub "" --default "" branch.branch-a.merge + ) +' + test_done From patchwork Thu Mar 31 18:49:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12797593 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 657D7C433EF for ; Thu, 31 Mar 2022 18:50:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237236AbiCaSwC (ORCPT ); Thu, 31 Mar 2022 14:52:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237067AbiCaSvy (ORCPT ); Thu, 31 Mar 2022 14:51:54 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 540D616F6FB for ; Thu, 31 Mar 2022 11:50:06 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id j18so1036330wrd.6 for ; Thu, 31 Mar 2022 11:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=WPpANUWFRgXIb3oDOZk37EOayhXJtam8+1zzZzqOzRY=; b=ZPrHilYACx8BGgJTrDyAB3xkfNh1rkrT123o73bhJx9fAFYPNUx/NxBM6ynNKmxYFL IXv5RW/Ixgz7zh06Z7rM6mZZR4Z/p5bciGP5jxh5JJAMI1mfHIRdymPAFZ9koFzY35ov 4s7vYYA3XJrMBwzgIMiSJCm2UojhJdR+uUdR559raR70hDtkcwpQ5eex5NO2jJjp5Joo lykArJwqfD+8zBXEsxe52AFBSYA8YkYJikKWZQTDKbhkAnDYSPRgD5nlL4T3BZ+k49wg vkgTkylObnSQDzCTY8sWvIgjRMyFLRgDNiIYLIJIqmSHHJ+ulNNdw1NZ4HNfG+6rbV6N FPLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=WPpANUWFRgXIb3oDOZk37EOayhXJtam8+1zzZzqOzRY=; b=FMkpwjIcNbLcBl71wq4vImdciCeW8NDjUpgw8RA/4dH4Xjomk5wudWz0Vhy/bRNYMg XvBodedlK53QNY+d0TVd7Kjy3JWG3E1oZDDyfdXx+bE7BTYK/bDqTmNBLj0cn2v6UiRd E/zRzFcpZjMb5cQmyL6C2N+4g+iDiBFqeu+JWPazxglzYHlYLrbY8iSvdS1cpZO2nO7I pt3NMBzCRgbj68iGypz27K1dK0XcgsTmp2lD54LAW1c343KD+qG11b8X41Rr1LP3VVCo 8vXTJjDHRU32shtP2YNjNc0ui3haut/BOEuFOYDERtq/IKkywWVtqlB3xbuhYW0wex6g sxVw== X-Gm-Message-State: AOAM532XDIDNvm5NrXBpsCGceXcZT2gv3gJdxt84S5evCN15xAtLVhuS Ma1fxGHhXYgw7Otn7p5ctEJE09FVvcA= X-Google-Smtp-Source: ABdhPJyMC5zNTzLWjer+S+0MNnf+opkpGaH6qCPUV+vGufCUKwJLW2JKIF09pPiwNoRI+yu0XtepNA== X-Received: by 2002:a5d:6d8a:0:b0:204:8aa:309f with SMTP id l10-20020a5d6d8a000000b0020408aa309fmr5041255wrs.38.1648752604692; Thu, 31 Mar 2022 11:50:04 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c511300b0038d0d8f67e5sm8157992wms.16.2022.03.31.11.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 11:50:04 -0700 (PDT) Message-Id: <74b839bfc4e9503f8b2c62aeab44ba5c07f09f0c.1648752601.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 31 Mar 2022 18:49:59 +0000 Subject: [PATCH v2 2/4] branch: give submodule updating advice before exit Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jonathan Tan , Junio C Hamano , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo Fix a bug where "hint:" was printed _before_ "fatal:" (instead of the other way around). Signed-off-by: Glen Choo --- branch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/branch.c b/branch.c index aac24591d22..1252b17b980 100644 --- a/branch.c +++ b/branch.c @@ -607,11 +607,13 @@ void create_branches_recursively(struct repository *r, const char *name, */ for (i = 0; i < submodule_entry_list.entry_nr; i++) { if (submodule_entry_list.entries[i].repo == NULL) { + int code = die_message( + _("submodule '%s': unable to find submodule"), + submodule_entry_list.entries[i].submodule->name); if (advice_enabled(ADVICE_SUBMODULES_NOT_UPDATED)) advise(_("You may try updating the submodules using 'git checkout %s && git submodule update --init'"), start_commitish); - die(_("submodule '%s': unable to find submodule"), - submodule_entry_list.entries[i].submodule->name); + exit(code); } if (submodule_create_branch( From patchwork Thu Mar 31 18:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12797594 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 17F0EC433F5 for ; Thu, 31 Mar 2022 18:50:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237248AbiCaSwD (ORCPT ); Thu, 31 Mar 2022 14:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237130AbiCaSvy (ORCPT ); Thu, 31 Mar 2022 14:51:54 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4582C16E7CD for ; Thu, 31 Mar 2022 11:50:07 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id i4so1041599wrb.5 for ; Thu, 31 Mar 2022 11:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:mime-version :content-transfer-encoding:fcc:to:cc; bh=s/5sKTsNwfsMmBsHaFDfuEBmde29MN+fEcM7qT9Uqp4=; b=SP4Q8cm7Z02JeBRWT6rfbGILbELEu2OcIKZUPh8af06y1LCk/0piPLc01v4bHLjRH6 e0qwoiyss13KA56583W9A+7ji5lhDOJbySThAHRQ7PylZK3IAMRca0tQckOW7re8ykOx 7RiDGZ9E32xz4aFZfhX8MgTi8a4LoIEDumKZGDhSH0iq5rD7O4LddJmWaJmp9SeX92lJ SYrTeU71kRzaoB1uCKHSsDAM7Ed6wviYPzeJdaZb0wcKJNHRN83QD7NEPROk0Qph4mh3 LjQi/TLCRMYnuLULz9z2gBtDeX5wwtBMAV/E/KSa/+BqQtN8rzqTfJdtG6SGiw10/fHP vEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:mime-version:content-transfer-encoding:fcc:to:cc; bh=s/5sKTsNwfsMmBsHaFDfuEBmde29MN+fEcM7qT9Uqp4=; b=vqundBJpPnqbJDs+FO/ZweDQrfeOXfbGwIM5CgBDD4mb3qtSgUYI1oa3zHS3/VIME+ ZSmO3O6LL/Mrjjl9v3pL9E+mgg7iFr77evJNc+dLiQWnt9H/PCH+lfR8EC3m8L7elIjk y9QZHjYLbWbgIotI73La+aA4HLtkrXcpbbbUKcORjJ0nO0PhVVRlfud2xz4kb5YHycvg iPAhONPxgaWYl/P6AnA0m1EwJImTbWFR9a1X1deZIyuTmJ1SkPxVrFXK/WQ+8dOFq6qb fub9lUbk8wLUupBzlfLV1filBkt4Hjbn2WbKJzRL+QJ4hcI4GcRzrQMJxtfuppRm84eT AJfg== X-Gm-Message-State: AOAM530Yp5p++1JrV7qFyk3APKbNFs1CHoSpoAxdz7CxLroNVbgANUIC +Mt9MLGAfbhpwXfqgss1qFDq4qfNFUI= X-Google-Smtp-Source: ABdhPJyk7Ag4PknY4TG1tYCxAZgscaPE0swWGJquGAgTXGL/mGuiqCmQMYtN2IOy03LmDLtKRuZmOQ== X-Received: by 2002:a5d:66ca:0:b0:203:fb72:a223 with SMTP id k10-20020a5d66ca000000b00203fb72a223mr4982587wrw.12.1648752605606; Thu, 31 Mar 2022 11:50:05 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d5-20020adfef85000000b00205b3945fdasm172279wro.92.2022.03.31.11.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 11:50:05 -0700 (PDT) Message-Id: <64d9b8e0f444a7191c83a69b943c95631270ff5b.1648752601.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 31 Mar 2022 18:50:00 +0000 Subject: [PATCH v2 3/4] branch --set-upstream-to: be consistent when advising MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jonathan Tan , Junio C Hamano , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo "git branch --set-upstream-to" behaves differently when advice is enabled/disabled: | | error prefix | exit code | |-----------------+--------------+-----------| | advice enabled | error: | 1 | | advice disabled | fatal: | 128 | Make both cases consistent by using die_message() when advice is enabled (this was first proposed in [1]). [1] https://lore.kernel.org/git/211210.86ee6ldwlc.gmgdl@evledraar.gmail.com Helped-by: Ævar Arnfjörð Bjarmason Signed-off-by: Glen Choo --- branch.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/branch.c b/branch.c index 1252b17b980..ca7f0c3adf8 100644 --- a/branch.c +++ b/branch.c @@ -388,12 +388,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)) { - error(_(upstream_missing), start_name); - advise(_(upstream_advice)); - exit(1); - } - 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); } From patchwork Thu Mar 31 18:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glen Choo X-Patchwork-Id: 12797595 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 C81F7C433F5 for ; Thu, 31 Mar 2022 18:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237421AbiCaSwO (ORCPT ); Thu, 31 Mar 2022 14:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237113AbiCaSv5 (ORCPT ); Thu, 31 Mar 2022 14:51:57 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE0A1704F2 for ; Thu, 31 Mar 2022 11:50:08 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id h23so1024136wrb.8 for ; Thu, 31 Mar 2022 11:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=fLlo4FesdHm9Z5Pf68tm3qfzTDs/F5UeG8LpLQb4aFA=; b=lXpNeBSX1DfflyLctf5ASbQAiuXcAMCZ5HpCO1oVVaNQ0k9dMN+kJPMTVz9NEK333y 52XvmkQCElwPqN7FvO7C3zuhN1vlWcQXCNVDcdROMyVrG9QsHikrBJoRowtud4zvPtxl OKPzIuBSTBOG1aHMsIxznnjlP9fAfldMGNHiFKOP+GjPpk7DAxGb/SMrao969miMjFcA q8yhFjONs/txIur13kQpXgBPso27NzFlLlQXviIdsdgx09kb7r512WcYzbGxA2sgFuMj 3lPdOQ3rUepNu7jmjAE4OtNAJJp/TuX26l1uDvwihujGZw7dC9vsoibRy2Gx0dNOTXkb hb3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=fLlo4FesdHm9Z5Pf68tm3qfzTDs/F5UeG8LpLQb4aFA=; b=4Kc3XSogzZ0iEAh9vK7K4FP+JVP4q9W66SkNEz9rJ/sM47Y2BhChThSyzkiemsj1Pq sBjzRctnpf9env3iDJYjJC5Iu2S3fYZvaOhfPolzYMFSKkS4DPUOLHm3j36Fx+Zxc38T JoL5JLNsHxaHEhrMbvBc9XZU8sIwnPl79bbrGdscAoVAfiyqhoVM7bPDO4qmzQaSkWkm Irs/UihgsvjBos/1A31w7MoShKelLB2oi+RDt30ImX8d6l21slBOoIJqUSwemozQoVI8 iB28rexObP0EMKTArSm3UccU7ogeqcxtzbsbGS/4U8tERVlEhuAT4TeMqNv8cOJ1K0Qn 09Bg== X-Gm-Message-State: AOAM533X/YfF0z1Rpi+MenQjXWikUELp8RLsvYKnVwGcpIHXgd65Yr4k gmHmNBGFMvqLChXHxBIz9Q6pjV/1KNk= X-Google-Smtp-Source: ABdhPJwJxCBhAf+gIxXcpsZ9IeiRyDzztt9svfaiztVPLLfjjt6Hv37I77srS9q+uYQNClhTWCfY1g== X-Received: by 2002:a5d:6441:0:b0:205:e06b:f7c5 with SMTP id d1-20020a5d6441000000b00205e06bf7c5mr4981646wrw.174.1648752606620; Thu, 31 Mar 2022 11:50:06 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n20-20020a05600c4f9400b0038cbd13e06esm8391392wmq.2.2022.03.31.11.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 11:50:06 -0700 (PDT) Message-Id: <306858373ccda2da80fe13fe3113ed793db56e91.1648752601.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 31 Mar 2022 18:50:01 +0000 Subject: [PATCH v2 4/4] branch: remove negative exit code Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Jonathan Tan , Junio C Hamano , Glen Choo , Glen Choo Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Glen Choo From: Glen Choo Replace an instance of "exit(-1)" with "exit(1)". We don't use negative exit codes - they are misleading because Unix machines will coerce them to 8-bit unsigned values, losing the sign. Signed-off-by: Glen Choo --- branch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/branch.c b/branch.c index ca7f0c3adf8..581afd634da 100644 --- a/branch.c +++ b/branch.c @@ -263,7 +263,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref, string_list_append(tracking.srcs, orig_ref); if (install_branch_config_multiple_remotes(config_flags, new_ref, tracking.remote, tracking.srcs) < 0) - exit(-1); + exit(1); cleanup: string_list_clear(&tracking_srcs, 0);