{"thread":{"id":"15564","subject":"combined diff, but not condensed, howto?","startedAt":"2008-09-17T08:00:07Z","lastAt":"2008-09-18T09:30:26Z","messageCount":9,"participants":["Johannes Sixt","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"90902","messageId":"48D0B907.7040903@viscovery.net","threadId":"15564","inReplyTo":null,"subject":"combined diff, but not condensed, howto?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-17T08:00:07Z","receivedAt":"2008-09-17T08:00:07Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"After a merge conflict, 'git diff' shows a combined diff, which presents\nonly the parts that conflicted or where there are near-by changes from\ndifferent parents (potential conflicts). Is there a command line switch so\nthat *all* changes are shown, even non-conflicting ones?\n\n'git diff', 'git diff --cc', and 'git diff -c' all show the same output.\n\n-- Hannes\n"},{"id":"90959","messageId":"7vwsha6761.fsf@gitster.siamese.dyndns.org","threadId":"15564","inReplyTo":"48D0B907.7040903@viscovery.net","subject":"Re: combined diff, but not condensed, howto?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-17T16:58:30Z","receivedAt":"2008-09-17T16:58:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> After a merge conflict, 'git diff' shows a combined diff, which presents\n> only the parts that conflicted or where there are near-by changes from\n> different parents (potential conflicts). Is there a command line switch so\n> that *all* changes are shown, even non-conflicting ones?\n\nLike \"git diff HEAD\"?\n"},{"id":"90991","messageId":"48D1EDB7.5070107@viscovery.net","threadId":"15564","inReplyTo":"7vwsha6761.fsf@gitster.siamese.dyndns.org","subject":"Re: combined diff, but not condensed, howto?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-18T05:57:11Z","receivedAt":"2008-09-18T05:57:11Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> Johannes Sixt <j.sixt@viscovery.net> writes:\n> \n>> After a merge conflict, 'git diff' shows a combined diff, which presents\n>> only the parts that conflicted or where there are near-by changes from\n>> different parents (potential conflicts). Is there a command line switch so\n>> that *all* changes are shown, even non-conflicting ones?\n> \n> Like \"git diff HEAD\"?\n\nNo. Something that produces\n\n@@@ -23,5 -23,5 +23,7 @@@\n  A\n  B\n++<<<<<<< HEAD:foo\n +C\n++=======\n+ D\n++>>>>>>> 97d7fee2cb068f215a593c6e5623b265db45d3bc:foo\n  E\n  F\n@@@ -50,4 -50,5 +53,5 @@@\n  G\n  H\n +I\n  J\n  K\n@@@ -60,5 -61,4 +63,4 @@@\n  L\n  M\n- N\n  O\n  P\n"},{"id":"90992","messageId":"7vy71qyo9d.fsf@gitster.siamese.dyndns.org","threadId":"15564","inReplyTo":"48D1EDB7.5070107@viscovery.net","subject":"Re: combined diff, but not condensed, howto?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-18T06:14:06Z","receivedAt":"2008-09-18T06:14:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Junio C Hamano schrieb:\n>> Johannes Sixt <j.sixt@viscovery.net> writes:\n>> \n>>> After a merge conflict, 'git diff' shows a combined diff, which presents\n>>> only the parts that conflicted or where there are near-by changes from\n>>> different parents (potential conflicts). Is there a command line switch so\n>>> that *all* changes are shown, even non-conflicting ones?\n>> \n>> Like \"git diff HEAD\"?\n>\n> No. Something that produces\n...\n\nAh, I see what you mean.\n\nIt all happens inside combine-diff.c::make_hunks().  If you pass dense==0,\nyou should be able to get all the uninteresting hunks, I think.\n\nPerhaps\n\n\t$ git diff --base -c\n\n???\n"},{"id":"90996","messageId":"48D1F426.4040208@viscovery.net","threadId":"15564","inReplyTo":"7vy71qyo9d.fsf@gitster.siamese.dyndns.org","subject":"Re: combined diff, but not condensed, howto?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-18T06:24:38Z","receivedAt":"2008-09-18T06:24:38Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> Johannes Sixt <j.sixt@viscovery.net> writes:\n> \n>> Junio C Hamano schrieb:\n>>> Johannes Sixt <j.sixt@viscovery.net> writes:\n>>>\n>>>> After a merge conflict, 'git diff' shows a combined diff, which presents\n>>>> only the parts that conflicted or where there are near-by changes from\n>>>> different parents (potential conflicts). Is there a command line switch so\n>>>> that *all* changes are shown, even non-conflicting ones?\n>>> Like \"git diff HEAD\"?\n>> No. Something that produces\n> ...\n> \n> Ah, I see what you mean.\n> \n> It all happens inside combine-diff.c::make_hunks().  If you pass dense==0,\n> you should be able to get all the uninteresting hunks, I think.\n> \n> Perhaps\n> \n> \t$ git diff --base -c\n\nYes, that does it!\n\nThanks,\n-- Hannes\n"},{"id":"91003","messageId":"7vskryym24.fsf@gitster.siamese.dyndns.org","threadId":"15564","inReplyTo":"48D1F426.4040208@viscovery.net","subject":"Re: combined diff, but not condensed, howto?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-18T07:01:39Z","receivedAt":"2008-09-18T07:01:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> Junio C Hamano schrieb:\n> ...\n>> It all happens inside combine-diff.c::make_hunks().  If you pass dense==0,\n>> you should be able to get all the uninteresting hunks, I think.\n>> \n>> Perhaps\n>> \n>> \t$ git diff --base -c\n>\n> Yes, that does it!\n\nIt may do so, but I do not necessarily agree with the logic.\n\nIt is very much Ok and useful for \"git diff\" to default to \"--cc -p\", and\nit may be fine for \"git diff-files -p\" to default to \"--cc\".\n\nBut I think ideally an explicit \"git diff -c\" and \"git diff-files -c -p\"\nshould not turn the \"dense combined\" mode on.\n\nThe commonality of these two functions is striking and calls for proper\nrefactoring, but aside from that, I think a patch like this should be\napplied.  What do you think?\n\n---\n\n builtin-diff-files.c |    7 ++++++-\n builtin-diff.c       |    7 ++++++-\n 2 files changed, 12 insertions(+), 2 deletions(-)\n\ndiff --git i/builtin-diff-files.c w/builtin-diff-files.c\nindex 9bf10bb..2b578c7 100644\n--- i/builtin-diff-files.c\n+++ w/builtin-diff-files.c\n@@ -50,7 +50,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)\n \t    3 < rev.max_count)\n \t\tusage(diff_files_usage);\n \n-\tif (rev.max_count == -1 &&\n+\t/*\n+\t * \"diff-files --base -p\" should not combine merges because it\n+\t * was not asked to.  \"diff-files -c -p\" should not densify\n+\t * (the user should ask with \"diff-files --cc\" explicitly).\n+\t */\n+\tif (rev.max_count == -1 && !rev.combine_merges &&\n \t    (rev.diffopt.output_format & DIFF_FORMAT_PATCH))\n \t\trev.combine_merges = rev.dense_combined_merges = 1;\n \ndiff --git i/builtin-diff.c w/builtin-diff.c\nindex 037c303..9fb30c6 100644\n--- i/builtin-diff.c\n+++ w/builtin-diff.c\n@@ -223,7 +223,12 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv\n \t\targv++; argc--;\n \t}\n \n-\tif (revs->max_count == -1 &&\n+\t/*\n+\t * \"diff --base\" should not combine merges because it was not\n+\t * asked to.  \"diff -c\" should not densify (the user should ask\n+\t * with \"diff --cc\" explicitly.\n+\t */\n+\tif (revs->max_count == -1 && !revs->combine_merges &&\n \t    (revs->diffopt.output_format & DIFF_FORMAT_PATCH))\n \t\trevs->combine_merges = revs->dense_combined_merges = 1;\n \n"},{"id":"91008","messageId":"48D203B3.90807@viscovery.net","threadId":"15564","inReplyTo":"7vskryym24.fsf@gitster.siamese.dyndns.org","subject":"Re: combined diff, but not condensed, howto?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-18T07:30:59Z","receivedAt":"2008-09-18T07:30:59Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> It is very much Ok and useful for \"git diff\" to default to \"--cc -p\", and\n> it may be fine for \"git diff-files -p\" to default to \"--cc\".\n> \n> But I think ideally an explicit \"git diff -c\" and \"git diff-files -c -p\"\n> should not turn the \"dense combined\" mode on.\n> \n> The commonality of these two functions is striking and calls for proper\n> refactoring, but aside from that, I think a patch like this should be\n> applied.  What do you think?\n\nThis makes a lot of sense. As I mention in my initial post, I was\nwondering why 'diff -c' was the same as 'diff --cc'.\n\n> diff --git i/builtin-diff-files.c w/builtin-diff-files.c\n> index 9bf10bb..2b578c7 100644\n> --- i/builtin-diff-files.c\n> +++ w/builtin-diff-files.c\n> @@ -50,7 +50,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)\n>  \t    3 < rev.max_count)\n>  \t\tusage(diff_files_usage);\n>  \n> -\tif (rev.max_count == -1 &&\n> +\t/*\n> +\t * \"diff-files --base -p\" should not combine merges because it\n> +\t * was not asked to.  \"diff-files -c -p\" should not densify\n> +\t * (the user should ask with \"diff-files --cc\" explicitly).\n> +\t */\n> +\tif (rev.max_count == -1 && !rev.combine_merges &&\n>  \t    (rev.diffopt.output_format & DIFF_FORMAT_PATCH))\n>  \t\trev.combine_merges = rev.dense_combined_merges = 1;\n\nHm... In my tests, a bare 'git diff-files --cc' produces a combined diff,\nbut 'git diff-files -c' does not.\n\n> diff --git i/builtin-diff.c w/builtin-diff.c\n> index 037c303..9fb30c6 100644\n> --- i/builtin-diff.c\n> +++ w/builtin-diff.c\n> @@ -223,7 +223,12 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv\n>  \t\targv++; argc--;\n>  \t}\n>  \n> -\tif (revs->max_count == -1 &&\n> +\t/*\n> +\t * \"diff --base\" should not combine merges because it was not\n> +\t * asked to.  \"diff -c\" should not densify (the user should ask\n> +\t * with \"diff --cc\" explicitly.\n\nI don't see why you add \"the user should ask with 'diff --cc'\" when this\nbecomes the default anyway.\n\n> +\t */\n> +\tif (revs->max_count == -1 && !revs->combine_merges &&\n>  \t    (revs->diffopt.output_format & DIFF_FORMAT_PATCH))\n>  \t\trevs->combine_merges = revs->dense_combined_merges = 1;\n\n-- Hannes\n"},{"id":"91016","messageId":"7v7i99zuqh.fsf_-_@gitster.siamese.dyndns.org","threadId":"15564","inReplyTo":"48D203B3.90807@viscovery.net","subject":"[PATCH] diff/diff-files: do not use --cc too aggressively","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-18T09:08:54Z","receivedAt":"2008-09-18T09:08:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Textual diff output for unmerged paths was too eager to give condensed\ncombined diff.  This has two problems:\n\n (1) \"diff --base/--ours/--theirs\" (and \"diff-files -p\" with the same) is\n     a request to compare with the named stage.  We showed \"-c -p\" output\n     instead;\n\n (2) \"diff -c\" (and \"diff-files -c -p\") is a request to view combined diff\n     without condensing (otherwise the user would have explicitly asked\n     for --cc, not -c).  We showed \"--cc\" output anyway.\n\n0fe7c1d (built-in diff: assorted updates, 2006-04-29) claimed to be\ncareful about doing this, but its breakage was hidden because back then\n\"git diff\" was still a shell script that did not use the codepath it\nintroduced fully.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin-diff-files.c |    7 ++++++-\n builtin-diff.c       |    8 +++++++-\n 2 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-diff-files.c b/builtin-diff-files.c\nindex 9bf10bb..2b578c7 100644\n--- a/builtin-diff-files.c\n+++ b/builtin-diff-files.c\n@@ -50,7 +50,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)\n \t    3 < rev.max_count)\n \t\tusage(diff_files_usage);\n \n-\tif (rev.max_count == -1 &&\n+\t/*\n+\t * \"diff-files --base -p\" should not combine merges because it\n+\t * was not asked to.  \"diff-files -c -p\" should not densify\n+\t * (the user should ask with \"diff-files --cc\" explicitly).\n+\t */\n+\tif (rev.max_count == -1 && !rev.combine_merges &&\n \t    (rev.diffopt.output_format & DIFF_FORMAT_PATCH))\n \t\trev.combine_merges = rev.dense_combined_merges = 1;\n \ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex 037c303..d5fe775 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -223,7 +223,13 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv\n \t\targv++; argc--;\n \t}\n \n-\tif (revs->max_count == -1 &&\n+\t/*\n+\t * \"diff --base\" should not combine merges because it was not\n+\t * asked to.  \"diff -c\" should not densify (if the user wants\n+\t * dense one, --cc can be explicitly asked for, or just rely\n+\t * on the default).\n+\t */\n+\tif (revs->max_count == -1 && !revs->combine_merges &&\n \t    (revs->diffopt.output_format & DIFF_FORMAT_PATCH))\n \t\trevs->combine_merges = revs->dense_combined_merges = 1;\n \n-- \n1.6.0.2.412.g0bc80\n"},{"id":"91018","messageId":"48D21FB2.50700@viscovery.net","threadId":"15564","inReplyTo":"7v7i99zuqh.fsf_-_@gitster.siamese.dyndns.org","subject":"Re: [PATCH] diff/diff-files: do not use --cc too aggressively","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-18T09:30:26Z","receivedAt":"2008-09-18T09:30:26Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> Textual diff output for unmerged paths was too eager to give condensed\n> combined diff.  This has two problems:\n> \n>  (1) \"diff --base/--ours/--theirs\" (and \"diff-files -p\" with the same) is\n>      a request to compare with the named stage.  We showed \"-c -p\" output\n>      instead;\n\nI cannot reproduce what you describe here. \"diff --base/--ours/--theirs\"\nworks as expected with and without this patch.\n\n>  (2) \"diff -c\" (and \"diff-files -c -p\") is a request to view combined diff\n>      without condensing (otherwise the user would have explicitly asked\n>      for --cc, not -c).  We showed \"--cc\" output anyway.\n\nThe patch fixes this:\n\nTested-by: Johannes Sixt <johannes.sixt@telecom.at>\n\n-- Hannes\n"}]}