git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Khomoutov <kostix@bswap.ru>
To: hgfds jhgfds <lvl100p@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Is the -w option for git blame bugged?
Date: Fri, 16 Feb 2018 13:57:56 +0300	[thread overview]
Message-ID: <20180216105755.ouexuzktevnxrqwf@tigra> (raw)
In-Reply-To: <CAOrVMvvM4XUsE0v7oxotD8yPHkmstG-mQYuhF0OsC-bETGQ-Og@mail.gmail.com>

On Fri, Feb 16, 2018 at 05:47:41PM +0800, hgfds jhgfds wrote:

> I recently asked a question on stackoverflow regarding what seemed to
> be erroneous output from git blame when the -w option is specified.
> However, no one answered my question, so I decided to ask here
> instead.
> 
> The question is available at
> https://stackoverflow.com/questions/48808281/git-blame-ignore-whitespace-option-bugged
> 
> Hope someone can help to shed light on this issue soon.

This is indeed the correct place to ask such questions.
Still, the next time please literally ask the question - inclusing its
full text - rather than dropping a link: few people bother do to that,
and even fewer of them have an SO account to actually answer it.
So it's both just basic netiquette and increasing the circle of the
potentional helpers ;-)

In order to remove the churn, I've copied and pasted your question here;
hope you have no issues with me doing this.

--------------------------------8<--------------------------------
Based on my understanding, the command `git blame` is supposed to show, for
each line in a file, the author and the commit in which the line was last
modified.  So for example, if I run

git blame -- "<filename>"

and get the following output for line 5:

106b77db (Walrus 2016-03-24 10:01:36 +0800   5) .root {

it means the line

.root {

originated from the author Walrus in the commit 106b77db.
In other words, if I inspect the patch produced by 106b77db using
`git show -p 106b77db`, I would expect the line

+.root {

to show up in the diff. Indeed, this is the case.

Snippet from 106b77db's diff for <filename>:

 /* JavaFX CSS - Leave this comment until you have at least create one rule       which uses -fx-Property */
+.root {
+   -fx-background-color: transparent;
+}
+

Now, when I run

git blame -w -- "<filename>"

(the -w option ignores whitespace changes, i.e. traces each line backwards in
time to find the last author which introduced non-whitespace changes to that
line), I now get the following output for line 5:

b6a6e8a2 (Walrus 2016-03-31 23:32:50 +0800   5) .root {

However, when I inspect the patch for b6a6e8a2 using

git show -p b6a6e8a2

the diff shows

.root {

rather than

+.root {

as expected.

Snippet from b6a6e8a2's diff for <filename>:

+
+/* setting window to be transparent================================ */
 .root {
    -fx-background-color: transparent;
-}
-

Has Git given me erroneous output, because according to the diff, the line
.root { was not modified at all in the commit b6a6e8a2?

I am using Git 2.13.3.windows.1.

EDIT: the repository is https://github.com/cs2103jan2016-f14-2j/main,
and the file is JimplePlanner/src/application.css.
After upgrading to Git 2.16.1.windows.4, the issue still persists.
--------------------------------8<--------------------------------


      reply	other threads:[~2018-02-16 10:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-16  9:47 Is the -w option for git blame bugged? hgfds jhgfds
2018-02-16 10:57 ` Konstantin Khomoutov [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

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

  git send-email \
    --in-reply-to=20180216105755.ouexuzktevnxrqwf@tigra \
    --to=kostix@bswap.ru \
    --cc=git@vger.kernel.org \
    --cc=lvl100p@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.
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 NNTP newsgroup(s).