use*_*152 5 git blame git-blame
根据我的理解,该命令git blame应该显示文件中的每一行的作者和最后修改该行的提交。例如,如果我运行git blame -- "<filename>"并获得第 5 行的以下输出:
106b77db (Walrus 2016-03-24 10:01:36 +0800 5) .root {
Run Code Online (Sandbox Code Playgroud)
这意味着该行.root {源自Walrus提交中的作者106b77db。换句话说,如果我检查106b77db使用生成的补丁git show -p 106b77db,我希望该行+.root {显示在差异中。确实如此。
106b77db的 diff的片段<filename>:
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
+.root {
+ -fx-background-color: transparent;
+}
+
Run Code Online (Sandbox Code Playgroud)
现在,当我运行git blame -w -- "<filename>"(该-w选项忽略空白更改,即及时向后跟踪每一行以找到对该行引入非空白更改的最后一个作者)时,我现在得到第 5 行的以下输出:
b6a6e8a2 (Walrus 2016-03-31 23:32:50 +0800 5) .root {
Run Code Online (Sandbox Code Playgroud)
b6a6e8a2但是,当我检查使用的补丁时git show -p b6a6e8a2,差异显示.root {而不是+.root {预期的那样。
b6a6e8a2的 diff的片段<filename>:
+
+/* setting window to be transparent================================ */
.root {
-fx-background-color: transparent;
-}
-
Run Code Online (Sandbox Code Playgroud)
Git 是否给了我错误的输出,因为根据 diff,该行在.root {提交中根本没有被修改b6a6e8a2?
我使用的是 Git 2.13.3.windows.1。
编辑:存储库是https://github.com/cs2103jan2016-f14-2j/main,文件是JimplePlanner/src/application.css. 升级到Git 2.16.1.windows.4后,问题仍然存在。
五年后,我遇到了同样的问题,并试图理解发生了什么。
事实证明,当您忽略空格时,git 有时会将更改理解为完全不同的更改,因为在空格省略后,重复模式会更改检测到的“最小更改”的位置。
在“不正确”的版本上运行git diff -wvs (在您的情况下, )说明了问题:git diffb6a6e8a
git diff b6a6e8a~..b6a6e8a:
diff --git a/JimplePlanner/src/application.css b/JimplePlanner/src/application.css
index e4634ef..c0cc44b 100644
--- a/JimplePlanner/src/application.css
+++ b/JimplePlanner/src/application.css
@@ -1,248 +1,108 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
+
+/* setting window to be transparent================================ */
.root {
-fx-background-color: transparent;
-}
-
-.today-pane {
Run Code Online (Sandbox Code Playgroud)
git diff -w b6a6e8a~..b6a6e8a:
diff --git a/JimplePlanner/src/application.css b/JimplePlanner/src/application.css
index e4634ef..c0cc44b 100644
--- a/JimplePlanner/src/application.css
+++ b/JimplePlanner/src/application.css
@@ -1,248 +1,108 @@
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
-.root {
- -fx-background-color: transparent;
-}
-
-.today-pane {
- -fx-background-radius: 10px;
- -fx-background-color: white;
- -fx-border-color: grey;
- -fx-border-radius: 10px;
-}
-
-.list-view {
- -fx-padding: 3px ;
- -fx-background-color: transparent;
-}
-
- .list-cell {
- -fx-padding: 10px ;
- -fx-background-color: transparent, -fx-background ;
-}
-
-.list-cell:empty {
- -fx-padding: 10px;
+/* setting window to be transparent================================ */
+.root {
-fx-background-color: transparent;
- -fx-background-insets: 0 ;
-}
+}/*============================================++================== */
Run Code Online (Sandbox Code Playgroud)
当忽略空格时,diff 算法最终会.root {在一个位置将其删除,然后在另一个位置添加回来。
这只是忽略空白的结果 - 有时它会解释所做的更改与您的想法大不相同;比不忽略空白时更常见。