From 5972dedfcfda1826617092b018e68757c18d995a Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 22 Jan 2016 08:17:54 -0800 Subject: 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" --- CHANGELOG | 1 + app/models/repository.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7c14a922c88..0d3e0571b59 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 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 -- cgit v1.2.1