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

Re: [PATCH v3 05/11] sequencer.c: recognize "(cherry picked from ..." as part of s-o-b footer

From
Brandon Casey <drafnel@gmail.com>
Date
Jan 28, 2013, 05:38 UTC
Message-ID
<CA+sFfMfm3k8T-TrXxZPD6pe4hN3LoCH98Txeam4HCmw1scHswA@mail.gmail.com>
In-Reply-To
<20130128025140.GI8206@elie.Belkin>
On Sun, Jan 27, 2013 at 6:51 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 56 quoted lines
> Jonathan Nieder wrote:
>
>> Here's the tweak I suggested last time.  I think its behavior is
>> slightly better in the "ends with incomplete line" case because it
>> limits the characters examined by is_rfc2822_line() and
>> is_cherry_picked_from_line() not to include buf[len] (which would
>> presumably sometimes be '\0').
>
> Whoops, that revealed a subtlety --- the '\n' or '\0' is what prevents
> exiting the loop in is_rfc2822_line when the line does not contain a
> colon.  Here's a corrected version of the tweak, that should actually
> work. :)
>
> diff --git i/sequencer.c w/sequencer.c
> index 0b5cd18c..108ea27b 100644
> --- i/sequencer.c
> +++ w/sequencer.c
> @@ -1029,13 +1029,11 @@ static int is_rfc2822_line(const char *buf, int len)
>         for (i = 0; i < len; i++) {
>                 int ch = buf[i];
>                 if (ch == ':')
> +                       return 1;
> +               if (!isalnum(ch) && ch != '-')
>                         break;
> -               if (isalnum(ch) || (ch == '-'))
> -                       continue;
> -               return 0;
>         }
> -
> -       return 1;
> +       return 0;
>  }
>
>  static int is_cherry_picked_from_line(const char *buf, int len)
> @@ -1043,9 +1041,7 @@ static int is_cherry_picked_from_line(const char *buf, int len)
>         /*
>          * We only care that it looks roughly like (cherry picked from ...)
>          */
> -       return !prefixcmp(buf, cherry_picked_prefix) &&
> -               (buf[len - 1] == ')' ||
> -                (buf[len - 1] == '\n' && buf[len - 2] == ')'));
> +       return !prefixcmp(buf, cherry_picked_prefix) && buf[len - 1] == ')';
>  }
>
>  static int has_conforming_footer(struct strbuf *sb, int ignore_footer)
> @@ -1072,8 +1068,8 @@ static int has_conforming_footer(struct strbuf *sb, int ignore_footer)
>                         ; /* do nothing */
>                 k++;
>
> -               if (!(is_rfc2822_line(buf + i, k - i) ||
> -                       is_cherry_picked_from_line(buf + i, k - i)))
> +               if (!is_rfc2822_line(buf + i, k - i - 1) &&
> +                   !is_cherry_picked_from_line(buf + i, k - i - 1))
>                         return 0;
>         }
>         return 1;
Looks good to me.
-Brandon
Previous: Jonathan NiederNext: Brandon Casey
Message 12 of 36 in “unify appending of sob”
  1. 00/11 unify appending of sobBrandon Casey, Jan 28, 2013
  2. 01/11 sequencer.c: rework search for start of footer to improve clarityBrandon Casey, Jan 28, 2013
  3. Jonathan NiederJan 28, 2013
  4. 02/11 commit, cherry-pick -s: remove broken support for multiline rfc2822 fieldsBrandon Casey, Jan 28, 2013
  5. Jonathan NiederJan 28, 2013
  6. 03/11 t/test-lib-functions.sh: allow to specify the tag name to test_commitBrandon Casey, Jan 28, 2013
  7. 04/11 t/t3511: add some tests of 'cherry-pick -s' functionalityBrandon Casey, Jan 28, 2013
  8. Jonathan NiederJan 28, 2013
  9. 05/11 sequencer.c: recognize "(cherry picked from ..." as part of s-o-b footerBrandon Casey, Jan 28, 2013
  10. Jonathan NiederJan 28, 2013
  11. Jonathan NiederJan 28, 2013
  12. Brandon CaseyJan 28, 2013
  13. 06/11 sequencer.c: always separate "(cherry picked from" from commit bodyBrandon Casey, Jan 28, 2013
  14. Jonathan NiederJan 28, 2013
  15. Brandon CaseyFeb 10, 2013
  16. 07/11 sequencer.c: teach append_signoff how to detect duplicate s-o-bBrandon Casey, Jan 28, 2013
  17. Jonathan NiederJan 28, 2013
  18. Jonathan NiederJan 28, 2013
  19. Brandon CaseyFeb 10, 2013
  20. 08/11 sequencer.c: teach append_signoff to avoid adding a duplicate newlineBrandon Casey, Jan 28, 2013
  21. Jonathan NiederJan 28, 2013
  22. 09/11 t4014: more tests about appending s-o-b linesBrandon Casey, Jan 28, 2013
  23. Jonathan NiederJan 28, 2013
  24. Junio C HamanoJan 28, 2013
  25. Junio C HamanoJan 28, 2013
  26. 10/11 format-patch: update append_signoff prototypeBrandon Casey, Jan 28, 2013
  27. Jonathan NiederJan 28, 2013
  28. 11/11 Unify appending signoff in format-patch, commit and sequencerBrandon Casey, Jan 28, 2013
  29. Jonathan NiederJan 28, 2013
  30. Brandon CaseyFeb 10, 2013
  31. Jonathan NiederFeb 11, 2013
  32. Brandon CaseyFeb 11, 2013
  33. Jonathan NiederJan 28, 2013
  34. Junio C HamanoJan 28, 2013
  35. Junio C HamanoJan 30, 2013
  36. Brandon CaseyJan 31, 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.