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

Re: [PATCH v3 1/2] revision: differentiate if --no-abbrev asked explicitly

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Aug 14, 2020, 00:59 UTC
Message-ID
<20200814005947.GA9518@danh.dev>
In-Reply-To
<xmqq8sei125k.fsf@gitster.c.googlers.com>
On 2020-08-13 17:50:31-0700, Junio C Hamano <gitster@pobox.com> wrote:
Show 30 quoted lines
> Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:
> 
> > When we see --no-abbrev in command's arguments, we reset the 'abbrev'
> > field in diff-options to 0 and this value will be looked at
> > diff_abbrev_oid() to decide not to truncate the object name.
> >
> > In a later change, we want to extend --abbrev support to diff-patch
> > format. When --abbrev supporting diff-patch, we need to differentiate
> > those below scenarios:
> >
> > * None of those options --abbrev, --no-abbrev, and --full-index are
> >   asked. diff-patch should keep old behavior of using DEFAULT_ABBREV
> >   for the index length.
> > * --no-abbrev is asked, diff-patch should treat this option as same as
> >   --full-index and show full object name in index line.
> 
> Sorry, but are you saying that the above two cases cannot be
> differentiated in the current code?
> 
>  * If none of --abbrev, --no-abbrev, --full-index are given, then
>    diff.c::prep_parse_options() will leave options->flags.full_index
>    and options->abbrev untouched.  They are initialized to false and
>    DEFAULT_ABBREV (typically -1 when unconfigured).
> 
>  * If --no-abbrev is given, options->abbrev is set to 0.
>    options->flags.full_index is not touched.
> 
> So you should be able to tell these two apart by only looking at
> options->flags.full_index bit.  Perhaps, even though you said "we
> need to differentiate", you meant something else?

Oops, I shouldn't say anything about --full-index in the second point to reduce confusion.

Let me list some combination here:
* none of --abbrev --no-abbrev --full-index -> default short index
* --abbrev --full-index                     -> full-index
* --full-index --abbrev                     -> full-index
* --abbrev --no-abbrev                      -> full-index
* --no-abbrev --abbrev=[n]                  -> shortened index to n char

So, we can't use full_index bit, because --no-abbrev can be defeated by --abbrev, but --full-index will always win --abbrev.

Show 8 quoted lines
> 
> > While not doing anything is very effective way to show full object id,
> > we couldn't differentiate if --no-abbrev or not.
> 
> Hmph.  --no-abbrev without --full-index would not set
> flags.full_index bit; using --full-index would set the bit.  Are you
> planning to do something special when BOTH --no-abbrev and --full-index
> is given?  I am confused X-<.

I'm not planning for anything special when both --no-abbrev and --full-index is given.

I'm planning for:
* BOTH --abbrev and --no-abbrev but NOT --full-index;
* BOTH --abbrev AND --full-index

Sorry for the confusion, I hope it's clear now, and you could help me rephase a bit to reduce confusion.

-- 
Danh
Previous: Junio C HamanoNext: Junio C Hamano
Message 20 of 41 in “extend --abbrev support to diff-patch format”
  1. 0/2 extend --abbrev support to diff-patch formatĐoàn Trần Công Danh, Aug 9, 2020
  2. 1/2 revision: differentiate if --no-abbrev asked explicitlyĐoàn Trần Công Danh, Aug 9, 2020
  3. 2/2 diff: extend --abbrev support to diff-patch formatĐoàn Trần Công Danh, Aug 9, 2020
  4. Junio C HamanoAug 9, 2020
  5. Jeff KingAug 10, 2020
  6. Đoàn Trần Công DanhAug 10, 2020
  7. Junio C HamanoAug 10, 2020
  8. Jeff KingAug 10, 2020
  9. Đoàn Trần Công DanhAug 11, 2020
  10. Jeff KingAug 11, 2020
  11. Đoàn Trần Công DanhAug 11, 2020
  12. Junio C HamanoAug 10, 2020
  13. 0/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 11, 2020
  14. 1/2 revision: differentiate if --no-abbrev asked explicitlyĐoàn Trần Công Danh, Aug 11, 2020
  15. Junio C HamanoAug 11, 2020
  16. 2/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 11, 2020
  17. 0/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 14, 2020
  18. 1/2 revision: differentiate if --no-abbrev asked explicitlyĐoàn Trần Công Danh, Aug 14, 2020
  19. Junio C HamanoAug 14, 2020
  20. Đoàn Trần Công DanhAug 14, 2020
  21. Junio C HamanoAug 14, 2020
  22. Đoàn Trần Công DanhAug 14, 2020
  23. Junio C HamanoAug 19, 2020
  24. 2/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 14, 2020
  25. SZEDER GáborAug 14, 2020
  26. Junio C HamanoAug 14, 2020
  27. Junio C HamanoAug 14, 2020
  28. brian m. carlsonAug 15, 2020
  29. Đoàn Trần Công DanhAug 15, 2020
  30. Junio C HamanoAug 17, 2020
  31. Junio C HamanoAug 20, 2020
  32. 0/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 20, 2020
  33. 2/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 20, 2020
  34. Junio C HamanoAug 20, 2020
  35. 1/2 t4013: improve diff-post-processor logicĐoàn Trần Công Danh, Aug 20, 2020
  36. Junio C HamanoAug 20, 2020
  37. Đoàn Trần Công DanhAug 21, 2020
  38. Junio C HamanoAug 21, 2020
  39. 0/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 21, 2020
  40. 2/2 diff: index-line: respect --abbrev in object's nameĐoàn Trần Công Danh, Aug 21, 2020
  41. 1/2 t4013: improve diff-post-processor logicĐoàn Trần Công Danh, Aug 21, 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.