git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] submodule--helper: set alternateLocation for cloned submodules

From
Jeff King <peff@peff.net>
Date
Dec 8, 2016, 18:53 UTC
Message-ID
<20161208185326.osknwhc654sqaq3t@sigill.intra.peff.net>
In-Reply-To
<d445a6c3-5375-22cf-4f03-1717559f1157@gmail.com>
On Thu, Dec 08, 2016 at 09:04:46PM +0300, vi0oss wrote:
> Why Git test use &&-chains instead of proper "set -e"?

Because "set -e" comes with all kinds of confusing corner cases. Using && chains is annoying, but rarely surprising.

One of my favorite examples is:
  set -e
  (
    false
    echo 1
  ) || {
    echo outcome=$?
    false
  }
  echo 2
which prints both "1" and "2".

Inside the subshell, "set -e" has no effect, and you cannot re-enable it by setting "-e" (it's suppressed entirely because we are on the left-hand side of an || conditional).

So you could write a function like this:
  foo() {
    do_one
    do_two
  }
that relies on catching the failure from do_one. And it works here:
  set -e
  foo
but not here:
  set -e
  if foo then
    do_something
  fi

And there's no way to make it work without adding back in the &&-chaining.

-Peff
Previous: Stefan Beller
Message 7 of 7 in “submodule--helper: set alternateLocation for cloned submodules”
  1. submodule--helper: set alternateLocation for cloned submodulesvi0oss@gmail.com, Dec 8, 2016
  2. Stefan BellerDec 8, 2016
  3. Jeff KingDec 8, 2016
  4. Stefan BellerDec 8, 2016
  5. vi0ossDec 8, 2016
  6. Stefan BellerDec 8, 2016
  7. Jeff KingDec 8, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.