From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 7DA751F5AE for ; Fri, 23 Jul 2021 17:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231597AbhGWRDz (ORCPT ); Fri, 23 Jul 2021 13:03:55 -0400 Received: from mail-ej1-f51.google.com ([209.85.218.51]:34486 "EHLO mail-ej1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbhGWRDz (ORCPT ); Fri, 23 Jul 2021 13:03:55 -0400 Received: by mail-ej1-f51.google.com with SMTP id v21so4923885ejg.1 for ; Fri, 23 Jul 2021 10:44:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yjf5fhBMhJIg0F8x3DOOnDUPDIWYF4RivIwucBQZfAI=; b=R+d8+ibJ5wcA+ksC3radsDz9HbZ2BWmJKFEjtIHqFXIK/6LcKHvkE5XmZtlP1yhCwF 24oSjaVieiEfgmutPg7BNyHkc8tu32LgNGIwk1ERex4ERs3Yj2moFEq5LDpJO1+sk6g4 MYj+jKeV1c1uD2P/EJHpj6OcdCbCCcJflQhjczes8S3ly8ZJQ7ZVAElgQTgN+bAPEAqW SBZ232bcTOKCQ9kkeXA8q3bchFb6KB0P4rTlaPmV3R2ETS+7hi+DYhSc8f5QnBtg5R08 8a8M7aUaX+IItMF+jCfJbhm4iXvxEtJRWNvysXpiGKUzaHGg4BKL4BzVP/lgmVjS1McK Dqcg== X-Gm-Message-State: AOAM5315WE0JvxAzR2HdfBoJtD0yOVgl1TDDbXrUYNL3rK4ae+BbpbzX ng+0Fh3VsIyUsx+S4LsS/I5W3MJlTvyzSHUKU5o= X-Google-Smtp-Source: ABdhPJxsqkE9jWOWOC/tJ2Hi/Xh6HcFgqG9qYLwvHReUB1czigHlcMxeOYCN1bAEmyVC4V23Wp7USzyAO3GYq3M2ZgM= X-Received: by 2002:a17:906:4a0a:: with SMTP id w10mr5681697eju.371.1627062266496; Fri, 23 Jul 2021 10:44:26 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Eric Sunshine Date: Fri, 23 Jul 2021 13:44:15 -0400 Message-ID: Subject: Re: [PATCH 1/5] t1092: test merge conflicts outside cone To: Elijah Newren Cc: Derrick Stolee via GitGitGadget , Git Mailing List , Junio C Hamano , Matheus Tavares Bernardino , Derrick Stolee , Derrick Stolee , Derrick Stolee Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, Jul 23, 2021 at 1:34 PM Elijah Newren wrote: > On Wed, Jul 21, 2021 at 2:07 PM Derrick Stolee via GitGitGadget > wrote: > > + for side in left right > > + do > > + git checkout -b merge-$side base && > > + echo $side >>deep/deeper2/a && > > + echo $side >>folder1/a && > > + echo $side >>folder2/a && > > + git add . && > > + git commit -m "$side" || return 1 > > Why is this "|| return 1" here? > > It looks like there are a number of other cases of this in the file > too, which I must have overlooked previously, because I don't > understand any of them. A shell for-loop won't automatically terminate just because some command in its body fails. Instead it will run to completion and return the status of the last command of the last iteration, which may not be the iteration which failed, thus a failure can be hidden. Therefore, we need to proactively stop the loop iteration _and_ ensure that the return status of the loop itself reflects the failure, which we do by `|| return 1`. (If this loop was inside a subshell, we'd use `|| exit 1` instead.)