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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
0b0e89ef
Commit
0b0e89ef
authored
Jul 12, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to eliminate unused diff options
parent
47c844bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
101 deletions
+9
-101
lib/gitlab/git/diff.rb
lib/gitlab/git/diff.rb
+4
-96
spec/lib/gitlab/git/diff_spec.rb
spec/lib/gitlab/git/diff_spec.rb
+5
-5
No files found.
lib/gitlab/git/diff.rb
View file @
0b0e89ef
# Gitaly note: JV: needs RPC for Gitlab::Git::Diff.between.
# Gitlab::Git::Diff is a wrapper around native Rugged::Diff object
# Gitlab::Git::Diff is a wrapper around native Rugged::Diff object
module
Gitlab
module
Gitlab
module
Git
module
Git
...
@@ -81,110 +83,16 @@ module Gitlab
...
@@ -81,110 +83,16 @@ module Gitlab
# Return a copy of the +options+ hash containing only keys that can be
# Return a copy of the +options+ hash containing only keys that can be
# passed to Rugged. Allowed options are:
# passed to Rugged. Allowed options are:
#
#
# :max_size ::
# An integer specifying the maximum byte size of a file before a it
# will be treated as binary. The default value is 512MB.
#
# :context_lines ::
# The number of unchanged lines that define the boundary of a hunk
# (and to display before and after the actual changes). The default is
# 3.
#
# :interhunk_lines ::
# The maximum number of unchanged lines between hunk boundaries before
# the hunks will be merged into a one. The default is 0.
#
# :old_prefix ::
# The virtual "directory" to prefix to old filenames in hunk headers.
# The default is "a".
#
# :new_prefix ::
# The virtual "directory" to prefix to new filenames in hunk headers.
# The default is "b".
#
# :reverse ::
# If true, the sides of the diff will be reversed.
#
# :force_text ::
# If true, all files will be treated as text, disabling binary
# attributes & detection.
#
# :ignore_whitespace ::
# If true, all whitespace will be ignored.
#
# :ignore_whitespace_change ::
# :ignore_whitespace_change ::
# If true, changes in amount of whitespace will be ignored.
# If true, changes in amount of whitespace will be ignored.
#
#
# :ignore_whitespace_eol ::
# If true, whitespace at end of line will be ignored.
#
# :ignore_submodules ::
# if true, submodules will be excluded from the diff completely.
#
# :patience ::
# If true, the "patience diff" algorithm will be used (currenlty
# unimplemented).
#
# :include_ignored ::
# If true, ignored files will be included in the diff.
#
# :include_untracked ::
# If true, untracked files will be included in the diff.
#
# :include_unmodified ::
# If true, unmodified files will be included in the diff.
#
# :recurse_untracked_dirs ::
# Even if +:include_untracked+ is true, untracked directories will
# only be marked with a single entry in the diff. If this flag is set
# to true, all files under ignored directories will be included in the
# diff, too.
#
# :disable_pathspec_match ::
# :disable_pathspec_match ::
# If true, the given +*paths+ will be applied as exact matches,
# If true, the given +*paths+ will be applied as exact matches,
# instead of as fnmatch patterns.
# instead of as fnmatch patterns.
#
#
# :deltas_are_icase ::
# If true, filename comparisons will be made with case-insensitivity.
#
# :include_untracked_content ::
# if true, untracked content will be contained in the the diff patch
# text.
#
# :skip_binary_check ::
# If true, diff deltas will be generated without spending time on
# binary detection. This is useful to improve performance in cases
# where the actual file content difference is not needed.
#
# :include_typechange ::
# If true, type changes for files will not be interpreted as deletion
# of the "old file" and addition of the "new file", but will generate
# typechange records.
#
# :include_typechange_trees ::
# Even if +:include_typechange+ is true, blob -> tree changes will
# still usually be handled as a deletion of the blob. If this flag is
# set to true, blob -> tree changes will be marked as typechanges.
#
# :ignore_filemode ::
# If true, file mode changes will be ignored.
#
# :recurse_ignored_dirs ::
# Even if +:include_ignored+ is true, ignored directories will only be
# marked with a single entry in the diff. If this flag is set to true,
# all files under ignored directories will be included in the diff,
# too.
def
filter_diff_options
(
options
,
default_options
=
{})
def
filter_diff_options
(
options
,
default_options
=
{})
allowed_options
=
[
:max_size
,
:context_lines
,
:interhunk_lines
,
allowed_options
=
[
:ignore_whitespace_change
,
:old_prefix
,
:new_prefix
,
:reverse
,
:force_text
,
:disable_pathspec_match
,
:paths
,
:ignore_whitespace
,
:ignore_whitespace_change
,
:ignore_whitespace_eol
,
:ignore_submodules
,
:patience
,
:include_ignored
,
:include_untracked
,
:include_unmodified
,
:recurse_untracked_dirs
,
:disable_pathspec_match
,
:deltas_are_icase
,
:include_untracked_content
,
:skip_binary_check
,
:include_typechange
,
:include_typechange_trees
,
:ignore_filemode
,
:recurse_ignored_dirs
,
:paths
,
:max_files
,
:max_lines
,
:limits
,
:expanded
]
:max_files
,
:max_lines
,
:limits
,
:expanded
]
if
default_options
if
default_options
...
...
spec/lib/gitlab/git/diff_spec.rb
View file @
0b0e89ef
...
@@ -241,7 +241,7 @@ EOT
...
@@ -241,7 +241,7 @@ EOT
end
end
describe
'.filter_diff_options'
do
describe
'.filter_diff_options'
do
let
(
:options
)
{
{
max_
size
:
100
,
invalid_opt:
true
}
}
let
(
:options
)
{
{
max_
files
:
100
,
invalid_opt:
true
}
}
context
"without default options"
do
context
"without default options"
do
let
(
:filtered_options
)
{
described_class
.
filter_diff_options
(
options
)
}
let
(
:filtered_options
)
{
described_class
.
filter_diff_options
(
options
)
}
...
@@ -253,7 +253,7 @@ EOT
...
@@ -253,7 +253,7 @@ EOT
context
"with default options"
do
context
"with default options"
do
let
(
:filtered_options
)
do
let
(
:filtered_options
)
do
default_options
=
{
max_
size:
5
,
bad_opt:
1
,
ignore_whitespac
e:
true
}
default_options
=
{
max_
files:
5
,
bad_opt:
1
,
ignore_whitespace_chang
e:
true
}
described_class
.
filter_diff_options
(
options
,
default_options
)
described_class
.
filter_diff_options
(
options
,
default_options
)
end
end
...
@@ -263,12 +263,12 @@ EOT
...
@@ -263,12 +263,12 @@ EOT
end
end
it
"should merge with default options"
do
it
"should merge with default options"
do
expect
(
filtered_options
).
to
have_key
(
:ignore_whitespace
)
expect
(
filtered_options
).
to
have_key
(
:ignore_whitespace
_change
)
end
end
it
"should override default options"
do
it
"should override default options"
do
expect
(
filtered_options
).
to
have_key
(
:max_
size
)
expect
(
filtered_options
).
to
have_key
(
:max_
files
)
expect
(
filtered_options
[
:max_
size
]).
to
eq
(
100
)
expect
(
filtered_options
[
:max_
files
]).
to
eq
(
100
)
end
end
end
end
end
end
...
...
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