在 GitHub 上查看没有空格更改的提交

发布于 2024-10-07 09:39:13 字数 149 浏览 4 评论 0原文

有没有办法在 github.com 上显示提交而不显示空白更改?

有没有办法从控制台显示它?即克隆然后查看本地提交(树),忽略所有空白更改?

我广泛使用 Trac;我正在寻找类似于忽略空白更改的内容(可以在更改集视图上找到)。

Is there a way to display a commit on github.com without showing whitespace changes?

Is there a way to display that from console? i.e. clone and then look at commit (tree) locally ignoring all white space changes?

I use Trac extensively; I'm looking for something similar to Ignore White space changes (which can be found on the changeset view).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

寻找一个思念的角度 2024-10-14 09:39:13

?w=1 附加到任何显示差异的 github.com 页面上的 URL,它将忽略空格。请参阅这篇博文

Append ?w=1 to the URL on any github.com page that is showing a diff and it will ignore whitespace. See this blog post.

慕烟庭风 2024-10-14 09:39:13

为此,您可以在命令行(使用任何 git 的 diff 命令)使用三个选项:

  • --ignore-space-at-eol 忽略 EOL 时空格的更改。
  • -b, --ignore-space-change 忽略空白量的变化。这会忽略行尾的空白,并认为一个或多个空白字符的所有其他序列是等效的。
  • -w, --ignore-all-space 比较行时忽略空格。即使一行有空格而另一行没有空格,这也会忽略差异。

我不相信 github 已经使用这些选项实现了任何东西。

There is a trio of options that you can use at the command line (with any of git's diff commands) for this:

  • --ignore-space-at-eol Ignore changes in whitespace at EOL.
  • -b, --ignore-space-change Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.
  • -w, --ignore-all-space Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.

I don't believe github has implemented anything using these options.

待天淡蓝洁白时 2024-10-14 09:39:13

遗憾的是,X 的东西消失了,之前的代码片段也变得毫无用处。现在应该可以使用以下内容:

var i, e, tr, tdL, tdR, textL, textR, text = function (el) { return el.parentNode.children[2].children[1].children[0].textContent.replace(/\s/g, '').substr(1); }
for (i = 0, e = document.getElementsByClassName('gd'); i < e.length; ++i) {
    tr = e[i].parentNode.parentNode.parentNode;
    if (' ' !== tr.children[1].innerHTML) { continue; }
    tdL = tr.children[0];
    tdR = document.getElementById(tdL.id.replace(/^L(\d+)L/, 'L$1R')),
    textL = text(tdL);
    textR = text(tdR);
    if (textL === textR) { tdL.parentNode.style.display = tdR.parentNode.style.display = 'none'; }
}

Sadly the X thing is gone and alongside the previous snippet is rendered useless. Here is something that should work for now:

var i, e, tr, tdL, tdR, textL, textR, text = function (el) { return el.parentNode.children[2].children[1].children[0].textContent.replace(/\s/g, '').substr(1); }
for (i = 0, e = document.getElementsByClassName('gd'); i < e.length; ++i) {
    tr = e[i].parentNode.parentNode.parentNode;
    if (' ' !== tr.children[1].innerHTML) { continue; }
    tdL = tr.children[0];
    tdR = document.getElementById(tdL.id.replace(/^L(\d+)L/, 'L$1R')),
    textL = text(tdL);
    textR = text(tdR);
    if (textL === textR) { tdL.parentNode.style.display = tdR.parentNode.style.display = 'none'; }
}
最丧也最甜 2024-10-14 09:39:13

在查看提交页面的源 HTML 后,我发现 github 用“x”CSS 类标记纯空白更改...这使得以下 oneliner 成为可能:它

jQuery.expr[':'].hasX = function(obj) { var $this = $(obj); return ($this.find('.x').length && $this.next().find('.x').length); }; jQuery('.data tbody tr:hasX').toggle().next().toggle();

的作用是遍历提交表​​的所有行,并隐藏给定行及其后的行中确实包含“.x”元素的行。

这是完整的 JS:

// create new selector
jQuery.expr[':'].hasX = function(obj) {
    // cache
    var $this = $(obj);
    // whether this and next line do have '.x' element as child
    return $this.find('.x').length && $this.next().find('.x').length;
}

// select all rows and hide (ones containing "-")
jQuery('.data tbody tr:hasX').toggle()
// hide the ones after selected (ones containing "+")
    .next().toggle();

After looking into source HTML of commit page, I've found out that github marks pure whitespace changes with "x" CSS class... Which makes the following oneliner possible:

jQuery.expr[':'].hasX = function(obj) { var $this = $(obj); return ($this.find('.x').length && $this.next().find('.x').length); }; jQuery('.data tbody tr:hasX').toggle().next().toggle();

What it does, is runs through all rows of the commit table, and hides rows if given line and the one after that do have ".x" element in them.

Here's full JS:

// create new selector
jQuery.expr[':'].hasX = function(obj) {
    // cache
    var $this = $(obj);
    // whether this and next line do have '.x' element as child
    return $this.find('.x').length && $this.next().find('.x').length;
}

// select all rows and hide (ones containing "-")
jQuery('.data tbody tr:hasX').toggle()
// hide the ones after selected (ones containing "+")
    .next().toggle();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文