{"thread":{"id":"59188","subject":"Bug Report: Superfluous Tab Characters","startedAt":"2023-02-03T12:30:12Z","lastAt":"2023-02-05T17:01:47Z","messageCount":4,"participants":["Diogo Fernandes","Martin Ågren"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"471426","messageId":"CADPR2CUgrO6ius5ss9Mgk8Zktf+4zQDq0vP4EEKOMku7K=V6FA@mail.gmail.com","threadId":"59188","inReplyTo":null,"subject":"Bug Report: Superfluous Tab Characters","fromName":"Diogo Fernandes","fromEmail":"diogoabfernandes@gmail.com","sentAt":"2023-02-03T12:29:29Z","receivedAt":"2023-02-03T12:30:12Z","isPatch":false,"sender":{"key":"diogoabfernandes@gmail.com","avatar":null},"body":"Dear git team,\n\nI have run into a bug where git seems to be adding superfluous tabs to\nthe end of filenames that contain a space. I have attached the output\nof `git bugreport` for your review. Feel free to have a look\nhttps://github.com/trufflesecurity/trufflehog/issues/1060 for\nadditional context.\n\nThanks.\n\nRegards,\nDiogo Fernandes\n\n\nThank 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\n$ mkdir test\n$ cd test\n$ git init\n$ echo foo > \"filename 2\"\n$ git add \"filename 2\"\n$ git commit -m \"test\"\n$ git log -p | grep \"+++\" | xxd  # 0x09 is a \\t character that is being added to a filename with a space\n\n00000000: 2b2b 2b20 622f 6669 6c65 6e61 6d65 2032  +++ b/filename 2\n00000010: 090a                                     ..\n\nWhat did you expect to happen? (Expected behavior)\n\n$ echo \"foo\" > filename2\n4 git add .\n$ git commit -m \"test\"\n$ git log -p | grep \"+++\" | xxd\n\n00000000: 2b2b 2b20 622f 6669 6c65 6e61 6d65 320a  +++ b/filename2.\n\nWhat happened instead? (Actual behavior)\n\nA tab character is being appended to filenames.\n\nWhat's different between what you expected and what actually happened?\n\nA tab character should not be appended to filenames.\n\nAnything else you want to add: No.\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.39.1\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:43:09 PST 2022; root:xnu-8020.240.18~2/RELEASE_ARM64_T6000 arm64\ncompiler info: clang: 14.0.0 (clang-1400.0.29.202)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\n"},{"id":"471431","messageId":"CAN0heSqwVV_G_nrt=omK0UjXVAD+TYPC+oB-1xHF4dG4oovncA@mail.gmail.com","threadId":"59188","inReplyTo":"CADPR2CUgrO6ius5ss9Mgk8Zktf+4zQDq0vP4EEKOMku7K=V6FA@mail.gmail.com","subject":"Re: Bug Report: Superfluous Tab Characters","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2023-02-03T13:43:34Z","receivedAt":"2023-02-03T13:43:50Z","isPatch":false,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"Hi Diogo,\n\nOn Fri, 3 Feb 2023 at 13:50, Diogo Fernandes <diogoabfernandes@gmail.com> wrote:\n>\n> I have run into a bug where git seems to be adding superfluous tabs to\n> the end of filenames that contain a space. I have attached the output\n> of `git bugreport` for your review. Feel free to have a look\n> https://github.com/trufflesecurity/trufflehog/issues/1060 for\n> additional context.\n\nThe code that adds this tab in the output of `git log` and friends has\nchanged a bit since it was originally added in 1a9eb3b9d5\n(\"git-diff/git-apply: make diff output a bit friendlier to GNU patch\n(part 2)\", 2006-09-22), but in that commit you can see the original\nmotivation.\n\nHere's an online view:\nhttps://github.com/git/git/commit/1a9eb3b9d50367bee8fe85022684d812816fe531\n\nMartin\n"},{"id":"471527","messageId":"CAN0heSruSHQk8cPZ1-Zhp8dfL+j-OAsASrsBTVdWKQcx14Pxtw@mail.gmail.com","threadId":"59188","inReplyTo":"CADPR2CXR_KRKFjPA-0ZuHGHHq_-epHXtJWCuwYx6uvLF_H49mg@mail.gmail.com","subject":"Re: Bug Report: Superfluous Tab Characters","fromName":"Martin Ågren","fromEmail":"martin.agren@gmail.com","sentAt":"2023-02-05T15:28:07Z","receivedAt":"2023-02-05T15:28:24Z","isPatch":false,"sender":{"key":"martin.agren@gmail.com","avatar":null},"body":"On Sat, 4 Feb 2023 at 13:54, Diogo Fernandes <diogoabfernandes@gmail.com> wrote:\n> On Fri, 3 Feb 2023 at 14:43 Martin Ågren <martin.agren@gmail.com> wrote:\n>>\n>> On Fri, 3 Feb 2023 at 13:50, Diogo Fernandes <diogoabfernandes@gmail.com> wrote:\n>> >\n>> > I have run into a bug where git seems to be adding superfluous tabs to\n>> > the end of filenames that contain a space. I have attached the output\n>> > of `git bugreport` for your review. Feel free to have a look\n>> > https://github.com/trufflesecurity/trufflehog/issues/1060 for\n>> > additional context.\n>>\n>> The code that adds this tab in the output of `git log` and friends has\n>> changed a bit since it was originally added in 1a9eb3b9d5\n>> (\"git-diff/git-apply: make diff output a bit friendlier to GNU patch\n>> (part 2)\", 2006-09-22), but in that commit you can see the original\n>> motivation.\n\n> So, this is by design and not a bug? And is it still current in the latest version of git?\n\nYes, it appears to be by design:\n\n    Somebody was wondering on #git channel why a git generated diff\n    does not apply with GNU patch when the filename contains a SP.\n    It is because GNU patch expects to find TAB (and trailing timestamp)\n    on ---/+++ (old_name and new_name) lines after the filenames.\n\n    The \"diff --git\" output format was carefully designed to be\n    compatible with GNU patch where it can, but whitespace\n    characters were always a pain.\n\n    This adds an extra TAB (but not trailing timestamp) to old_name\n    and new_name lines of git-diff output when the filename has a SP\n    in it.  An earlier patch updated git-apply to prepare for this.\n\nFrom a quick test, this behavior does seem to be in newest git.\n\nI sense there is some sort of ulterior motive here that hasn't come\nacross yet. Are you trying to parse the output of `git log` to find\nsomething? Would `git diff-tree` work, e.g., if you're mostly just after\nthe filenames involved?  Depending on what you're trying to achieve, it\ncould be a bit simpler to parse `git diff-tree` and other \"plumbing\"\ncommands, rather than `git log` and other such \"porcelain\" commands.\n\n(Also, note that one person's `git log` output can be different from\nyours, e.g., because of various config knobs being set different ways.)\n\nMartin\n"},{"id":"471529","messageId":"CADPR2CWzjiPJn9ZtkcU0ZTbacq5JQu2vXriuLq+VreqqUo_-dA@mail.gmail.com","threadId":"59188","inReplyTo":"CAN0heSruSHQk8cPZ1-Zhp8dfL+j-OAsASrsBTVdWKQcx14Pxtw@mail.gmail.com","subject":"Re: Bug Report: Superfluous Tab Characters","fromName":"Diogo Fernandes","fromEmail":"diogoabfernandes@gmail.com","sentAt":"2023-02-05T17:01:05Z","receivedAt":"2023-02-05T17:01:47Z","isPatch":false,"sender":{"key":"diogoabfernandes@gmail.com","avatar":null},"body":"Hi Martin,\n\nI am not personally parsing the output of git. This was rather\nobserved while using a third-party tool that reads the output of git\nas initially pointed out by\nhttps://github.com/trufflesecurity/trufflehog/issues/1060.\n\nI have the latest v2.39.1 from `brew` on macOS and the tab character\nis added to the output.\n\nAnyhow, thanks for checking.\n\nRegards,\nDiogo\n\nOn Sun, Feb 5, 2023 at 4:28 PM Martin Ågren <martin.agren@gmail.com> wrote:\n>\n> On Sat, 4 Feb 2023 at 13:54, Diogo Fernandes <diogoabfernandes@gmail.com> wrote:\n> > On Fri, 3 Feb 2023 at 14:43 Martin Ågren <martin.agren@gmail.com> wrote:\n> >>\n> >> On Fri, 3 Feb 2023 at 13:50, Diogo Fernandes <diogoabfernandes@gmail.com> wrote:\n> >> >\n> >> > I have run into a bug where git seems to be adding superfluous tabs to\n> >> > the end of filenames that contain a space. I have attached the output\n> >> > of `git bugreport` for your review. Feel free to have a look\n> >> > https://github.com/trufflesecurity/trufflehog/issues/1060 for\n> >> > additional context.\n> >>\n> >> The code that adds this tab in the output of `git log` and friends has\n> >> changed a bit since it was originally added in 1a9eb3b9d5\n> >> (\"git-diff/git-apply: make diff output a bit friendlier to GNU patch\n> >> (part 2)\", 2006-09-22), but in that commit you can see the original\n> >> motivation.\n>\n> > So, this is by design and not a bug? And is it still current in the latest version of git?\n>\n> Yes, it appears to be by design:\n>\n>     Somebody was wondering on #git channel why a git generated diff\n>     does not apply with GNU patch when the filename contains a SP.\n>     It is because GNU patch expects to find TAB (and trailing timestamp)\n>     on ---/+++ (old_name and new_name) lines after the filenames.\n>\n>     The \"diff --git\" output format was carefully designed to be\n>     compatible with GNU patch where it can, but whitespace\n>     characters were always a pain.\n>\n>     This adds an extra TAB (but not trailing timestamp) to old_name\n>     and new_name lines of git-diff output when the filename has a SP\n>     in it.  An earlier patch updated git-apply to prepare for this.\n>\n> From a quick test, this behavior does seem to be in newest git.\n>\n> I sense there is some sort of ulterior motive here that hasn't come\n> across yet. Are you trying to parse the output of `git log` to find\n> something? Would `git diff-tree` work, e.g., if you're mostly just after\n> the filenames involved?  Depending on what you're trying to achieve, it\n> could be a bit simpler to parse `git diff-tree` and other \"plumbing\"\n> commands, rather than `git log` and other such \"porcelain\" commands.\n>\n> (Also, note that one person's `git log` output can be different from\n> yours, e.g., because of various config knobs being set different ways.)\n>\n> Martin\n"}]}