Skip to content

Commit fca147c

Browse files
committed
Use explicit allow file protocol config flag when executing git submodule add command (Issue sds#828)
1 parent e54f89b commit fca147c

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

‎spec/overcommit/git_repo_spec.rb‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
end
2525

2626
submodule = repo do
27-
`git submodule add #{nested_submodule} nested-sub 2>&1 > #{File::NULL}`
27+
`git -c protocol.file.allow=always submodule add #{nested_submodule} nested-sub 2>&1 > #{File::NULL}`
2828
`git commit -m "Add nested submodule"`
2929
end
3030

3131
repo do
32-
`git submodule add #{submodule} sub 2>&1 > #{File::NULL}`
32+
`git -c protocol.file.allow=always submodule add #{submodule} sub 2>&1 > #{File::NULL}`
3333
example.run
3434
end
3535
end
@@ -150,7 +150,7 @@
150150
end
151151

152152
before do
153-
`git submodule add #{submodule} sub 2>&1 > #{File::NULL}`
153+
`git -c protocol.file.allow=always submodule add #{submodule} sub 2>&1 > #{File::NULL}`
154154
end
155155

156156
it { should_not include File.expand_path('sub') }
@@ -178,7 +178,7 @@
178178
`git commit --allow-empty -m "Submodule commit"`
179179
end
180180

181-
`git submodule add #{submodule} #{submodule_dir} 2>&1 > #{File::NULL}`
181+
`git -c protocol.file.allow=always submodule add #{submodule} #{submodule_dir} 2>&1 > #{File::NULL}`
182182
`git commit -m "Add submodule"`
183183
end
184184

@@ -282,7 +282,7 @@
282282
touch 'tracked'
283283
`git add tracked`
284284
`git commit -m "Initial commit"`
285-
`git submodule add #{submodule} sub 2>&1 > #{File::NULL}`
285+
`git -c protocol.file.allow=always submodule add #{submodule} sub 2>&1 > #{File::NULL}`
286286
touch 'staged'
287287
`git add staged`
288288
example.run
@@ -327,7 +327,7 @@
327327
end
328328

329329
repo do
330-
`git submodule add #{submodule} sub-repo 2>&1 > #{File::NULL}`
330+
`git -c protocol.file.allow=always submodule add #{submodule} sub-repo 2>&1 > #{File::NULL}`
331331
`git commit -m "Initial commit"`
332332
example.run
333333
end
@@ -343,7 +343,7 @@
343343
`git commit --allow-empty -m "Another submodule"`
344344
end
345345

346-
`git submodule add #{another_submodule} another-sub-repo 2>&1 > #{File::NULL}`
346+
`git -c protocol.file.allow=always submodule add #{another_submodule} another-sub-repo 2>&1 > #{File::NULL}`
347347
end
348348

349349
it { should be_empty }
@@ -369,7 +369,7 @@
369369
`git commit --allow-empty -m "Another submodule"`
370370
end
371371

372-
`git submodule add #{another_submodule} yet-another-sub-repo 2>&1 > #{File::NULL}`
372+
`git -c protocol.file.allow=always submodule add #{another_submodule} yet-another-sub-repo 2>&1 > #{File::NULL}`
373373
`git commit -m "Add yet another submodule"`
374374
`git rm sub-repo`
375375
`git rm yet-another-sub-repo`

‎spec/overcommit/hook_context/commit_msg_spec.rb‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
end
299299

300300
repo do
301-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
301+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
302302
`git commit -m "Add submodule"`
303303
echo('Hello World', 'sub/submodule-file')
304304
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -474,7 +474,7 @@
474474
end
475475

476476
repo do
477-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
477+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
478478
`git commit -m "Add submodule"`
479479
echo('Hello World', 'sub/submodule-file')
480480
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -500,7 +500,7 @@
500500
end
501501

502502
repo do
503-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
503+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
504504
`git commit -m "Add submodule"`
505505
echo('Hello World', 'sub/submodule-file')
506506
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -532,7 +532,7 @@
532532
end
533533

534534
repo do
535-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
535+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
536536
`git commit -m "Add submodule"`
537537
`git rm sub`
538538
example.run
@@ -561,7 +561,7 @@
561561
end
562562

563563
repo do
564-
`git submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
564+
`git -c protocol.file.allow=always submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
565565
expect(subject).to_not include File.expand_path('test-sub')
566566
end
567567
end

‎spec/overcommit/hook_context/pre_commit_spec.rb‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
end
208208

209209
repo do
210-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
210+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
211211
`git commit -m "Add submodule"`
212212
echo('Hello World', 'sub/submodule-file')
213213
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -383,7 +383,7 @@
383383
end
384384

385385
repo do
386-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
386+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
387387
`git commit -m "Add submodule"`
388388
echo('Hello World', 'sub/submodule-file')
389389
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -409,7 +409,7 @@
409409
end
410410

411411
repo do
412-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
412+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
413413
`git commit -m "Add submodule"`
414414
echo('Hello World', 'sub/submodule-file')
415415
`git submodule foreach "git add submodule-file" < #{File::NULL}`
@@ -441,7 +441,7 @@
441441
end
442442

443443
repo do
444-
`git submodule add #{submodule} sub > #{File::NULL} 2>&1`
444+
`git -c protocol.file.allow=always submodule add #{submodule} sub > #{File::NULL} 2>&1`
445445
`git commit -m "Add submodule"`
446446
`git rm sub`
447447
example.run
@@ -470,7 +470,7 @@
470470
end
471471

472472
repo do
473-
`git submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
473+
`git -c protocol.file.allow=always submodule add #{submodule} test-sub 2>&1 > #{File::NULL}`
474474
expect(subject).to_not include File.expand_path('test-sub')
475475
end
476476
end

‎spec/overcommit/installer_spec.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ def hook_files_installed?(hooks_dir)
231231
context 'which has an external git dir' do
232232
let(:submodule) { File.join(target, 'submodule') }
233233
before do
234-
system 'git', 'submodule', 'add', target, 'submodule',
235-
chdir: target, out: :close, err: :close
234+
system 'git', '-c', 'protocol.file.allow=always', 'submodule', 'add', target,
235+
'submodule', chdir: target, out: :close, err: :close
236236
end
237237
let(:submodule_git_file) { File.join(submodule, '.git') }
238238
let(:submodule_git_dir) do

0 commit comments

Comments
 (0)