{"thread":{"id":"43536","subject":"Re: git: how to produce context diffs?","startedAt":"2006-11-27T14:16:30Z","lastAt":"2006-11-27T19:18:32Z","messageCount":8,"participants":["Sean","Bruno Haible","Jakub Narebski","Thomas Kolejka","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"295448","messageId":"200611271516.30425.bruno@clisp.org","threadId":"43536","inReplyTo":null,"subject":"git: how to produce context diffs?","fromName":"Bruno Haible","fromEmail":"bruno@clisp.org","sentAt":"2006-11-27T14:16:30Z","receivedAt":"2006-11-27T14:16:30Z","isPatch":false,"sender":{"key":"bruno@clisp.org","avatar":null},"body":"Hi,\n\nIs this a bug in git-diff? The git-diff-files.html says:\n\n  \" When the environment variable GIT_EXTERNAL_DIFF is not set ...\n    For example, if you prefer context diff:\n    GIT_DIFF_OPTS=-c git-diff-index -p HEAD  \"\n\nThis doesn't work for me with git-1.4.4:\n\n$ unset GIT_EXTERNAL_DIFF\n$ export GIT_DIFF_OPTS=-c\n$ git-diff-index -p HEAD\ndiff --git a/configure.ac b/configure.ac\nindex 74901dc..d222ded 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -1,5 +1,5 @@\n dnl Process this file with autoconf to produce a configure script.\n-AC_INIT(hello, 2.1.1, bug-gnu-hello@gnu.org)\n+AC_INIT(hello, 2.1.2, bug-gnu-hello@gnu.org)\n AC_CONFIG_SRCDIR([src/hello.c])\n \n AC_PREREQ(2.52)\n\nExpected output:\n\n$ git-diff-index -p HEAD\nindex 74901dc..d222ded 100644\ndiff --git a/configure.ac b/configure.ac\n*** a/configure.ac\n--- b/configure.ac\n***************\n*** 1,5 ****\n  dnl Process this file with autoconf to produce a configure script.\n! AC_INIT(hello, 2.1.1, bug-gnu-hello@gnu.org)\n  AC_CONFIG_SRCDIR([src/hello.c])\n  \n  AC_PREREQ(2.52)\n--- 1,5 ----\n  dnl Process this file with autoconf to produce a configure script.\n! AC_INIT(hello, 2.1.2, bug-gnu-hello@gnu.org)\n  AC_CONFIG_SRCDIR([src/hello.c])\n  \n  AC_PREREQ(2.52)\n\n\n(Really, while I find -u diffs fine for tiny changes, I find them unreadable\nfor rewrites of larger blocks, and cannot live without -c for these.)\n\nWhen I look at diff.c around\n       const char *diffopts = getenv(\"GIT_DIFF_OPTS\");\nit appears that only unified diffs are supported??\n\n"},{"id":"297319","messageId":"ekesgt$6jq$1@sea.gmane.org","threadId":"43536","inReplyTo":"200611271516.30425.bruno@clisp.org","subject":"Re: git: how to produce context diffs?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-27T14:27:20Z","receivedAt":"2006-11-27T14:27:20Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Bruno Haible wrote:\n\n> Is this a bug in git-diff? The git-diff-files.html says:\n> \n>   \" When the environment variable GIT_EXTERNAL_DIFF is not set ...\n>     For example, if you prefer context diff:\n>     GIT_DIFF_OPTS=-c git-diff-index -p HEAD  \"\n> \n> This doesn't work for me with git-1.4.4:\n\nYes, the bug in documentation, I think. There is an option '-c' to git-diff,\nbut it means \"combined diff\" (for merges), not \"context diff\".\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"296710","messageId":"BAYC1-PASMTP01B6529D1821EEBC0A6E6FAEE60@CEZ.ICE","threadId":"43536","inReplyTo":"ekesgt$6jq$1@sea.gmane.org","subject":"Re: git: how to produce context diffs?","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-11-27T15:19:49Z","receivedAt":"2006-11-27T15:19:49Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Mon, 27 Nov 2006 15:27:20 +0100\nJakub Narebski <jnareb@gmail.com> wrote:\n\n> Bruno Haible wrote:\n> \n> > Is this a bug in git-diff? The git-diff-files.html says:\n> > \n> >   \" When the environment variable GIT_EXTERNAL_DIFF is not set ...\n> >     For example, if you prefer context diff:\n> >     GIT_DIFF_OPTS=-c git-diff-index -p HEAD  \"\n> > \n> > This doesn't work for me with git-1.4.4:\n> \n> Yes, the bug in documentation, I think. There is an option '-c' to git-diff,\n> but it means \"combined diff\" (for merges), not \"context diff\".\n\nIndeed.  That documentation predates built-in diff completely.\n\nIt appears the only valid options now are \"-u XX\" and \"--unified=XX\".\nThese options are never passed to diff, but rather used to control\nthe internal diff.  Strangely, it appears that gitk is even passing\nincorrect parameters via GIT_DIFF_OPTS.\n\nUnless i've really missed something, the above documentation should be\nreworked to remove mention of running diff altogether, and should mention\nthat the GIT_DIFF_OPTS only has two valid settings.\n\n"},{"id":"295352","messageId":"BAYC1-PASMTP10B822EE809E075EFFD879AEE60@CEZ.ICE","threadId":"43536","inReplyTo":"ekesgt$6jq$1@sea.gmane.org","subject":"Re: git: how to produce context diffs?","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-11-27T15:38:04Z","receivedAt":"2006-11-27T15:38:04Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Mon, 27 Nov 2006 15:27:20 +0100\nJakub Narebski <jnareb@gmail.com> wrote:\n\n> Bruno Haible wrote:\n> \n> > Is this a bug in git-diff? The git-diff-files.html says:\n> > \n> >   \" When the environment variable GIT_EXTERNAL_DIFF is not set ...\n> >     For example, if you prefer context diff:\n> >     GIT_DIFF_OPTS=-c git-diff-index -p HEAD  \"\n> > \n> > This doesn't work for me with git-1.4.4:\n> \n> Yes, the bug in documentation, I think. There is an option '-c' to git-diff,\n> but it means \"combined diff\" (for merges), not \"context diff\".\n\nIndeed.  That documentation predates built-in diff completely.\n\nIt appears the only valid options now are \"-u XX\" and \"--unified=XX\".\nThese options are never passed to diff, but rather used to control\nthe internal diff.  Strangely, it appears that gitk is even passing\nincorrect parameters via GIT_DIFF_OPTS.\n\nUnless i've really missed something, the above documentation should be\nreworked to remove mention of running diff altogether, and should mention\nthat the GIT_DIFF_OPTS only has two valid settings.\n\n"},{"id":"295871","messageId":"200611271705.36479.jnareb@gmail.com","threadId":"43536","inReplyTo":"BAYC1-PASMTP01B6529D1821EEBC0A6E6FAEE60@CEZ.ICE","subject":"Re: git: how to produce context diffs?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-27T16:05:35Z","receivedAt":"2006-11-27T16:05:35Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Sean wrote:\n> On Mon, 27 Nov 2006 15:27:20 +0100\n> Jakub Narebski <jnareb@gmail.com> wrote:\n> \n>> Bruno Haible wrote:\n>> \n>>> Is this a bug in git-diff? The git-diff-files.html says:\n>>> \n>>>   \" When the environment variable GIT_EXTERNAL_DIFF is not set ...\n>>>     For example, if you prefer context diff:\n>>>     GIT_DIFF_OPTS=-c git-diff-index -p HEAD  \"\n>>> \n>>> This doesn't work for me with git-1.4.4:\n>> \n>> Yes, the bug in documentation, I think. There is an option '-c' to git-diff,\n>> but it means \"combined diff\" (for merges), not \"context diff\".\n> \n> Indeed.  That documentation predates built-in diff completely.\n> \n> It appears the only valid options now are \"-u XX\" and \"--unified=XX\".\n\nWhich both mean the same.\n\n> These options are never passed to diff, but rather used to control\n> the internal diff.  Strangely, it appears that gitk is even passing\n> incorrect parameters via GIT_DIFF_OPTS.\n\nWhich, in convoluted way is said in documentation (the fact that\nGIT_DIFF_OPTS affect internal diff).\n \n> Unless i've really missed something, the above documentation should be\n> reworked to remove mention of running diff altogether, and should mention\n> that the GIT_DIFF_OPTS only has two valid settings.\n\nFor now.\n-- \nJakub Narebski\n"},{"id":"295396","messageId":"BAYC1-PASMTP11E0FF8B4ADAE232E667DDAEE60@CEZ.ICE","threadId":"43536","inReplyTo":"200611271705.36479.jnareb@gmail.com","subject":"Re: git: how to produce context diffs?","fromName":"Sean","fromEmail":"seanlkml@sympatico.ca","sentAt":"2006-11-27T17:06:15Z","receivedAt":"2006-11-27T17:06:15Z","isPatch":false,"sender":{"key":"seanlkml@sympatico.ca","avatar":"https://gravatar.com/avatar/f92923f54fc08c401fc59b71829d4b89e9b8087fbba45ff87c82e6a83aee02ae?d=mp&s=160"},"body":"On Mon, 27 Nov 2006 17:05:35 +0100\nJakub Narebski <jnareb@gmail.com> wrote:\n\n> > It appears the only valid options now are \"-u XX\" and \"--unified=XX\".\n> \n> Which both mean the same.\n\nYes, I guess I should have said that.  The point was really that you\ncan't pass any-diff-option and expect it to work.\n\n> Which, in convoluted way is said in documentation (the fact that\n> GIT_DIFF_OPTS affect internal diff).\n\nThe idea is to make it less convoluted.  It directly says that -c should\nwork _because_ it use to work when the options were passed to external\ndiff.  It's not just -c that won't work, none of the other myriad external\ndiff options will work either.\n\n> > Unless i've really missed something, the above documentation should be\n> > reworked to remove mention of running diff altogether, and should mention\n> > that the GIT_DIFF_OPTS only has two valid settings.\n> \n> For now.\n\nWell the documentation can be updated later if additional options\nare added.\n\n"},{"id":"297604","messageId":"20061127183346.30010@gmx.net","threadId":"43536","inReplyTo":"200611271516.30425.bruno@clisp.org","subject":"Re: git: how to produce context diffs?","fromName":"Thomas Kolejka","fromEmail":"thomas.kolejka@gmx.at","sentAt":"2006-11-27T18:33:46Z","receivedAt":"2006-11-27T18:33:46Z","isPatch":false,"sender":{"key":"thomas.kolejka@gmx.at","avatar":null},"body":"Hello,\n\nI'm using the following script 'external-diff.sh':\n\n--\n# path old-file old-hex old-mode new-file new-hex new-mode\n# $1   $2       $3      $4       $5       $6      $7\n\nold_hex=$3\nnew_hex=`git-hash-object $5`\n\nif [ \"$old_hex\" = \"$new_hex\" ]\nthen\n\texit 0\nfi\n\necho \"diff --git a/$1 b/$1\"\necho \"index ${old_hex:0:7}..${new_hex:0:7} $4\"\n\ndiff -L a/$1 -L b/$1 -pc $2 $5\n\nexit 0\n--\n\nwhich can be called by:\n\nexport GIT_EXTERNAL_DIFF=external-diff.sh\ngit-diff-index master -p > my.patch\n\n\n\nBye,\nThomas Kolejka\n\n-- \n\"Ein Herz für Kinder\" - Ihre Spende hilft! Aktion: www.deutschlandsegelt.de\nUnser Dankeschön: Ihr Name auf dem Segel der 1. deutschen America's C"},{"id":"298053","messageId":"7v8xhwhf5j.fsf@assigned-by-dhcp.cox.net","threadId":"43536","inReplyTo":"200611271516.30425.bruno@clisp.org","subject":"Re: git: how to produce context diffs?","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-27T19:18:32Z","receivedAt":"2006-11-27T19:18:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"There are a few things to note:\n\n * Obviously diff.c::builtin_diff() needs to be taught to\n   generate the new format, both in the patch text and also in\n   the patch and hunk header part.\n\n * Corresponding changes to builtin-apply.c need to be made;\n   most of the functions in the callchain that starts at\n   apply_patch() down to apply_one_fragment() need to be taught\n   about the copied context format.  Also code to count diffstat\n   in builtin-apply.c needs to be adjusted.  This part should be\n   done first before diff.c if we were to support copied context\n   diff, because we should not be generating what we cannot\n   apply.\n\n * I do not think of a sane way to show a combined diff from\n   multiple preimages in copied context format; combine-diff.c\n   can probably be left as it is.\n\nI too find larger hunks easier to read with copied context than\nwith unified context, but what needs to be done listed above is\na nontrivial amount of work.  Since the beginning, git has only\nsupported unified context format and not copied context format,\nand apparently people who lived with git for the last 18 months\nhave survived without copied context format, so it is of very\nlow priority even for me right now.\n\nI am not opposed to adding the copied context format as long as\nsomebody else does the work ;-).\n"}]}