pickaxe: hoist empty needle check

If we are given an empty pickaxe needle like "git log -S ''", it is impossible for us to find anything (because no matter what the content, the count will always be 0). We currently check this at the lowest level of contains(). Let's hoist the logic much earlier to has_changes(), so that it is simpler to return our answer before loading any blob data. Signed-off-by: Jeff King <peff@peff.net>

Jeff King committed Oct 28, 2012 at 08:34 UTC 8fa4b09fb14339c5d62e65a88fde8b220cb1591b
1 file changed +3 -2
diffcore-pickaxe.c
+3 -2
@@ -163,8 +163,6 @@ static unsigned int contains(struct diff_filespec *one, struct diff_options *o,
163 unsigned int cnt;
164 unsigned long sz;
165 const char *data;
166 - if (!o->pickaxe[0])
167 - return 0;
166 if (diff_populate_filespec(one, 0))
167 return 0;
168
@@ -206,6 +204,9 @@ static unsigned int contains(struct diff_filespec *one, struct diff_options *o,
204 static int has_changes(struct diff_filepair *p, struct diff_options *o,
205 regex_t *regexp, kwset_t kws)
206 {
207 + if (!o->pickaxe[0])
208 + return 0;
209 +
210 if (!DIFF_FILE_VALID(p->one)) {
211 if (!DIFF_FILE_VALID(p->two))
212 return 0; /* ignore unmerged */