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

Re: [PATCH v3 7/9] pretty: refactor `format_sanitized_subject()`

From
Hariom verma <hariom18599@gmail.com>
Date
Aug 20, 2020, 17:33 UTC
Message-ID
<CA+CkUQ8tkKM6SKrpJJ9-+9Nj+4Ly3FWHKUp1BQgJEG0-XyWENw@mail.gmail.com>
In-Reply-To
<xmqqeeo2vcsl.fsf@gitster.c.googlers.com>
Hi,
On Wed, Aug 19, 2020 at 9:38 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 36 quoted lines
>
> Junio C Hamano <gitster@pobox.com> writes:
>
> > Hariom verma <hariom18599@gmail.com> writes:
> >
> >>> Also, because neither LF or SP is a titlechar(), wouldn't the "if
> >>> r[i] is LF, replace it with SP" a no-op wrt what will be in sb at
> >>> the end?
> >>
> >> Maybe its better to directly replace LF with hyphen? [Instead of first
> >> replacing LF with SP and then replacing SP with '-'.]
> >
> > Why do you think LF is so special?
> >
> > Everything other than titlechar() including HT, '#', '*', SP is
> > treated in the same way as the body of that loop.  It does not
> > directly contribute to the final contents of sb, but just leaves
> > the marker in the variable "space" the fact that when adding the
> > next titlechar() to the resulting sb, we need a SP to wordbreak.
>
> I was undecided between mentioning and not mentioning the variable
> name "space" here.  On one hand, one _could_ argue that "space" is
> used to remember we saw "space and the like" and if it were named
> "seen_non_title_char", then such a confusion to treat LF so
> specially might not have occurred.  But on the other hand, "space"
> is what the variable exactly keeps track of; it is just the need for
> space on the output side, i.e. we remember that "space needed before
> the next output" with that variable.
>
> I am inclined not to suggest renaming "space" at all, but it won't
> be the end of the world if it were renamed to "need_space" (before
> the next output), or "seen_nontitle".  If we were to actually
> rename, I have moderately strong preference to the "need_space" over
> "seen_nontitle", as it won't have to be renamed again when the logic
> to require a space before the next output has to be updated to
> include cases other than just "we saw a nontitle character".

Yeah, if it was named "seen_non_title_char", I might not get confused. But now as you have already explained its working pretty well, "space" makes more sense to me. Well, I'm okay with both "space" and "need_space".

I wonder what others have to say on this? "space" or "need_space"?

Thanks, Hariom

Previous: Junio C HamanoNext: Hariom verma
Message 35 of 51 in “[GSoC] Improvements to ref-filter”
  1. 0/5 [GSoC] Improvements to ref-filterHariom Verma via GitGitGadget, Jul 27, 2020
  2. 1/5 ref-filter: support different email formatsHariom Verma via GitGitGadget, Jul 27, 2020
  3. Junio C HamanoJul 27, 2020
  4. Hariom vermaJul 28, 2020
  5. Junio C HamanoJul 28, 2020
  6. Đoàn Trần Công DanhJul 28, 2020
  7. Junio C HamanoJul 28, 2020
  8. 2/5 ref-filter: add `short` option for 'tree' and 'parent'Hariom Verma via GitGitGadget, Jul 27, 2020
  9. Junio C HamanoJul 27, 2020
  10. 3/5 pretty: refactor `format_sanitized_subject()`Hariom Verma via GitGitGadget, Jul 27, 2020
  11. 4/5 format-support: move `format_sanitized_subject()` from prettyHariom Verma via GitGitGadget, Jul 27, 2020
  12. 5/5 ref-filter: add `sanitize` option for 'subject' atomHariom Verma via GitGitGadget, Jul 27, 2020
  13. 0/9 [GSoC] Improvements to ref-filterHariom Verma via GitGitGadget, Aug 5, 2020
  14. 1/9 ref-filter: support different email formatsHariom Verma via GitGitGadget, Aug 5, 2020
  15. 2/9 ref-filter: refactor `grab_objectname()`Hariom Verma via GitGitGadget, Aug 5, 2020
  16. 3/9 ref-filter: modify error messages in `grab_objectname()`Hariom Verma via GitGitGadget, Aug 5, 2020
  17. 4/9 ref-filter: rename `objectname` related functions and fieldsHariom Verma via GitGitGadget, Aug 5, 2020
  18. 5/9 ref-filter: add `short` modifier to 'tree' atomHariom Verma via GitGitGadget, Aug 5, 2020
  19. 6/9 ref-filter: add `short` modifier to 'parent' atomHariom Verma via GitGitGadget, Aug 5, 2020
  20. 8/9 format-support: move `format_sanitized_subject()` from prettyHariom Verma via GitGitGadget, Aug 5, 2020
  21. 9/9 ref-filter: add `sanitize` option for 'subject' atomHariom Verma via GitGitGadget, Aug 5, 2020
  22. 7/9 pretty: refactor `format_sanitized_subject()`Hariom Verma via GitGitGadget, Aug 5, 2020
  23. Junio C HamanoAug 5, 2020
  24. Hariom vermaAug 6, 2020
  25. 0/9 [Resend][GSoC] Improvements to ref-filterHariom Verma via GitGitGadget, Aug 17, 2020
  26. 2/9 ref-filter: refactor `grab_objectname()`Hariom Verma via GitGitGadget, Aug 17, 2020
  27. 3/9 ref-filter: modify error messages in `grab_objectname()`Hariom Verma via GitGitGadget, Aug 17, 2020
  28. 1/9 ref-filter: support different email formatsHariom Verma via GitGitGadget, Aug 17, 2020
  29. 4/9 ref-filter: rename `objectname` related functions and fieldsHariom Verma via GitGitGadget, Aug 17, 2020
  30. 7/9 pretty: refactor `format_sanitized_subject()`Hariom Verma via GitGitGadget, Aug 17, 2020
  31. Junio C HamanoAug 17, 2020
  32. Hariom vermaAug 19, 2020
  33. Junio C HamanoAug 19, 2020
  34. Junio C HamanoAug 19, 2020
  35. Hariom vermaAug 20, 2020
  36. Hariom vermaAug 20, 2020
  37. 6/9 ref-filter: add `short` modifier to 'parent' atomHariom Verma via GitGitGadget, Aug 17, 2020
  38. 5/9 ref-filter: add `short` modifier to 'tree' atomHariom Verma via GitGitGadget, Aug 17, 2020
  39. 8/9 format-support: move `format_sanitized_subject()` from prettyHariom Verma via GitGitGadget, Aug 17, 2020
  40. Junio C HamanoAug 17, 2020
  41. 9/9 ref-filter: add `sanitize` option for 'subject' atomHariom Verma via GitGitGadget, Aug 17, 2020
  42. Junio C HamanoAug 17, 2020
  43. 0/8 [GSoC] Improvements to ref-filterHariom Verma via GitGitGadget, Aug 21, 2020
  44. 1/8 ref-filter: support different email formatsHariom Verma via GitGitGadget, Aug 21, 2020
  45. 2/8 ref-filter: refactor `grab_objectname()`Hariom Verma via GitGitGadget, Aug 21, 2020
  46. 3/8 ref-filter: modify error messages in `grab_objectname()`Hariom Verma via GitGitGadget, Aug 21, 2020
  47. 5/8 ref-filter: add `short` modifier to 'tree' atomHariom Verma via GitGitGadget, Aug 21, 2020
  48. 6/8 ref-filter: add `short` modifier to 'parent' atomHariom Verma via GitGitGadget, Aug 21, 2020
  49. 8/8 ref-filter: add `sanitize` option for 'subject' atomHariom Verma via GitGitGadget, Aug 21, 2020
  50. 4/8 ref-filter: rename `objectname` related functions and fieldsHariom Verma via GitGitGadget, Aug 21, 2020
  51. 7/8 pretty: refactor `format_sanitized_subject()`Hariom Verma via GitGitGadget, 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.