summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-01-23 18:11:08 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2016-01-23 18:11:08 +0000
commitdc78ee4e8b4911edf04949e2aa036997623d60ae (patch)
tree4e5cf467c754ce8052a30aee4d856665548b2bc5
parentfb3e1026e8d1bbdf1b6714648ddc907a5ad9cfe7 (diff)
parent5972dedfcfda1826617092b018e68757c18d995a (diff)
downloadgitlab-ce-dc78ee4e8b4911edf04949e2aa036997623d60ae.tar.gz
Merge branch 'ignore-binary-files-in-git-grep' into 'master'
Ignore binary files in code search to prevent Error 500 Leaving out the -I option in "git grep" would cause an Error 500 because the resulting line would include "Binary file X matches", which would cause the project search results to crash with the following error: ``` ActionView::Template::Error (wrong argument type nil (expected Regexp)): 1: - blob = @project.repository.parse_search_result(blob) 2: .blob-result 3: .file-holder 4: .file-title app/models/repository.rb:742:in `sub' app/models/repository.rb:742:in `block in parse_search_result_from_grep' app/models/repository.rb:741:in `each_line' app/models/repository.rb:741:in `parse_search_result_from_grep' app/models/repository.rb:682:in `parse_search_result' app/views/search/results/_blob.html.haml:1:in `_app_views_search_results__blob_html_haml__1959871337755590783_162450160' app/views/search/_results.html.haml:20:in `_app_views_search__results_html_haml__2198486911700532411_58329920' app/views/search/show.html.haml:7:in `_app_views_search_show_html_haml___1698304427272645201_62235300' ``` See merge request !2565
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/repository.rb2
2 files changed, 2 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 0c4d90855a5..7af6a22f37f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.5.0 (unreleased)
- Add "visibility" flag to GET /projects api endpoint
+ - Ignore binary files in code search to prevent Error 500 (Stan Hu)
- Upgrade gitlab_git to 7.2.23 to fix commit message mentions in first branch push
- New UI for pagination
- Fix diff comments loaded by AJAX to load comment with diff in discussion tab
diff --git a/app/models/repository.rb b/app/models/repository.rb
index d9ff71c01ed..9e8bd91fde9 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -598,7 +598,7 @@ class Repository
def search_files(query, ref)
offset = 2
- args = %W(#{Gitlab.config.git.bin_path} grep -i -n --before-context #{offset} --after-context #{offset} -e #{query} #{ref || root_ref})
+ args = %W(#{Gitlab.config.git.bin_path} grep -i -I -n --before-context #{offset} --after-context #{offset} -e #{query} #{ref || root_ref})
Gitlab::Popen.popen(args, path_to_repo).first.scrub.split(/^--$/)
end