lib/gitlab_git/attributes.rb in gitlab_git-10.6.2 vs lib/gitlab_git/attributes.rb in gitlab_git-10.6.3
- old
+ new
@@ -55,31 +55,38 @@
# Returns a Hash containing the attributes and their values.
def parse_attributes(string)
values = {}
dash = '-'
equal = '='
+ binary = 'binary'
string.split(/\s+/).each do |chunk|
# Data such as "foo = bar" should be treated as "foo" and "bar" being
# separate boolean attributes.
next if chunk == equal
+ key = chunk
+
# Input: "-foo"
if chunk.start_with?(dash)
key = chunk.byteslice(1, chunk.length - 1)
+ value = false
- values[key] = false
-
# Input: "foo=bar"
elsif chunk.include?(equal)
key, value = chunk.split(equal, 2)
- values[key] = value
-
# Input: "foo"
else
- values[chunk] = true
+ value = true
end
+
+ values[key] = value
+
+ # When the "binary" option is set the "diff" option should be set to
+ # the inverse. If "diff" is later set it should overwrite the
+ # automatically set value.
+ values['diff'] = false if key == binary && value
end
values
end