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

Re: Combined diff format documentation

From
Junio C Hamano <junkio@cox.net>
Date
Oct 25, 2006, 23:24 UTC
Message-ID
<7vslhcj7x8.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<ehoq5r$8h5$1@sea.gmane.org>
Jakub Narebski <jnareb@gmail.com> writes:
Show 5 quoted lines
> Well, the _documentation_ doesn't tell. I haven't fully grokked the code
> for generating and coloring combined diff output besides the fact that
> I think it uses last indicator ('+' or '-') to chose color for the rest
> of line. You said that even if the possibility exist, it is extreme
> unlikely.
Well if I said that I must have been on booze ;-).

A '-' in the nth column means that the line is from the nth parent and does _not_ appear in the merge result. A '+' in the nth column means that the line _appears_ in the merge result, and the nth parent does not have that line (i.e. added by the merge itself, or inherited from other parents).

Hence, by definition, you cannot have '-' and '+' on the same line (otherwise the line has to exist and not exist in the merge result at the same time).

A ' ' is a bit tricky to interpret. A ' ' on a line _without_ any '-' means the line is the same as in that parent and the merge result (i.e. the result inherited the line from that parent). A ' ' on a line that has '-' talks nothing about the merge result (because by definition '-' lines do not exist in the merge result) nor the parent that has ' '; in other words, it is a "don't care" bit. In the example you quoted from the commit log of af3feefa:

         - static void describe(char *arg)
          -static void describe(struct commit *cmit, int last_one)
         ++static void describe(char *arg, int last_one)
           {

The first parent had it as one-arg function, and the second one two-arg but the first parameter was of type "struct commit *"; the merge result has it as two-arg with the first parameter of type "char *". The second parent does not know about the one-arg form of the function so it has ' ' in its column for the first line.

All versions start the function with an opening brace '{' so the line has two ' ' prefixed, which is an example of ' ' on a line without any '-'.

Previous: Junio C HamanoNext: Jakub Narebski
Message 5 of 10 in “Combined diff format documentation”
  1. Jakub NarebskiOct 25, 2006
  2. Junio C HamanoOct 25, 2006
  3. Jakub NarebskiOct 25, 2006
  4. Junio C HamanoOct 25, 2006
  5. Junio C HamanoOct 25, 2006
  6. Jakub NarebskiOct 25, 2006
  7. diff-format.txt: Combined diff format documentation supplementJakub Narebski, Oct 26, 2006
  8. Junio C HamanoOct 26, 2006
  9. Junio C HamanoOct 26, 2006
  10. Junio C HamanoOct 26, 2006

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.