在 gitlab 中查看子模块的提交差异 [英] see diff of commit on submodule in gitlab

查看:94
本文介绍了在 gitlab 中查看子模块的提交差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 gitlab 7.3 版,当我使用普通存储库时它工作得很好.但是,我在我的 gitlab 项目中添加了一个 github 子模块.在我的仓库中,我在提交和推送( git push --recurse-submodules=check )之后做了,它运行良好.

但是现在,我可以在 gitlab 上看到我的提交,但是当我使用 chrome 在我的 gitlab 上浏览它时,没有显示差异.同时,子模块外文件的所有提交都得到了很好的显示.这是一个已知问题吗?

我还有其他事情要做吗?

解决方案

这是一个关于 Git 本身的已知问题.

今天已通过 Git 2.11 及其新的 git diff --submodule=diff 解决:

(图片来自"Git 的新特性2.11"来自 Tim Pettersen)

这在 GitLab GUI 中不可用,因为它刚刚在 Git 中发布.


注意:只有 Git 2.13(2017 年第二季度)修复了该功能中的错误:

参见 commit 17b254c(2017 年 3 月 31 日),作者为 Stefan Beller (stefanbeller).
(由 Junio C Hamano 合并 -- gitster -- in 提交 1776a71,2017 年 4 月 17 日)

<块引用>

在一个子模块中运行 git diff --submodule=diff 得到错误:

致命:坏对象.

出现这种情况,是因为我们没有正确初始化环境diff 在子模块中运行.
这意味着我们从设置环境变量的主进程继承环境.(显然我们确实设置了不在子模块中时未设置的环境变量,即 .git 目录已链接)


注意:Git 2.14 仍然改进了该命令git diff --submodule=diff",该命令现在递归到嵌套的子模块中.

参见 commit 5a52214(2017 年 5 月 4 日)://github.com/stefanbeller" rel="nofollow noreferrer">Stefan Beller (stefanbeller).
(由 Junio C Hamano 合并 -- gitster -- in 提交 a531ecf,2017 年 5 月 29 日)

<块引用>

diff:递归到嵌套子模块中进行内联diff

<块引用>

fd47ae6 (diff: 教diff 使用内联 diff 显示子模块差异,2016-08-31,Git 2.11) 被引入,我们没有考虑递归到嵌套子模块.

当显示子模块的内联差异时,自动递归嵌套子模块以及内联子模块差异.


在 Git 2.34(2021 年第四季度)之前,"<代码>git diff --submodule=diff"(man) 在尝试在子模块中运行 diff 时显示 run_command() 失败,此时用户手动删除了子模块目录.

这个问题已经解决了.

参见 commit 67f61ef, commit f1c0368(2021 年 8 月 31 日)和 大卫·特纳 (csusbdt).
(由 Junio C Hamano 合并 -- gitster -- in 提交 75405e7,2021 年 9 月 20 日)

<块引用>

diff --submodule=diff:不要'不打印失败信息两次

签字人:大卫·特纳

<块引用>

当我们无法在子模块内启动 diff 命令时,立即退出例程,而不是尝试完成命令并打印第二条消息.

I have a gitlab version 7.3 that is working totally fine when I work with normal repositories. However, I added a github submodule inside my gitlab project. On my repo, I did after commit and push ( git push --recurse-submodules=check ) and it worked perfectly.

But now, I can see my commit on gitlab, but the diff isnt displayed when I browse it on my gitlab with chrome. All the commits on files outside the submodules are well displayed meanwhile. Is that a known issue?

Do I have something to do another way?

解决方案

It is a known issue... about Git itself.

It was resolved today with Git 2.11 and its new git diff --submodule=diff:

(picture from "What is new in Git 2.11" from Tim Pettersen)

This is not available through GitLab GUI, since it just got released in Git.


Note: only Git 2.13 (Q2 2017) fixes a bug in that feature:

See commit 17b254c (31 Mar 2017) by Stefan Beller (stefanbeller).
(Merged by Junio C Hamano -- gitster -- in commit 1776a71, 17 Apr 2017)

Running git diff --submodule=diff in a submodule which has it's own submodules that have changes get the error:

fatal: bad object.

This happens, because we do not properly initialize the environment in which the diff is run in the submodule.
That means we inherit the environment from the main process, which sets environment variables. (Apparently we do set environment variables which we do not set when not in a submodules, i.e. the .git directory is linked)


Note: Git 2.14 still improve that command "git diff --submodule=diff", which now recurses into nested submodules.

See commit 5a52214 (04 May 2017) by Stefan Beller (stefanbeller).
(Merged by Junio C Hamano -- gitster -- in commit a531ecf, 29 May 2017)

diff: recurse into nested submodules for inline diff

When fd47ae6 (diff: teach diff to display submodule difference with an inline diff, 2016-08-31, Git 2.11) was introduced, we did not think of recursing into nested submodules.

When showing the inline diff for submodules, automatically recurse into nested submodules as well with inline submodule diffs.


Before Git 2.34 (Q4 2021), "git diff --submodule=diff"(man) showed failure from run_command() when trying to run diff inside a submodule, when the user manually removes the submodule directory.

That has been fixed.

See commit 67f61ef, commit f1c0368 (31 Aug 2021), and commit 4577d26 (26 Jul 2021) by David Turner (csusbdt).
(Merged by Junio C Hamano -- gitster -- in commit 75405e7, 20 Sep 2021)

diff --submodule=diff: don't print failure message twice

Signed-off-by: David Turner

When we fail to start a diff command inside a submodule, immediately exit the routine rather than trying to finish the command and printing a second message.

这篇关于在 gitlab 中查看子模块的提交差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆