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 via email to