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

Re: [PATCH v4 6/6] Make --color-words work well with --graph

From
Junio C Hamano <gitster@pobox.com>
Date
May 29, 2010, 01:10 UTC
Message-ID
<7viq675x7t.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1274858637-13243-4-git-send-email-struggleyb.nku@gmail.com>
Bo Yang <struggleyb.nku@gmail.com> writes:
Show 6 quoted lines
> '--color-words' algorithm can be described as:
>
> 1. collect a the minus/plus lines of a diff hunk, divided into minus-lines and plus-lines;
> 2. break both minus-lines and plus-lines into words and place them into two
>    mmfile_t with one word for each line;
> 3. use xdiff to run diff on the two mmfile_t to get the words level diff;

Please wrap lines at reasonable length, and indent bulleted lists like this a bit from the left, with a blank line between each item, like this:

|'--color-words' algorithm can be described as:
|
|  1. collect a the minus/plus lines of a diff hunk, divided into
|     minus-lines and plus-lines;
|
|  2. break both minus-lines and plus-lines into words and place them
|     into two mmfile_t with one word for each line;
|
|  3. use xdiff to run diff on the two mmfile_t to get the words level
|     diff;
|
|And for the common parts of the both file, we output the plus side...
| ...
|For '--graph' to work with '--color-words', we need to output the
|graph prefix on each line of color words output. Generally, there are
|two conditions on which we should output the prefix.
|
|  1. diff_words->last_minus == 0 &&
|     diff_words->current_plus == diff_words->plus.text.ptr
|
|     that is: the plus text must start as a new line, and if there is
|     no minus word printed, a graph prefix must be printed.
|
|  2. diff_words->current_plus > diff_words->plus.text.ptr &&
|     *(diff_words->current_plus - 1) == '\n'
|
|     that is: a graph prefix must be printed following a '\n'.

Same thing for the in-code comments; it would probably be easier to read if you made a small helper function (that a compiler would inline for you) that decides if you would want to show the line_prefix, and make that big comment a comment to that helper function.

Previous: Bo YangNext: Junio C Hamano
Message 5 of 7 in “diff.c: Output the text graph padding before each diff line”
  1. 3/6 diff.c: Output the text graph padding before each diff lineBo Yang, May 26, 2010
  2. 4/6 Emit a whole line once a timeBo Yang, May 26, 2010
  3. 5/6 Register a callback for graph outputBo Yang, May 26, 2010
  4. 6/6 Make --color-words work well with --graphBo Yang, May 26, 2010
  5. Junio C HamanoMay 29, 2010
  6. Junio C HamanoMay 29, 2010
  7. Bo YangMay 29, 2010

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.