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

Re: [PATCH 1/3] wt-status: implement opportunisitc index update correctly

From
Paul Tan <pyokagan@gmail.com>
Date
Dec 8, 2016, 10:18 UTC
Message-ID
<CACRoPnRpZr=E6SW81Vg-2TiOr=RJo1YouAt5iZoE0CNBx-qesg@mail.gmail.com>
In-Reply-To
<CAGZ79kZHGqU2y19_uKhtVuE6vhspzPNpw-nVDnm8gLQ8u528kQ@mail.gmail.com>
Hi Junio,
On Thu, Dec 8, 2016 at 4:48 AM, Stefan Beller <sbeller@google.com> wrote:
Show 8 quoted lines
> On Wed, Dec 7, 2016 at 11:41 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> The require_clean_work_tree() function calls hold_locked_index()
>> with die_on_error=0 to signal that it is OK if it fails to obtain
>> the lock, but unconditionally calls update_index_if_able(), which
>> will try to write into fd=-1.
>>
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>> ---

Ah, sorry about this. I was indeed misled by the function naming and its comment ("do not complain if we can't"). Should have looked more closely at the other call sites.

> However I think the promise of that function is
> to take care of the fd == -1?

Hmm, to add on, looking at the three other call sites of this function, two of them (builtin/commit.c and builtin/describe.c) basically do:

    if (0 <= fd)
        update_index_if_able(...)

with that 0 <= fd conditional. With this patch it becomes three out of four. Perhaps the repeated use of this conditional is a sign that the 0 <= fd check could be built into update_index_if_able()? I think there is precedent for building in these kind of checks -- rollback_lock_file() also does not fail if the lock file was not successfully opened.

That said, the number of call sites is quite low so it's probably not worth doing this.

Thanks, Paul

Previous: Stefan BellerNext: Junio C Hamano
Message 13 of 19 in “[BUG] Index.lock error message regression in git 2.11.0”
  1. Robbie IannucciDec 3, 2016
  2. Robbie IannucciDec 3, 2016
  3. Junio C HamanoDec 6, 2016
  4. Re* [BUG] Index.lock error message regression in git 2.11.0Junio C Hamano, Dec 6, 2016
  5. Junio C HamanoDec 7, 2016
  6. 0/3 Do not be totally silent upon lock errorJunio C Hamano, Dec 7, 2016
  7. 1/3 wt-status: implement opportunisitc index update correctlyJunio C Hamano, Dec 7, 2016
  8. Stefan BellerDec 7, 2016
  9. Junio C HamanoDec 7, 2016
  10. Stefan BellerDec 7, 2016
  11. Junio C HamanoDec 7, 2016
  12. Stefan BellerDec 7, 2016
  13. Paul TanDec 8, 2016
  14. Junio C HamanoDec 8, 2016
  15. 2/3 hold_locked_index(): align error handling with hold_lockfile_for_update()Junio C Hamano, Dec 7, 2016
  16. 3/3 lockfile: LOCK_REPORT_ON_ERRORJunio C Hamano, Dec 7, 2016
  17. Johannes SchindelinDec 8, 2016
  18. Robbie IannucciDec 8, 2016
  19. Junio C HamanoDec 8, 2016

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.