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

Re: [PATCH 1/3] name-hash: refactor polymorphic index_name_exists()

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 13, 2013, 21:44 UTC
Message-ID
<CAPig+cS4x1h3v2=0T95+g2_08_7qZj7fUsSiLgDtFyRSbFE0bA@mail.gmail.com>
In-Reply-To
<CAPc5daVtDByrA6yakk_1fq9g5Hv3naNDzEho5G4Ghxc6jzpawg@mail.gmail.com>
On Fri, Sep 13, 2013 at 3:41 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 36 quoted lines
> On Fri, Sep 13, 2013 at 12:29 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Fri, Sep 13, 2013 at 2:40 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Eric Sunshine <sunshine@sunshineco.com> writes:
>>>
>>>> Since these two modes of operations are disjoint and have no code in
>>>> common (one searches index_state.name_hash; the other dir_hash), they
>>>> can be represented more naturally as distinct functions: one to search
>>>> for a file, and one for a directory.
>>>
>>> Good thinking.  Thanks for working on this; I agree with the general
>>> direction this series is going.
>>>
>>> I however wonder if it would be a good idea to rename the other one
>>> to {cache|index}_file_exists(), and even keep the *_name_exists()
>>> variant that switches between the two based on the trailing slash,
>>> to avoid breaking other topics in flight that may have added new
>>> callsites to *_name_exists().  Otherwise the new callsites will feed
>>> a path with a trailing slash to *_name_exists() and get a false
>>> result, no?
>>
>> An assert("no trailing /") was added to index_name_exists() precisely
>> for the purpose of catching cases of code incorrectly calling
>> index_name_exists() to search for a directory. No existing code in
>> 'master' trips the assertion (at least according to the tests),
>> however, the assertion may be annoying for topics in flight which do.
>>
>> Other than plopping these patches atop 'pu' and seeing if anything
>> breaks, what would be the "git way" of detecting in-flight topics
>> which add callers of index_name_exists()? (Excuse my git ignorance.)
>
> I would do a quick
>
> $ git diff master..pu | grep '^+.*_name_exists'
>
> which would be more conservative (it would also show an invocation
> moved from one place to another).

There appear to be no topics in flight which add new index_name_exists() callers (which is not to say that no new callers will be introduced before this topic lands in 'master').

I also plopped the patches atop 'pu' and there are no new tests failures on Linux or Mac OS X, so the series does not seem to break anything in flight. (There are a few test failures on 'pu' on Mac OS X, but they are not related to this series.)

Given the above. How should I proceed? Do you still feel that it is advisable to keep an index_name_exists() around for compatibility reasons in case any new callers are introduced? Regardless of that answer, do you want index_name_exists() renamed to index_file_exists()?

Previous: Eric SunshineNext: Junio C Hamano
Message 7 of 9 in “stop storing trailing slash in dir-hash”
  1. 0/3 stop storing trailing slash in dir-hashEric Sunshine, Sep 13, 2013
  2. 1/3 name-hash: refactor polymorphic index_name_exists()Eric Sunshine, Sep 13, 2013
  3. Junio C HamanoSep 13, 2013
  4. Eric SunshineSep 13, 2013
  5. 2/3 name-hash: stop storing trailing '/' on paths in index_state.dir_hashEric Sunshine, Sep 13, 2013
  6. 3/3 dir: revert work-around for retired dangerous behaviorEric Sunshine, Sep 13, 2013
  7. Eric SunshineSep 13, 2013
  8. Junio C HamanoSep 13, 2013
  9. Eric SunshineSep 13, 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.