see diff of commit on submodule in gitlab

2019-02-20 12:58发布

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?

1条回答
成全新的幸福
2楼-- · 2019-02-20 13:16

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

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

enter image description here (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.

查看更多
登录 后发表回答