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

Re: [PATCH 4/4] t: branch: improve test rollback

From
Jeff King <peff@peff.net>
Date
Sep 8, 2013, 04:56 UTC
Message-ID
<20130908045606.GF14019@sigill.intra.peff.net>
In-Reply-To
<CAMP44s2PFVAKRUkEyN8BAH8C5UUMn21ou9hNkcOXaCsXscywHQ@mail.gmail.com>
On Sat, Sep 07, 2013 at 10:02:59PM -0500, Felipe Contreras wrote:
> 'git checkout -' works perfectly fine, and it's the closest we have to
> my suggested test_checkout() which I think would be ideal, but I'm not
> going to work on.

I do not think it works perfectly fine if the checkout itself fails. For example, after your patch, one of the tests reads:

  test_when_finished "git checkout -" &&
  git checkout HEAD^{} &&
  test_must_fail git branch --set-upstream-to master

The cleanup is undoing what happened on the second line. So if we fail on the third line, it does what we want. If we fail on the second line, then what branch are switching to?

I think you would at least want to reverse the order as:
  git checkout HEAD^{} &&
  test_when_finished "git checkout -" &&
  test_must_fail git branch --set-upstream-to master
so that you know you are actually going to the pre-test state.
-Peff
Previous: Felipe ContrerasNext: Felipe Contreras
Message 13 of 14 in “t: branch: fixes and cleanups”
  1. 0/4 t: branch: fixes and cleanupsFelipe Contreras, Aug 31, 2013
  2. 1/4 t: branch: trivial style fixFelipe Contreras, Aug 31, 2013
  3. Junio C HamanoSep 3, 2013
  4. 2/4 t: branch: fix typoFelipe Contreras, Aug 31, 2013
  5. 3/4 t: branch: fix broken && chainsFelipe Contreras, Aug 31, 2013
  6. 4/4 t: branch: improve test rollbackFelipe Contreras, Aug 31, 2013
  7. Junio C HamanoSep 3, 2013
  8. Felipe ContrerasSep 3, 2013
  9. Junio C HamanoSep 3, 2013
  10. Felipe ContrerasSep 3, 2013
  11. Junio C HamanoSep 4, 2013
  12. Felipe ContrerasSep 8, 2013
  13. Jeff KingSep 8, 2013
  14. Felipe ContrerasSep 8, 2013

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.