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

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

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Sep 3, 2013, 23:03 UTC
Message-ID
<CAMP44s1Q6YjVnVz3OnT=cE+ozUddBxFzM1r_WT5QoR7sP6-9Sg@mail.gmail.com>
In-Reply-To
<xmqqtxi1o6kf.fsf@gitster.dls.corp.google.com>
On Tue, Sep 3, 2013 at 5:59 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 18 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Tue, Sep 3, 2013 at 2:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>>>  test_expect_success 'refuse --edit-description on unborn branch for now' '
>>>> +     test_when_finished "git checkout -" &&
>>>
>>> I am not sure if this is a good change.  Depending on the outcome of
>>> the "git checkout" in the test (it may succeed and set @{-1} to the
>>> branch we were on when we entered the test, or it may fail and leave
>>> @{-1} to the branch before we were on when we entered the test),
>>> this will take us to a different place, no?
>>
>> It is better than leaving Git in an unborn branch.
>
> True, but it falls short of "After every test the environment should
> be as close as to how it was before as possible.", doesn't it?
No it doesn't. Closer is closer.
> I think the fix is just to use the name of a concrete branch,
> instead of "-", which could be far quickly done than making excuses
> like that.

The fix is to write a test_checkout that would save the previous HEAD and restore it after the test, or something similar. But I'm not going to write that, and I bet nobody else is, so unless you want the tests to remain in the crappy state they are, "git checkout -" is the best sensible option.

-- 
Felipe Contreras
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 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.