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

[PATCH] Re: Teach mailinfo to ignore everything before -- >8 -- mark

From
NSNicolas Sebrecht <nicolas.s.dev@gmx.fr>
Date
Aug 26, 2009, 03:54 UTC
Message-ID
<20090826035401.GJ3526@vidovic>
In-Reply-To
<7vvdkbl4ul.fsf@alter.siamese.dyndns.org>
The 25/08/09, Junio C Hamano wrote:
Show 9 quoted lines
> What I meant was that I would not want to spend any more of _my_ time on
> the definition of the scissors for now.  That means spending or wasting
> time on improving the 'pu' patch myself, or looking at others patch to
> find flaws in them.
> 
> Of course, as the maintainer, I would need to look at proposals to improve
> or fix bugs in the code before the series hits the master, but I would
> give zero priority to the patches that change the definition at least for
> now to give myself time to work on more useful things.
Ok, thank you.
> I think --ignore-scissors is a good thing to add, regardless of what the
> definition of scissors should be.  So your patch should definitely be
> separated into two parts.
Could find it at the end of the mails.
Show 7 quoted lines
> >  #include "builtin.h"
> >  #include "utf8.h"
> >  #include "strbuf.h"
> > +#include "git-compat-util.h"
> 
> Inclusion of builtin.h is designed to be enough.  What do you need this
> for?
It is for the warning() call
  warning("scissors line found, will skip text above");

I've added. That said, moving this declaration to builtin.h could be a good idea. Hint?

Show 7 quoted lines
> > @@ -715,51 +717,63 @@ static inline int patchbreak(const struct strbuf *line)
> >  		if (isspace(buf[i])) {
> > +			if (scissors_dashes_seen)
> > +				mark_end = i;
> 
> I think you do not want this part, and then you won't have to trim
> trailing whitespaces from mark_end later.
Good eyes.
Show 8 quoted lines
> > +			/*
> > +			 * The mark is 8 charaters long and contains at least one dash and
> > +			 * either a ">8" or "<8". Check if the last mark in the line
> > +			 * matches the first mark found without worrying about what could
> > +			 * be between them. Only one mark in the whole line is permitted.
> > +			 */
> 
> This definition makes "-            8<" a scissors.  

Yes. Instead of looking for dashes alone, I will give a try to something like

	  if (!scissors_dashes_seen)
	    mark_start = i;
	  if (i + 1 < len) {
	    if (!memcmp(buf + i, ">8", 2) || !memcmp(buf + i, "8<", 2))) {
	      scissors_dashes_seen |= 02;
	      i++;
	      mark_end = i;
	      continue;
	    else if (!memcmp(buf + i "--", 2) {
	      scissors_dashes_seen |= 04;
	      i++;
	      mark_end = i;
	      continue;
	    }
	  }
	  if (i + 2 < len)
	    if (!memcmp(buf + i + 1, "- -", 3) {
	      scissors_dashes_seen |= 04;
	      i += 2;
	      mark_end = i;
	      continue;
	    }
	  if (buf[i] == '-') {
	    mark_end = i;
	    scissors_dashes_seen |= 01;
	    continue;
	  }
	  break;
	}
	
	if (scissors_dashes_seen == 07) {
	  ...
> it does not allow
> 
>     "-- 8< -- please cut here -- 8< -- --"

Actually, I believe this one should really not be a scissors line. If we accept some random dashes around markers it will break the definition of the mark itself.

As I said, I'd rather rules easy to define over others because if the end-user scissors line doesn't work, he can refer to the documentation...

Show 7 quoted lines
> nor
> 
>     "-- 8< -- -- please cut here -- -- 8< --"
> 
> nor
> 
>     "-- 8< -- -- please cut here -- -- >8 --"
...and symmetrical markers make sense to the user. Will add this.
Show 11 quoted lines
> > +	if (!ignore_scissors) {
> > +		if (is_scissors_line(line)) {
> > +			warning("scissors line found, will skip text above");
> > ...
> > +			return 0;
> 
> Don't re-indent like this.  Just do:
> 
> 	if (!ignore_scissors && is_scissors_line(line)) {
>         	...
> 	}

Does the compilers (or a standard) assure that the members are evaluated in the left-right order?

Otherwise, we may call is_scissors_line() where not needed.
-- 
Nicolas Sebrecht
Previous: Junio C HamanoNext: Nanako Shiraishi
Message 43 of 63 in “Help/Advice needed on diff bug in xutils.c”
  1. Thell FowlerAug 4, 2009
  2. Johannes SchindelinAug 5, 2009
  3. Thell FowlerAug 10, 2009
  4. Add diff tests for trailing-space and now newlineThell Fowler, Aug 12, 2009
  5. 0/6 Series to correct xutils incomplete line handling.Thell Fowler, Aug 19, 2009
  6. Thell FowlerAug 21, 2009
  7. Alex RiesenAug 21, 2009
  8. Thell FowlerAug 22, 2009
  9. 0/6 improvements for trailing-space processing on incomplete linesThell Fowler, Aug 23, 2009
  10. 1/6 Add supplemental test for trailing-whitespace on incomplete linesThell Fowler, Aug 23, 2009
  11. 2/6 xutils: fix hash with whitespace on incomplete lineThell Fowler, Aug 23, 2009
  12. Junio C HamanoAug 23, 2009
  13. Thell FowlerAug 23, 2009
  14. 3/6 xutils: fix ignore-all-space on incomplete lineThell Fowler, Aug 23, 2009
  15. Junio C HamanoAug 23, 2009
  16. Nanako ShiraishiAug 23, 2009
  17. Junio C HamanoAug 23, 2009
  18. Nanako ShiraishiAug 23, 2009
  19. Junio C HamanoAug 23, 2009
  20. Thell FowlerAug 23, 2009
  21. Junio C HamanoAug 23, 2009
  22. Teach mailinfo to ignore everything before -- >8 -- markNicolas Sebrecht, Aug 24, 2009
  23. Junio C HamanoAug 24, 2009
  24. Junio C HamanoAug 24, 2009
  25. Re: Teach mailinfo to ignore everything before -- >8 -- markNicolas Sebrecht, Aug 24, 2009
  26. Junio C HamanoAug 24, 2009
  27. Re: Teach mailinfo to ignore everything before -- >8 -- markNicolas Sebrecht, Aug 24, 2009
  28. Don ZickusAug 24, 2009
  29. Junio C HamanoAug 24, 2009
  30. Nanako ShiraishiAug 24, 2009
  31. Re: Teach mailinfo to ignore everything before -- >8 -- markNicolas Sebrecht, Aug 24, 2009
  32. Re: Teach mailinfo to ignore everything before -- >8 -- markNicolas Sebrecht, Aug 24, 2009
  33. Junio C HamanoAug 24, 2009
  34. Nicolas SebrechtAug 25, 2009
  35. Junio C HamanoAug 26, 2009
  36. Junio C HamanoAug 26, 2009
  37. Re: Teach mailinfo to ignore everything before -- >8 -- markNicolas Sebrecht, Aug 26, 2009
  38. Jakub NarebskiAug 26, 2009
  39. Johannes SchindelinAug 26, 2009
  40. Junio C HamanoAug 27, 2009
  41. Johannes SchindelinAug 27, 2009
  42. Junio C HamanoAug 26, 2009
  43. Re: Teach mailinfo to ignore everything before -- >8 -- markNicolas Sebrecht, Aug 26, 2009
  44. Nanako ShiraishiAug 24, 2009
  45. Thell FowlerAug 23, 2009
  46. Junio C HamanoAug 23, 2009
  47. Thell FowlerAug 23, 2009
  48. Junio C HamanoAug 23, 2009
  49. Thell FowlerAug 24, 2009
  50. Junio C HamanoAug 24, 2009
  51. Thell FowlerAug 24, 2009
  52. Thell FowlerAug 25, 2009
  53. 4/6 xutils: fix ignore-space-change on incomplete lineThell Fowler, Aug 23, 2009
  54. 5/6 xutils: fix ignore-space-at-eol on incomplete lineThell Fowler, Aug 23, 2009
  55. 6/6 t4015: add tests for trailing-space on incomplete lineThell Fowler, Aug 23, 2009
  56. 1/6 Add supplemental test for trailing-whitespace on incomplete lines.Thell Fowler, Aug 19, 2009
  57. 2/6 Make xdl_hash_record_with_whitespace ignore eofThell Fowler, Aug 19, 2009
  58. 3/6 Make diff -w handle trailing-spaces on incomplete lines.Thell Fowler, Aug 19, 2009
  59. Thell FowlerAug 20, 2009
  60. 4/6 Make diff -b handle trailing-spaces on incomplete lines.Thell Fowler, Aug 19, 2009
  61. 5/6 Make diff --ignore-space-at-eol handle incomplete lines.Thell Fowler, Aug 19, 2009
  62. 6/6 Add diff tests for trailing-space on incomplete linesThell Fowler, Aug 19, 2009
  63. Junio C HamanoAug 26, 2009

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.