英文:
git diff must compare only from a certain offset or char. column in a line
问题
以下是翻译后的内容:
如何在git diff中仅从某一行中的特定偏移列进行比较,例如下面的两个日志应该没有区别:
index 7e2d6d7..cb88ce6
--- a/var/log/lightdm/lightdm.log
+++ b/mnt/OSraw/var/log/lightdm/lightdm.log
@@ -1,46 +1,175 @@
-[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
-[+0.00s] DEBUG: Starting Light Display Manager 1.32.0, UID=0
-[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
-[+0.00s] DEBUG: Registered seat module local
+[+0.01s] DEBUG: Logging to /var/log/lightdm/lightdm.log
+[+0.01s] DEBUG: Starting Light Display Manager 1.32.0, UID=0
+[+0.01s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
+[+0.01s] DEBUG: Registered seat module local
请帮忙!
英文:
How git diff compare only from a certain offset column in a line, eg the two log below should be not different
index 7e2d6d7..cb88ce6
--- a/var/log/lightdm/lightdm.log
+++ b/mnt/OSraw/var/log/lightdm/lightdm.log
@@ -1,46 +1,175 @@
-[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
-[+0.00s] DEBUG: Starting Light Display Manager 1.32.0, UID=0
-[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
-[+0.00s] DEBUG: Registered seat module local
+[+0.01s] DEBUG: Logging to /var/log/lightdm/lightdm.log
+[+0.01s] DEBUG: Starting Light Display Manager 1.32.0, UID=0
+[+0.01s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
+[+0.01s] DEBUG: Registered seat module local
Please help out!
答案1
得分: 2
你正在寻找textconv
的差异。虽然文档中说它用于查找二进制文件的差异,但这里所谓的“二进制”实际上指的是在其原始形式下难以处理的任何内容。
echo lightdm.log diff=myfilter >> .git/info/attributes
上述的sed
命令会在差异查看它们之前从行中去除前面的括号括起的单词,只是在初始列上涂白了一定数量的列,你可以像这样做:s,..........,----------,
。
英文:
You're looking for textconv
diffs. While the docs say it's for diffing binaries, what "binary" means here is really just anything that's difficult to work with in its original form.
git config diff.myfilter.textconv "sed 's,^\\[[^]]*] , ,'"
echo lightdm.log diff=myfilter >> .git/info/attributes
that sed
strips leading bracketed words off the lines before the diff sees them, to just white out a fixed number of initial columns you'd do something like s,..........,----------,
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论