Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3f79376c
Commit
3f79376c
authored
Jan 29, 2018
by
Jacob Vosmaer (GitLab)
Committed by
Rémy Coutable
Jan 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set alternate object directories in run_git
parent
726c7105
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
23 deletions
+35
-23
lib/gitlab/git/blame.rb
lib/gitlab/git/blame.rb
+1
-3
lib/gitlab/git/popen.rb
lib/gitlab/git/popen.rb
+2
-0
lib/gitlab/git/repository.rb
lib/gitlab/git/repository.rb
+32
-20
No files found.
lib/gitlab/git/blame.rb
View file @
3f79376c
...
...
@@ -42,9 +42,7 @@ module Gitlab
end
def
load_blame_by_shelling_out
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
@repo
.
path
}
blame -p
#{
@sha
}
--
#{
@path
}
)
# Read in binary mode to ensure ASCII-8BIT
IO
.
popen
(
cmd
,
'rb'
)
{
|
io
|
io
.
read
}
@repo
.
shell_blame
(
@sha
,
@path
)
end
def
process_raw_blame
(
output
)
...
...
lib/gitlab/git/popen.rb
View file @
3f79376c
...
...
@@ -19,6 +19,8 @@ module Gitlab
cmd_output
=
""
cmd_status
=
0
Open3
.
popen3
(
vars
,
*
cmd
,
options
)
do
|
stdin
,
stdout
,
stderr
,
wait_thr
|
stdout
.
set_encoding
(
Encoding
::
ASCII_8BIT
)
yield
(
stdin
)
if
block_given?
stdin
.
close
...
...
lib/gitlab/git/repository.rb
View file @
3f79376c
...
...
@@ -614,11 +614,11 @@ module Gitlab
if
is_enabled
gitaly_ref_client
.
find_ref_name
(
sha
,
ref_path
)
else
args
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
for-each-ref --count=1
#{
ref_path
}
--contains
#{
sha
}
)
args
=
%W(for-each-ref --count=1
#{
ref_path
}
--contains
#{
sha
}
)
# Not found -> ["", 0]
# Found -> ["b8d95eb4969eefacb0a58f6a28f6803f8070e7b9 commit\trefs/environments/production/77\n", 0]
popen
(
args
,
@path
).
first
.
split
.
last
run_git
(
args
).
first
.
split
.
last
end
end
end
...
...
@@ -887,8 +887,7 @@ module Gitlab
"delete
#{
ref
}
\x00\x00
"
end
command
=
%W[
#{
Gitlab
.
config
.
git
.
bin_path
}
update-ref --stdin -z]
message
,
status
=
popen
(
command
,
path
)
do
|
stdin
|
message
,
status
=
run_git
(
%w[update-ref --stdin -z]
)
do
|
stdin
|
stdin
.
write
(
instructions
.
join
)
end
...
...
@@ -1409,6 +1408,11 @@ module Gitlab
end
end
def
shell_blame
(
sha
,
path
)
output
,
_status
=
run_git
(
%W(blame -p
#{
sha
}
--
#{
path
}
)
)
output
end
private
def
shell_write_ref
(
ref_path
,
ref
,
old_ref
)
...
...
@@ -1433,6 +1437,12 @@ module Gitlab
def
run_git
(
args
,
chdir:
path
,
env:
{},
nice:
false
,
&
block
)
cmd
=
[
Gitlab
.
config
.
git
.
bin_path
,
*
args
]
cmd
.
unshift
(
"nice"
)
if
nice
object_directories
=
alternate_object_directories
if
object_directories
.
any?
env
[
'GIT_ALTERNATE_OBJECT_DIRECTORIES'
]
=
object_directories
.
join
(
File
::
PATH_SEPARATOR
)
end
circuit_breaker
.
perform
do
popen
(
cmd
,
chdir
,
env
,
&
block
)
end
...
...
@@ -1624,7 +1634,7 @@ module Gitlab
offset_in_ruby
=
use_follow_flag
&&
options
[
:offset
].
present?
limit
+=
offset
if
offset_in_ruby
cmd
=
%
W[
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
log]
cmd
=
%
w[
log]
cmd
<<
"--max-count=
#{
limit
}
"
cmd
<<
'--format=%H'
cmd
<<
"--skip=
#{
offset
}
"
unless
offset_in_ruby
...
...
@@ -1640,7 +1650,7 @@ module Gitlab
cmd
+=
Array
(
options
[
:path
])
end
raw_output
=
IO
.
popen
(
cmd
)
{
|
io
|
io
.
read
}
raw_output
,
_status
=
run_git
(
cmd
)
lines
=
offset_in_ruby
?
raw_output
.
lines
.
drop
(
offset
)
:
raw_output
.
lines
lines
.
map!
{
|
c
|
Rugged
::
Commit
.
new
(
rugged
,
c
.
strip
)
}
...
...
@@ -1678,18 +1688,23 @@ module Gitlab
end
def
alternate_object_directories
relative_paths
=
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_RELATIVE_DIRECTORIES_VARIABLES
).
flatten
.
compact
relative_paths
=
relative_object_directories
if
relative_paths
.
any?
relative_paths
.
map
{
|
d
|
File
.
join
(
path
,
d
)
}
else
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_DIRECTORIES_VARIABLES
)
.
flatten
.
compact
.
flat_map
{
|
d
|
d
.
split
(
File
::
PATH_SEPARATOR
)
}
absolute_object_directories
.
flat_map
{
|
d
|
d
.
split
(
File
::
PATH_SEPARATOR
)
}
end
end
def
relative_object_directories
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_RELATIVE_DIRECTORIES_VARIABLES
).
flatten
.
compact
end
def
absolute_object_directories
Gitlab
::
Git
::
Env
.
all
.
values_at
(
*
ALLOWED_OBJECT_DIRECTORIES_VARIABLES
).
flatten
.
compact
end
# Get the content of a blob for a given commit. If the blob is a commit
# (for submodules) then return the blob's OID.
def
blob_content
(
commit
,
blob_name
)
...
...
@@ -1833,13 +1848,13 @@ module Gitlab
def
count_commits_by_shelling_out
(
options
)
cmd
=
count_commits_shelling_command
(
options
)
raw_output
=
IO
.
popen
(
cmd
)
{
|
io
|
io
.
read
}
raw_output
,
_status
=
run_git
(
cmd
)
process_count_commits_raw_output
(
raw_output
,
options
)
end
def
count_commits_shelling_command
(
options
)
cmd
=
%
W[
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
rev-list]
cmd
=
%
w[
rev-list]
cmd
<<
"--after=
#{
options
[
:after
].
iso8601
}
"
if
options
[
:after
]
cmd
<<
"--before=
#{
options
[
:before
].
iso8601
}
"
if
options
[
:before
]
cmd
<<
"--max-count=
#{
options
[
:max_count
]
}
"
if
options
[
:max_count
]
...
...
@@ -1884,20 +1899,17 @@ module Gitlab
return
[]
end
cmd
=
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--git-dir=
#{
path
}
ls-tree)
cmd
+=
%w(-r)
cmd
+=
%w(--full-tree)
cmd
+=
%w(--full-name)
cmd
+=
%W(--
#{
actual_ref
}
)
cmd
=
%W(ls-tree -r --full-tree --full-name --
#{
actual_ref
}
)
raw_output
,
_status
=
run_git
(
cmd
)
raw_output
=
IO
.
popen
(
cmd
,
&
:read
)
.
split
(
"
\n
"
).
map
do
|
f
|
lines
=
raw_output
.
split
(
"
\n
"
).
map
do
|
f
|
stuff
,
path
=
f
.
split
(
"
\t
"
)
_mode
,
type
,
_sha
=
stuff
.
split
(
" "
)
path
if
type
==
"blob"
# Contain only blob type
end
raw_output
.
compact
lines
.
compact
end
# Returns true if the given ref name exists
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment