Skip to content
Snippets Groups Projects
Commit 3d5a6b91 authored by Douwe Maan's avatar Douwe Maan
Browse files

Merge branch 'fix-existing-submodule-dir' into 'master'

Ignore submodules that are defined in .gitmodules but are checked in as directories

Check that a blob entry is a not a tree (aka directory). It's possible to check in a submodule in .gitmodules but not the actual directory, leading to a 500 Error in GitLab.

See: https://gitlab.com/stanhu/gitlab-git-test/commits/add-submodule-to-existing-dir and click *Files* to see the error.

NOTE: Don't merge this gitlab-git-test change into master; put it in another branch called `fix-existing-submodule-dir`. I could not get the gitlab_git tests to pass with master because the git checkout to the feature branch caused libgit2 to complained about a conflict, even though `git checkout -b foo_branch origin/feature` works fine. Apparently git uses no code in libgit2, which might explain the discrepancy. I suspect libgit2 sees the mismatched submodule directory as a conflict.

Closes: gitlab-org/gitlab-ce#1439 (duplicate here: https://github.com/gitlabhq/gitlabhq/issues/9140)

See merge request !26
parents 4ce7663c c3c747a7
No related branches found
No related tags found
No related merge requests found
Pipeline #
v 7.1.10
- Ignore submodules that are defined in .gitmodules but are checked in as directories.
v 7.1.9
- Ignore invalid lines in .gitmodules.
 
Loading
Loading
Loading
Loading
@@ -766,9 +766,12 @@ module Gitlab
raise InvalidBlobName.new("Invalid blob name: #{blob_name}")
end
 
if blob_entry[:type] == :commit
case blob_entry[:type]
when :commit
blob_entry[:oid]
else
when :tree
raise InvalidBlobName.new("#{blob_name} is a tree, not a blob")
when :blob
rugged.lookup(blob_entry[:oid]).content
end
end
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ describe Gitlab::Git::Branch do
subject { repository.branches }
 
it { should be_kind_of Array }
its(:size) { should eq(3) }
its(:size) { should eq(SeedRepo::Repo::BRANCHES.size) }
 
describe 'first branch' do
let(:branch) { repository.branches.first }
Loading
Loading
Loading
Loading
@@ -193,7 +193,7 @@ describe Gitlab::Git::Commit do
commits.map { |c| c.id }
end
 
it { should have(20).elements }
it { should have(22).elements }
it { should include(SeedRepo::Commit::ID) }
it { should include(SeedRepo::Commit::PARENT_ID) }
it { should include(SeedRepo::FirstCommit::ID) }
Loading
Loading
Loading
Loading
@@ -121,7 +121,7 @@ describe Gitlab::Git::Repository do
subject { heads }
 
it { should be_kind_of Array }
its(:size) { should eq(3) }
its(:size) { should eq(SeedRepo::Repo::BRANCHES.size) }
 
context :head do
subject { heads.first }
Loading
Loading
@@ -199,6 +199,11 @@ describe Gitlab::Git::Repository do
it 'should not have an entry for an invalid submodule' do
expect(submodules).not_to have_key('invalid/path')
end
it 'should not have an entry for an uncommited submodule dir' do
submodules = repository.submodules('fix-existing-submodule-dir')
expect(submodules).not_to have_key('submodule-existing-dir')
end
end
 
context 'where repo doesn\'t have submodules' do
Loading
Loading
module SeedRepo
module Repo
HEAD = "master"
BRANCHES = ["feature", "fix", "master"]
BRANCHES = ["feature", "fix", "fix-existing-submodule-dir", "master"]
TAGS = ["v1.0.0", 'v1.1.0', 'v1.2.0', 'v1.2.1']
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment