Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 17e522f

Browse files
committed
Merge pull request #184 from kasal/master
rebased on v1.9.3
2 parents 70d7fea + 22d6277 commit 17e522f

File tree

4 files changed

+27
-42
lines changed

4 files changed

+27
-42
lines changed

builtin/grep.c

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "quote.h"
1919
#include "dir.h"
2020
#include "pathspec.h"
21-
#include "attr.h"
2221

2322
static char const * const grep_usage[] = {
2423
N_("git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]"),
@@ -164,22 +163,6 @@ static void work_done(struct work_item *w)
164163
grep_unlock();
165164
}
166165

167-
static int skip_binary(struct grep_opt *opt, const char *filename)
168-
{
169-
if ((opt->binary & GREP_BINARY_NOMATCH)) {
170-
static struct git_attr *attr_text;
171-
struct git_attr_check check;
172-
173-
if (!attr_text)
174-
attr_text = git_attr("text");
175-
memset(&check, 0, sizeof(check));
176-
check.attr = attr_text;
177-
return !git_check_attr(filename, 1, &check) &&
178-
ATTR_FALSE(check.value);
179-
}
180-
return 0;
181-
}
182-
183166
static void *run(void *arg)
184167
{
185168
int hit = 0;
@@ -190,9 +173,6 @@ static void *run(void *arg)
190173
if (!w)
191174
break;
192175

193-
if (skip_binary(opt, (const char *)w->source.identifier))
194-
continue;
195-
196176
opt->output_priv = w;
197177
hit |= grep_source(opt, &w->source);
198178
grep_source_clear_data(&w->source);
@@ -401,9 +381,6 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
401381
continue;
402382
if (!ce_path_match(ce, pathspec, NULL))
403383
continue;
404-
if (skip_binary(opt, ce->name))
405-
continue;
406-
407384
/*
408385
* If CE_VALID is on, we assume worktree file and its cache entry
409386
* are identical, even if worktree file has been modified, so use
@@ -828,8 +805,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
828805
string_list_append(&path_list, show_in_pager);
829806
use_threads = 0;
830807
}
831-
if ((opt.binary & GREP_BINARY_NOMATCH))
832-
use_threads = 0;
833808

834809
if (!opt.pattern_list)
835810
die(_("no pattern given."));
@@ -900,7 +875,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
900875
pager += len - 4;
901876

902877
if (opt.ignore_case && !strcmp("less", pager))
903-
string_list_append(&path_list, "-i");
878+
string_list_append(&path_list, "-I");
904879

905880
if (!strcmp("less", pager) || !strcmp("vi", pager)) {
906881
struct strbuf buf = STRBUF_INIT;

builtin/tag.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,17 @@ static int in_commit_list(const struct commit_list *want, struct commit *c)
7373
return 0;
7474
}
7575

76+
enum contains_result {
77+
CONTAINS_UNKNOWN = -1,
78+
CONTAINS_NO = 0,
79+
CONTAINS_YES = 1,
80+
};
81+
7682
/*
7783
* Test whether the candidate or one of its parents is contained in the list.
7884
* Do not recurse to find out, though, but return -1 if inconclusive.
7985
*/
80-
static int contains_test(struct commit *candidate,
86+
static enum contains_result contains_test(struct commit *candidate,
8187
const struct commit_list *want)
8288
{
8389
/* was it previously marked as containing a want commit? */
@@ -121,12 +127,13 @@ static void push_to_stack(struct commit *candidate, struct stack *stack)
121127
stack->stack[index].parents = candidate->parents;
122128
}
123129

124-
static int contains(struct commit *candidate, const struct commit_list *want)
130+
static enum contains_result contains(struct commit *candidate,
131+
const struct commit_list *want)
125132
{
126133
struct stack stack = { 0, 0, NULL };
127134
int result = contains_test(candidate, want);
128135

129-
if (result >= 0)
136+
if (result != CONTAINS_UNKNOWN)
130137
return result;
131138

132139
push_to_stack(candidate, &stack);
@@ -136,22 +143,22 @@ static int contains(struct commit *candidate, const struct commit_list *want)
136143
struct commit_list *parents = entry->parents;
137144

138145
if (!parents) {
139-
commit->object.flags = UNINTERESTING;
146+
commit->object.flags |= UNINTERESTING;
140147
stack.nr--;
141148
}
142149
/*
143150
* If we just popped the stack, parents->item has been marked,
144151
* therefore contains_test will return a meaningful 0 or 1.
145152
*/
146153
else switch (contains_test(parents->item, want)) {
147-
case 1:
154+
case CONTAINS_YES:
148155
commit->object.flags |= TMP_MARK;
149156
stack.nr--;
150157
break;
151-
case 0:
158+
case CONTAINS_NO:
152159
entry->parents = parents->next;
153160
break;
154-
default:
161+
case CONTAINS_UNKNOWN:
155162
push_to_stack(parents->item, &stack);
156163
break;
157164
}

compat/poll/poll.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
605605

606606
if (!rc && timeout == INFTIM)
607607
{
608-
/* Sleep 1 millisecond to avoid busy wait */
609-
SleepEx(1, TRUE);
610-
608+
SleepEx (1, TRUE);
611609
goto restart;
612610
}
613611

t/t7004-tag.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,12 +1380,17 @@ test_expect_success 'multiple --points-at are OR-ed together' '
13801380
test_cmp expect actual
13811381
'
13821382
1383-
>expect
1384-
# ulimit is a bash builtin; we can rely on that in MinGW, but nowhere else
1385-
test_expect_success MINGW '--contains works in a deep repo' '
1386-
ulimit -s 64
1383+
run_with_limited_stack () {
1384+
(ulimit -s 64 && "$@")
1385+
}
1386+
1387+
test_lazy_prereq ULIMIT 'run_with_limited_stack true'
1388+
1389+
# we require ulimit, this excludes Windows
1390+
test_expect_success ULIMIT '--contains works in a deep repo' '
1391+
>expect &&
13871392
i=1 &&
1388-
while test $i -lt 1000
1393+
while test $i -lt 4000
13891394
do
13901395
echo "commit refs/heads/master
13911396
committer A U Thor <[email protected]> $((1000000000 + $i * 100)) +0200
@@ -1397,7 +1402,7 @@ EOF"
13971402
done | git fast-import &&
13981403
git checkout master &&
13991404
git tag far-far-away HEAD^ &&
1400-
git tag --contains HEAD >actual &&
1405+
run_with_limited_stack git tag --contains HEAD >actual &&
14011406
test_cmp expect actual
14021407
'
14031408

0 commit comments

Comments
 (0)