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

Re: [PATCH v2] refspec: make @ a synonym of HEAD

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Nov 25, 2020, 23:48 UTC
Message-ID
<CAMP44s2cpPgg55XHTr=cRqRcrMOkU=qcrM=RpWYwVJJdd9V4JA@mail.gmail.com>
In-Reply-To
<xmqq360ygq2g.fsf@gitster.c.googlers.com>
On Tue, Nov 24, 2020 at 7:53 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 27 quoted lines
>
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
> > On Tue, Nov 24, 2020 at 6:37 PM Junio C Hamano <gitster@pobox.com> wrote:
> >> Felipe Contreras <felipe.contreras@gmail.com> writes:
> >
> >> > +test_expect_success 'push with @' '
> >> > +
> >> > +     mk_test testrepo heads/master &&
> >> > +     git checkout master &&
> >> > +     git push testrepo @ &&
> >> > +     check_push_result testrepo $the_commit heads/master
> >> > +
> >> > +'
> >>
> >> This is OK, but shouldn't this be placed before the tests with
> >> various configuration?  Something along the lines of the attached,
> >> but with the body of the loop properly reindented, would also give
> >> us a better test coverage at the same time.
> >
> > I don't see much value in those tests, since I don't see how if one
> > passes another one would fail. But I guess it cannot hurt.
>
> That can only be said based on the knowledge of the implementation
> detail of the code immediately after this patch gets applied.  Any
> future change to the code for whatever reason (e.g. refactoring) can
> make the current assumption invalid.

It's not just the current implementation of the code; it's any implementation of the code (in my opinion).

Show 15 quoted lines
> As the proposed log message says,
>
>     Since commit 9ba89f484e git learned how to push to a remote branch using
>     the source @, for example:
>
>       git push origin @:$dst
>
>     However, if the right-hand side is missing, the push fails:
>
>       git push origin @
>
> we care about both of these forms working, not just the singleton
> form, so it is not just "not hurt", but is actively a good thing, to
> protect both forms from future breakage.  After all, that is why we
> have tests.
Both forms were already tested.

What you suggested adds three more tests: 3. +@ form, 4. @ not present on the remote, 5. @ in remote.*.push. If the first two pass, I cannot see any implementation that would fail the other three (okay, maybe the +@ one).

Anyway, I had to improve the current tests to make your suggestion work, and what once was a single simple patch now became a series that is mostly shuffling around test code. At some point the aphorism "don't let the perfect be the enemy of the good" has to apply though.

Cheers.
-- 
Felipe Contreras
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 6 in “refspec: make @ a synonym of HEAD”
  1. refspec: make @ a synonym of HEADFelipe Contreras, Nov 25, 2020
  2. Junio C HamanoNov 25, 2020
  3. Felipe ContrerasNov 25, 2020
  4. Junio C HamanoNov 25, 2020
  5. Felipe ContrerasNov 25, 2020
  6. Junio C HamanoNov 26, 2020

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.