git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Diogo Fernandes <diogoabfernandes@gmail.com>
To: "Martin Ågren" <martin.agren@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Bug Report: Superfluous Tab Characters
Date: Sun, 5 Feb 2023 18:01:05 +0100	[thread overview]
Message-ID: <CADPR2CWzjiPJn9ZtkcU0ZTbacq5JQu2vXriuLq+VreqqUo_-dA@mail.gmail.com> (raw)
In-Reply-To: <CAN0heSruSHQk8cPZ1-Zhp8dfL+j-OAsASrsBTVdWKQcx14Pxtw@mail.gmail.com>

Hi Martin,

I am not personally parsing the output of git. This was rather
observed while using a third-party tool that reads the output of git
as initially pointed out by
https://github.com/trufflesecurity/trufflehog/issues/1060.

I have the latest v2.39.1 from `brew` on macOS and the tab character
is added to the output.

Anyhow, thanks for checking.

Regards,
Diogo

On Sun, Feb 5, 2023 at 4:28 PM Martin Ågren <martin.agren@gmail.com> wrote:
>
> On Sat, 4 Feb 2023 at 13:54, Diogo Fernandes <diogoabfernandes@gmail.com> wrote:
> > On Fri, 3 Feb 2023 at 14:43 Martin Ågren <martin.agren@gmail.com> wrote:
> >>
> >> On Fri, 3 Feb 2023 at 13:50, Diogo Fernandes <diogoabfernandes@gmail.com> wrote:
> >> >
> >> > I have run into a bug where git seems to be adding superfluous tabs to
> >> > the end of filenames that contain a space. I have attached the output
> >> > of `git bugreport` for your review. Feel free to have a look
> >> > https://github.com/trufflesecurity/trufflehog/issues/1060 for
> >> > additional context.
> >>
> >> The code that adds this tab in the output of `git log` and friends has
> >> changed a bit since it was originally added in 1a9eb3b9d5
> >> ("git-diff/git-apply: make diff output a bit friendlier to GNU patch
> >> (part 2)", 2006-09-22), but in that commit you can see the original
> >> motivation.
>
> > So, this is by design and not a bug? And is it still current in the latest version of git?
>
> Yes, it appears to be by design:
>
>     Somebody was wondering on #git channel why a git generated diff
>     does not apply with GNU patch when the filename contains a SP.
>     It is because GNU patch expects to find TAB (and trailing timestamp)
>     on ---/+++ (old_name and new_name) lines after the filenames.
>
>     The "diff --git" output format was carefully designed to be
>     compatible with GNU patch where it can, but whitespace
>     characters were always a pain.
>
>     This adds an extra TAB (but not trailing timestamp) to old_name
>     and new_name lines of git-diff output when the filename has a SP
>     in it.  An earlier patch updated git-apply to prepare for this.
>
> From a quick test, this behavior does seem to be in newest git.
>
> I sense there is some sort of ulterior motive here that hasn't come
> across yet. Are you trying to parse the output of `git log` to find
> something? Would `git diff-tree` work, e.g., if you're mostly just after
> the filenames involved?  Depending on what you're trying to achieve, it
> could be a bit simpler to parse `git diff-tree` and other "plumbing"
> commands, rather than `git log` and other such "porcelain" commands.
>
> (Also, note that one person's `git log` output can be different from
> yours, e.g., because of various config knobs being set different ways.)
>
> Martin

      reply	other threads:[~2023-02-05 17:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03 12:29 Bug Report: Superfluous Tab Characters Diogo Fernandes
2023-02-03 13:43 ` Martin Ågren
     [not found]   ` <CADPR2CXR_KRKFjPA-0ZuHGHHq_-epHXtJWCuwYx6uvLF_H49mg@mail.gmail.com>
2023-02-05 15:28     ` Martin Ågren
2023-02-05 17:01       ` Diogo Fernandes [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADPR2CWzjiPJn9ZtkcU0ZTbacq5JQu2vXriuLq+VreqqUo_-dA@mail.gmail.com \
    --to=diogoabfernandes@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=martin.agren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).