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

Re: [PATCH v3 2/3] Setup working tree in describe

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 29, 2019, 17:39 UTC
Message-ID
<xmqqr2cv8isf.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190129131151.GB22211@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> On Tue, Jan 29, 2019 at 06:18:58AM +0100, Sebastian Staudt wrote:
>
>> Subject: Re: [PATCH v3 2/3] Setup working tree in describe
>
> We usually write subjects as "area: do some thing" which is a little
> easier when scanning big lists of "git log --oneline".
>
> I think it's key, too, that we only do this for the --dirty case, not
> always. So maybe:
>
>   describe: setup working tree for --dirty
>
> or something?

Thanks as always for being an excellent reviewer who not just reviews but also gives good suggestions.

Show 44 quoted lines
>> This ensures the given working tree is used for --dirty.
>
> There's been a lot of digging and discussion on the list about what
> happens if we don't do this. Could we summarize it here?
>
> Perhaps:
>
>   We don't use NEED_WORK_TREE when running the git-describe builtin,
>   since you should be able to describe a commit even in a bare
>   repository. However, the --dirty flag does need a working tree. Since
>   we don't call setup_work_tree(), it uses whatever directory we happen
>   to be in. That's unlikely to match our index, meaning we'd say "dirty"
>   even when the real working tree is clean.
>
>   We can fix that by calling setup_work_tree() once we know that the
>   user has asked for --dirty.
>
>> The implementation of --broken uses diff-index which calls
>> setup_work_tree() itself.
>
> If I hadn't just read the rest of the thread, I'd probably wonder why we
> are talking about --broken at all. Maybe:
>
>   The --broken option similarly needs a working tree. But because the
>   current implementation calls an external diff-index to do the work,
>   we don't have to bother setting up the working tree in the
>   git-describe process.
>
>> diff --git a/builtin/describe.c b/builtin/describe.c
>> index cc118448ee..b5b7abdc8f 100644
>> --- a/builtin/describe.c
>> +++ b/builtin/describe.c
>> @@ -629,6 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
>>  			struct argv_array args = ARGV_ARRAY_INIT;
>>  			int fd, result;
>>  
>> +			setup_work_tree();
>>  			read_cache();
>>  			refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
>>  				      NULL, NULL, NULL);
>
> The patch itself looks good. :)
>
> -Peff
Previous: Jeff KingNext: Eric Sunshine
Message 4 of 15 in “Add tests for describe with --work-tree”
  1. 1/3 Add tests for describe with --work-treeSebastian Staudt, Jan 29, 2019
  2. 2/3 Setup working tree in describeSebastian Staudt, Jan 29, 2019
  3. Jeff KingJan 29, 2019
  4. Junio C HamanoJan 29, 2019
  5. Eric SunshineJan 29, 2019
  6. Jeff KingJan 29, 2019
  7. Sebastian StaudtJan 30, 2019
  8. Jeff KingJan 30, 2019
  9. 3/3 Add test for describe with a bare repositorySebastian Staudt, Jan 29, 2019
  10. Jeff KingJan 29, 2019
  11. Sebastian StaudtJan 30, 2019
  12. Jeff KingJan 29, 2019
  13. Junio C HamanoJan 29, 2019
  14. Sebastian StaudtJan 30, 2019
  15. Jeff KingJan 30, 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.