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

Re: [PATCH] fetch: prefer suffix substitution in compact fetch.output

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 26, 2019, 23:57 UTC
Message-ID
<CACsJy8CzKoq41o09vNsQ=56mAtND_EaHxYN1VgVeLVTo=U2TUA@mail.gmail.com>
In-Reply-To
<xmqqef90fmi6.fsf@gitster-ct.c.googlers.com>
On Sat, Jan 26, 2019 at 4:36 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 29 quoted lines
>
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
> > I have a remote named "jch" and it has a branch with the same name. And
> > fetch.output is set to "compact". Fetching this remote looks like this
> >
> >  From https://github.com/gitster/git
> >   + eb7fd39f6b...835363af2f jch                -> */jch  (forced update)
> >     6f11fd5edb..59b12ae96a  nd/config-move-to  -> jch/*
> >   * [new branch]            nd/diff-parseopt   -> jch/*
> >   * [new branch]            nd/the-index-final -> jch/*
> >
> > Notice that the local side of branch jch starts with "*" instead of
> > ending with it like the rest. It's not exactly wrong. It just looks
> > weird.
> >
> > This patch changes the find-and-replace code a bit to try finding prefix
> > first before falling back to strstr() which finds a substring from left
> > to right. Now we have something less OCD
> >
> >  From https://github.com/gitster/git
> >   + eb7fd39f6b...835363af2f jch                -> jch/*  (forced update)
> >     6f11fd5edb..59b12ae96a  nd/config-move-to  -> jch/*
> >   * [new branch]            nd/diff-parseopt   -> jch/*
> >   * [new branch]            nd/the-index-final -> jch/*
>
> Sounds good.  I do not think strstr() would ever be correct in this
> application in the first place.  In what situation would it produce
> a reasonable result, I wonder?

I think it's useful for github pull requests. The remote side is usually pull/<id>/head but when mapping to a local ref I think we often don't want a ref ending with "head", just pull/<id>. In this case, strstr() can pick the middle part and substitute it with "*".

-- 
Duy
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 3 of 7 in “fetch: prefer suffix substitution in compact fetch.output”
  1. fetch: prefer suffix substitution in compact fetch.outputNguyễn Thái Ngọc Duy, Jan 25, 2019
  2. Junio C HamanoJan 25, 2019
  3. Duy NguyenJan 26, 2019
  4. Ideas for even more compact fetch.output=compact outputÆvar Arnfjörð Bjarmason, Feb 22, 2019
  5. Duy NguyenFeb 22, 2019
  6. Junio C HamanoFeb 22, 2019
  7. Junio C HamanoFeb 22, 2019

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.