{"thread":{"id":"55362","subject":"Blob hash of binary files in patches generated by git format patch show in full form instead of short form","startedAt":"2021-03-21T13:06:48Z","lastAt":"2021-03-22T10:07:30Z","messageCount":4,"participants":["Bagas Sanjaya","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"419853","messageId":"499c9922-eb42-c2a8-b4b4-8e5197ea0fc6@gmail.com","threadId":"55362","inReplyTo":null,"subject":"Blob hash of binary files in patches generated by git format patch show in full form instead of short form","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-03-21T13:05:39Z","receivedAt":"2021-03-21T13:06:48Z","isPatch":false,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\nI'm trying to do format-patch with binary files (images) in commits.\nIn each commit, it adds an image and its alt description text in separated\nfile.\n\nFull steps:\n\n   First, initialize empty repo and populate it with commits:\n   - cd /tmp\n   - mkdir bin-patch && cd bin-patch\n   - git init\n   - echo \"test format-patch binary files\" > README\n   - git add * && git commit -m \"init README\"\n   - git checkout -b test\n   - wget -c [1] -O stackoverflow.png && echo \"Stack Overflow\" > stackoverflow.alt\n   - git add * && git commit -m \"Add Stack Overflow logo\"\n   - wget -c [2] -O idntm.jpg && echo \"Indonesia's Next Top Model cast\" > idntm.alt\n   - git add * && git commit -m \"Add IdNTM cast poster\"\n\n   Now prepare patches as usual (with cover letter ignored for this purpose):\n   - git format-patch --cover-letter -M master\n\n   (image link):\n   [1]: https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Stack_Overflow_logo.svg/1280px-Stack_Overflow_logo.svg.png\n   [2]: https://upload.wikimedia.org/wikipedia/en/9/9f/IndonesiaNTM1Cast.jpg\n\nWhat did you expect to happen? (Expected behavior)\n\nBlob hash in the `index` header of generated patches for binary file (image)\nuse short form (7 characters), just like for text file (alt description).\n\nWhat happened instead? (Actual behavior)\nBlob hash in the `index` stanza of generated patches for image use full\n(long) form.\n\nFor first patch (Stack Overflow commit), diff header for the image read:\n```\ndiff --git a/stackoverflow.png b/stackoverflow.png\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..969908ad3161a66af31f2441cfea4ae002a5ec67\n```\n\nwhile diff header for alt description read:\n```\ndiff --git a/stackoverflow.alt b/stackoverflow.alt\nnew file mode 100644\nindex 0000000..9368417\n```\n\nSimilarly, for the second patch (INTM poster), diff header for the image read:\n```\ndiff --git a/idntm.jpg b/idntm.jpg\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..8921ab9540e0a36a53f8c6632482fb04d5d0cc6c\n```\n\nwhile diff header for alt description read:\n```\ndiff --git a/idntm.alt b/idntm.alt\nnew file mode 100644\nindex 0000000..719feb9\n```\n\nWhat's different between what you expected and what actually happened?\n\nBlob hash for binary files are shown in full form, as opposed to blob hash\nfor text files.\n\nAnything else you want to add:\n(none)\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.31.0.29.g98164e9585\ncpu: x86_64\nbuilt from commit: 98164e9585e02e31dcf1377a553efe076c15f8c6\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.11.6-kernelorg-upstream-generic #1 SMP Fri Mar 12 06:35:27 WIB 2021 x86_64\ncompiler info: gnuc: 9.3\nlibc info: glibc: 2.31\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n(none)\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"419876","messageId":"xmqqblbcbehd.fsf@gitster.g","threadId":"55362","inReplyTo":"499c9922-eb42-c2a8-b4b4-8e5197ea0fc6@gmail.com","subject":"Re: Blob hash of binary files in patches generated by git format patch show in full form instead of short form","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-03-21T17:31:26Z","receivedAt":"2021-03-21T17:32:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bagas Sanjaya <bagasdotme@gmail.com> writes:\n\n> What's different between what you expected and what actually happened?\n>\n> Blob hash for binary files are shown in full form, as opposed to blob hash\n> for text files.\n\nThis is working as intended, designed and implemented.  \n\nThe textual patch is meant to be applicable on target text that may\neven have been slightly modified from the original from which the\npatch was taken, and the abbreviated object name on the \"index\" line\nis there mostly for human's sanity check and as a visual aid.\nOrdinarily it is not used to actually find the matching blob object\n(and it is not an error if there is no matching blob object in the\nrepository that a patch application is attempted in).\n\nBut the binary patch is designed to be applicable only to an exact\ncopy of the original and nowhere else.  The object name is given in\nfull, instead of using abbreviated form, to ensure that we do not\ntry to apply a binary patch to an object whose name is \"similar\".\n\nThanks.\n"},{"id":"419906","messageId":"56cde808-95c3-2e22-2dab-880061d51473@gmail.com","threadId":"55362","inReplyTo":"xmqqblbcbehd.fsf@gitster.g","subject":"Re: Blob hash of binary files in patches generated by git format patch show in full form instead of short form","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-03-22T05:47:21Z","receivedAt":"2021-03-22T05:48:30Z","isPatch":false,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"On 22/03/21 00.31, Junio C Hamano wrote:\n> Bagas Sanjaya <bagasdotme@gmail.com> writes:\n> \n>> What's different between what you expected and what actually happened?\n>>\n>> Blob hash for binary files are shown in full form, as opposed to blob hash\n>> for text files.\n> \n> This is working as intended, designed and implemented.\n> \n> The textual patch is meant to be applicable on target text that may\n> even have been slightly modified from the original from which the\n> patch was taken, and the abbreviated object name on the \"index\" line\n> is there mostly for human's sanity check and as a visual aid.\n> Ordinarily it is not used to actually find the matching blob object\n> (and it is not an error if there is no matching blob object in the\n> repository that a patch application is attempted in).\n> \n> But the binary patch is designed to be applicable only to an exact\n> copy of the original and nowhere else.  The object name is given in\n> full, instead of using abbreviated form, to ensure that we do not\n> try to apply a binary patch to an object whose name is \"similar\".\n> \n> Thanks.\n> \n\nHmm... but I don't see that in the documentation for git format-patch.\nMaybe I need to send doc update.\n\n-- \nAn old man doll... just what I always wanted! - Clara\n"},{"id":"419917","messageId":"a29052c9-b309-080a-537e-af6114116930@gmail.com","threadId":"55362","inReplyTo":"56cde808-95c3-2e22-2dab-880061d51473@gmail.com","subject":"Re: Blob hash of binary files in patches generated by git format patch show in full form instead of short form","fromName":"Bagas Sanjaya","fromEmail":"bagasdotme@gmail.com","sentAt":"2021-03-22T10:06:35Z","receivedAt":"2021-03-22T10:07:30Z","isPatch":false,"sender":{"key":"bagasdotme@gmail.com","avatar":"https://avatars.githubusercontent.com/u/40219486?v=4"},"body":"Oh oh oh, I see git diff format for generating patches in documentation for\ngit diff-files.\n\nOn 22/03/21 12.47, Bagas Sanjaya wrote:\n> On 22/03/21 00.31, Junio C Hamano wrote:\n>> Bagas Sanjaya <bagasdotme@gmail.com> writes:\n>>\n>>> What's different between what you expected and what actually happened?\n>>>\n>>> Blob hash for binary files are shown in full form, as opposed to blob hash\n>>> for text files.\n>>\n>> This is working as intended, designed and implemented.\n>>\n>> The textual patch is meant to be applicable on target text that may\n>> even have been slightly modified from the original from which the\n>> patch was taken, and the abbreviated object name on the \"index\" line\n>> is there mostly for human's sanity check and as a visual aid.\n>> Ordinarily it is not used to actually find the matching blob object\n>> (and it is not an error if there is no matching blob object in the\n>> repository that a patch application is attempted in).\n>>\n>> But the binary patch is designed to be applicable only to an exact\n>> copy of the original and nowhere else.  The object name is given in\n>> full, instead of using abbreviated form, to ensure that we do not\n>> try to apply a binary patch to an object whose name is \"similar\".\n>>\n>> Thanks.\n>>\n> \n> Hmm... but I don't see that in the documentation for git format-patch.\n> Maybe I need to send doc update.\n> \n\n-- \nAn old man doll... just what I always wanted! - Clara\n"}]}