{"thread":{"id":"35870","subject":"diff weirdness (bug?)","startedAt":"2014-02-14T19:20:04Z","lastAt":"2014-02-18T19:12:25Z","messageCount":5,"participants":["Dario Bertini","Junio C Hamano","Thomas Rast"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"234789","messageId":"52FE6C64.4060700@gmail.com","threadId":"35870","inReplyTo":null,"subject":"diff weirdness (bug?)","fromName":"Dario Bertini","fromEmail":"berdario@gmail.com","sentAt":"2014-02-14T19:20:04Z","receivedAt":"2014-02-14T19:20:04Z","isPatch":false,"sender":{"key":"berdario@gmail.com","avatar":"https://gravatar.com/avatar/8a656e2249beafba0dc194c046514d0d5d2b89559045de75b829d5369fd6c28e?d=mp&s=160"},"body":"git clone git@github.com:ansible/ansible.git\ngit revert 3616dffb68badb2b8d56\n\nmanually solve the conflict (you can look at the commit here:\nhttps://github.com/ansible/ansible/commit/3616dffb68badb2b8d56ef34391d7aae8de79cd6\n)\n\ngit diff will output:\n\ndario@macbook ~/P/ansible (devel*+|REVERTING)> git diff\ndiff --cc lib/ansible/constants.py\nindex c055ccf,6eac602..0000000\n--- a/lib/ansible/constants.py\n+++ b/lib/ansible/constants.py\n@@@ -84,16 -61,8 +84,12 @@@ active_user   = pwd.getpwuid(os.geteuid\n\n  # Needed so the RPM can call setup.py and have modules land in the\n  # correct location. See #1277 for discussion\n- if getattr(sys, \"real_prefix\", None):\n-     # in a virtualenv\n-     DIST_MODULE_PATH = os.path.join(sys.prefix, 'share/ansible/')\n- else:\n-     DIST_MODULE_PATH = '/usr/share/ansible/'\n+ DIST_MODULE_PATH = os.path.join(sys.prefix, 'share/ansible/')\n\n +# check all of these extensions when looking for yaml files for things\nlike\n +# group variables\n +YAML_FILENAME_EXTENSIONS = [ \"\", \".yml\", \".yaml\" ]\n +\n  # sections in config file\n  DEFAULTS='defaults'\n\n\n\nnow, it weirdly/incorrectly says that we added the YAML-related lines\n\nif we remove these 3 lines, we'll get this diff:\n\ndario@macbook ~/P/ansible (devel*+|REVERTING)> git diff --patience\ndiff --cc lib/ansible/constants.py\nindex c055ccf,6eac602..0000000\n--- a/lib/ansible/constants.py\n+++ b/lib/ansible/constants.py\n@@@ -84,16 -61,8 +84,9 @@@ active_user   = pwd.getpwuid(os.geteuid\n\n  # Needed so the RPM can call setup.py and have modules land in the\n  # correct location. See #1277 for discussion\n- if getattr(sys, \"real_prefix\", None):\n-     # in a virtualenv\n-     DIST_MODULE_PATH = os.path.join(sys.prefix, 'share/ansible/')\n- else:\n-     DIST_MODULE_PATH = '/usr/share/ansible/'\n+ DIST_MODULE_PATH = os.path.join(sys.prefix, 'share/ansible/')\n\n- # check all of these extensions when looking for yaml files for things\nlike\n- # group variables\n- YAML_FILENAME_EXTENSIONS = [ \"\", \".yml\", \".yaml\" ]\n +\n  # sections in config file\n  DEFAULTS='defaults'\n\n\neven more weirdly, it'll say that we deleted the yaml-related lines\n\nif we also remove one of the extra blank lines next to the yaml lines we\nget an empty diff:\n\ndario@macbook ~/P/ansible (devel*+|REVERTING)> git diff\ndiff --cc lib/ansible/constants.py\nindex c055ccf,6eac602..0000000\n--- a/lib/ansible/constants.py\n+++ b/lib/ansible/constants.py\n\n\nrunning `git add .` and then checking with git diff --cached will show\nthat everything is normal\n\nthe output is the same also with\ngit diff --minimal\nor\ngit diff --patience\n\n\n-- \nxmpp: berdario@gmail.com\nbitmessage: BM-2cTYXfGiSTsnx3righ6aHcJSWe4MV17jDP\ngpg fingerprint: 3F8D53518012716C4EEF7DF67B498306B3BF75A0 (used just\nfor signing commits)\n"},{"id":"234805","messageId":"xmqq8utdihqx.fsf@gitster.dls.corp.google.com","threadId":"35870","inReplyTo":"52FE6C64.4060700@gmail.com","subject":"Re: diff weirdness (bug?)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-14T20:03:50Z","receivedAt":"2014-02-14T20:03:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dario Bertini <berdario@gmail.com> writes:\n\n> git clone git@github.com:ansible/ansible.git\n> git revert 3616dffb68badb2b8d56\n>\n> manually solve the conflict (you can look at the commit here:\n> https://github.com/ansible/ansible/commit/3616dffb68badb2b8d56ef34391d7aae8de79cd6\n> )\n>\n> git diff will output:\n>\n> dario@macbook ~/P/ansible (devel*+|REVERTING)> git diff\n> diff --cc lib/ansible/constants.py\n> index c055ccf,6eac602..0000000\n> --- a/lib/ansible/constants.py\n> +++ b/lib/ansible/constants.py\n> @@@ -84,16 -61,8 +84,12 @@@ active_user   = pwd.getpwuid(os.geteuid\n>\n>   # Needed so the RPM can call setup.py and have modules land in the\n>   # correct location. See #1277 for discussion\n> - if getattr(sys, \"real_prefix\", None):\n> -     # in a virtualenv\n> -     DIST_MODULE_PATH = os.path.join(sys.prefix, 'share/ansible/')\n> - else:\n> -     DIST_MODULE_PATH = '/usr/share/ansible/'\n> + DIST_MODULE_PATH = os.path.join(sys.prefix, 'share/ansible/')\n>\n>  +# check all of these extensions when looking for yaml files for things\n> like\n>  +# group variables\n>  +YAML_FILENAME_EXTENSIONS = [ \"\", \".yml\", \".yaml\" ]\n>  +\n>   # sections in config file\n>   DEFAULTS='defaults'\n>\n>\n>\n> now, it weirdly/incorrectly says that we added the YAML-related lines\n\nThis is a combined diff, and yaml-related lines are added relative\nto your _other_ branch you are merging (notice these + are indented\nby one place).  Relative to what you had at the tip of your branch\nbefore you started this operation that ended up conflicted, the\nhalf-merged result removes if/else that sets DIST_MODULE_PATH and\nreplaces it with a single line (their +/- are on the first column,\nsignifying that these are differences relative to the first parent,\ni.e. your state before you started the operation).\n\n> if we remove these 3 lines, we'll get this diff:\n\nWith that understanding, I think the output after removing these\nthree lines is perfectlyh understandable and correct.  You are\nlooking at the three lines that used to exist in the version you\nstarted from, that were missing from the other side.  If you remoe\nthem, it will show as removal from _your_ version (notice these -\nthat shows what _you_ did manually are on the first column, saying\nthat that is relative to _your_ version).\n"},{"id":"234909","messageId":"53014A43.6080505@gmail.com","threadId":"35870","inReplyTo":"xmqq8utdihqx.fsf@gitster.dls.corp.google.com","subject":"Re: diff weirdness (bug?)","fromName":"Dario Bertini","fromEmail":"berdario@gmail.com","sentAt":"2014-02-16T23:31:15Z","receivedAt":"2014-02-16T23:31:15Z","isPatch":false,"sender":{"key":"berdario@gmail.com","avatar":"https://gravatar.com/avatar/8a656e2249beafba0dc194c046514d0d5d2b89559045de75b829d5369fd6c28e?d=mp&s=160"},"body":"On 02/14/2014 09:03 PM, Junio C Hamano wrote:\n> This is a combined diff, and yaml-related lines are added relative\n> to your _other_ branch you are merging (notice these + are indented\n> by one place).  Relative to what you had at the tip of your branch\n> before you started this operation that ended up conflicted, the\n> half-merged result removes if/else that sets DIST_MODULE_PATH and\n> replaces it with a single line (their +/- are on the first column,\n> signifying that these are differences relative to the first parent,\n> i.e. your state before you started the operation).\n> \n>> if we remove these 3 lines, we'll get this diff:\n> \n> With that understanding, I think the output after removing these\n> three lines is perfectlyh understandable and correct.  You are\n> looking at the three lines that used to exist in the version you\n> started from, that were missing from the other side.  If you remoe\n> them, it will show as removal from _your_ version (notice these -\n> that shows what _you_ did manually are on the first column, saying\n> that that is relative to _your_ version).\n> \n\nThank you, I was completely unaware of combined diffs. Still: I can't\nsee how this would explain the empty diff when deleting 4 lines instead\nof 3.\n\nAlso: in the diff output I get 2 hashes, but these are not the hashes of\nthe commits, but the contents of the files apparently. One should be\nHEAD (but if I run sha1sum over the file the hash doesn't match), but\nthe other can't be the commit which I reverted: the diff is too small...\nor at least this is what I understand\n\nBy the way, in the man of git diff there's the briefly mentioned '-m'\nflag. If anyone else reading this mail in the archives is confused by\nthe combined diff output, just use \"git diff -m HEAD\"... I'll probably\nadd this in my git aliases\n\n\n-- \nxmpp: berdario@gmail.com\nbitmessage: BM-2cTYXfGiSTsnx3righ6aHcJSWe4MV17jDP\ngpg fingerprint: 3F8D53518012716C4EEF7DF67B498306B3BF75A0 (used just\nfor signing commits)\n"},{"id":"234915","messageId":"87r472ujl1.fsf@thomasrast.ch","threadId":"35870","inReplyTo":"53014A43.6080505@gmail.com","subject":"Re: diff weirdness (bug?)","fromName":"Thomas Rast","fromEmail":"tr@thomasrast.ch","sentAt":"2014-02-17T10:20:10Z","receivedAt":"2014-02-17T10:20:10Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Dario Bertini <berdario@gmail.com> writes:\n\n> On 02/14/2014 09:03 PM, Junio C Hamano wrote:\n>> This is a combined diff, and yaml-related lines are added relative\n>> to your _other_ branch you are merging (notice these + are indented\n>> by one place).  Relative to what you had at the tip of your branch\n>> before you started this operation that ended up conflicted, the\n>> half-merged result removes if/else that sets DIST_MODULE_PATH and\n>> replaces it with a single line (their +/- are on the first column,\n>> signifying that these are differences relative to the first parent,\n>> i.e. your state before you started the operation).\n>> \n>>> if we remove these 3 lines, we'll get this diff:\n>> \n>> With that understanding, I think the output after removing these\n>> three lines is perfectlyh understandable and correct.  You are\n>> looking at the three lines that used to exist in the version you\n>> started from, that were missing from the other side.  If you remoe\n>> them, it will show as removal from _your_ version (notice these -\n>> that shows what _you_ did manually are on the first column, saying\n>> that that is relative to _your_ version).\n>> \n>\n> Thank you, I was completely unaware of combined diffs. Still: I can't\n> see how this would explain the empty diff when deleting 4 lines instead\n> of 3.\n\nWith a --cc diff (which it is: it says 'diff --cc' in the file headers)\ngit doesn't show the combined diff for hunks that fully agree with one\nside.\n\nSo if you (even manually) resolve the merge so that it fully matches one\nside, that will not show up in a --cc diff.\n\n-- \nThomas Rast\ntr@thomasrast.ch\n"},{"id":"235002","messageId":"xmqqbny4fd5y.fsf@gitster.dls.corp.google.com","threadId":"35870","inReplyTo":"53014A43.6080505@gmail.com","subject":"Re: diff weirdness (bug?)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-18T19:12:25Z","receivedAt":"2014-02-18T19:12:25Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dario Bertini <berdario@gmail.com> writes:\n\n> On 02/14/2014 09:03 PM, Junio C Hamano wrote:\n>> This is a combined diff, and yaml-related lines are added relative\n>> to your _other_ branch you are merging (notice these + are indented\n>> by one place).  Relative to what you had at the tip of your branch\n>> before you started this operation that ended up conflicted, the\n>> half-merged result removes if/else that sets DIST_MODULE_PATH and\n>> replaces it with a single line (their +/- are on the first column,\n>> signifying that these are differences relative to the first parent,\n>> i.e. your state before you started the operation).\n>> \n>>> if we remove these 3 lines, we'll get this diff:\n>> \n>> With that understanding, I think the output after removing these\n>> three lines is perfectlyh understandable and correct.  You are\n>> looking at the three lines that used to exist in the version you\n>> started from, that were missing from the other side.  If you remoe\n>> them, it will show as removal from _your_ version (notice these -\n>> that shows what _you_ did manually are on the first column, saying\n>> that that is relative to _your_ version).\n>> \n>\n> Thank you, I was completely unaware of combined diffs. Still: I can't\n> see how this would explain the empty diff when deleting 4 lines instead\n> of 3.\n>\n> Also: in the diff output I get 2 hashes, but these are not the hashes of\n> the commits, but the contents of the files apparently. One should be\n> HEAD (but if I run sha1sum over the file the hash doesn't match), but\n\nA blob object name (or for that matter, names of any type of object)\nis not the same as the hash over its contents alone.\n\nSee \"combined diff format\" section of \"git diff --help\" if you are\ninterested in reading what the output format is telling you.\n\n> the other can't be the commit which I reverted: the diff is too small...\n> or at least this is what I understand\n>\n> By the way, in the man of git diff there's the briefly mentioned '-m'\n> flag. If anyone else reading this mail in the archives is confused by\n> the combined diff output, just use \"git diff -m HEAD\"... I'll probably\n> add this in my git aliases\n\nIf you are primarily interested in what a merge (or other\nmergy-operation like revert) did to your working tree state,\nrelative to the state it operated on, \"git diff HEAD\" is most likely\nwhat you want.\n"}]}