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

Re: Confused about diff-tree --cc output

From
Jay Soffian <jaysoffian@gmail.com>
Date
Feb 5, 2009, 03:49 UTC
Message-ID
<76718490902041949v8fffd17l7cb19d836a3e1887@mail.gmail.com>
In-Reply-To
<7vk585n9x8.fsf@gitster.siamese.dyndns.org>
On Wed, Feb 4, 2009 at 4:56 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 5 quoted lines
> I think this is "more than two versions", in
>
>    http://thread.gmane.org/gmane.comp.version-control.git/15486/focus=15491
>
> Nothing new to see here, I think.
Okay, let me just make sure I understand. The output of git show has:

diff --cc builtin-remote.c index abc8dd8,07cfdac..db18bcf

So, I can do:

git diff abc8dd8 db18bcf > parent1.diff git diff 07cfdac db18bcf > parent2.diff

Then look at each for overlapping hunks. If I do so, I find that this hunk in parent1.diff (I've annotated w/line numbers):

@@ -542,8 +552,11 @@ static int rm(int argc, const char **argv)
552 	struct strbuf buf = STRBUF_INIT;
553 	struct known_remotes known_remotes = { NULL, NULL };
554 	struct string_list branches = { NULL, 0, 0, 1 };
   -	struct branches_for_remote cb_data = { NULL, &branches, &known_remotes };
   -	int i;
555+	struct string_list skipped = { NULL, 0, 0, 1 };
556+	struct branches_for_remote cb_data = {
557+		NULL, &branches, &skipped, &known_remotes
558+	};
559+	int i, result;
560
561 	if (argc != 2)
562 		usage_with_options(builtin_remote_usage, options);

and this hunk in parent2.diff:

@@ -362,7 +549,7 @@ static int rm(int argc, const char **argv)
549 		OPT_END()
550 	};
551 	struct remote *remote;
   -	struct strbuf buf;
552+	struct strbuf buf = STRBUF_INIT;
553 	struct known_remotes known_remotes = { NULL, NULL };
554 	struct string_list branches = { NULL, 0, 0, 1 };
555 	struct string_list skipped = { NULL, 0, 0, 1 };

overlap (lines 552-555). Since the hunks overlap, and each introduces
a unique change, both hunks are shown in the combined format. I guess
this makes sense now that I know how it works, but my expectation had
been that I'd only see output if there was a merge conflict.

I also note that "git diff-tree -U2 --cc 8554af" produces no output,
and this is because there is no longer overlap (well, the context
lines overlap, but are identical, which I guess is good enough).

Is that about right?

(Aside, to reconstruct the merge manually I did the following, but I
bet there is an easier way:

git show 3613d1d:builtin-remote.c > mine
git show 441adf0:builtin-remote.c > other
git show $(git merge-base 3613d1d 441adf0):builtin-remote.c > base
git merge-file -p mine base other
)

j.
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “Confused about diff-tree --cc output”
  1. Jay SoffianFeb 4, 2009
  2. Junio C HamanoFeb 4, 2009
  3. Jay SoffianFeb 5, 2009
  4. Junio C HamanoFeb 5, 2009
  5. Jay SoffianFeb 5, 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.