Skip to content
代码片段 群组 项目
提交 f6d9f2ea 编辑于 作者: Vasilii Iakliushin's avatar Vasilii Iakliushin 提交者: Marc Shaw
浏览文件

Fix push rules validation on initial push

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/356094

**Problem**

Push rules validations for files don't work on the first push to the
empty repository.

The root cause is a `git diff-tree` behavior for an initial commit. It
returns an empty result if we provide a sha of the initial commit, but
it works correctly for all following commits.

**Solution**

Use tree ids to get the diff of the initial commit. Git has a special
empty tree id `4b825dc642cb6eb9a060e54bf8d69288fbee4904` that
corresponds to the empty repository state.

Instead of `git diff-tree <commit_id>` we can request a diff between two
trees: `git diff-tree <empty_tree_id> <commit_tree_id>`.

This approach returns a correct diff for the initial commit.
上级 4d3e57d2
No related branches found
No related tags found
无相关合并请求
加载中
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册