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

Commit 674dd13

Browse files
committed
Merge 'refs/rewritten/junio/next' into HEAD
2 parents ec765f6 + 6c536a9 commit 674dd13

File tree

13 files changed

+151
-35
lines changed

13 files changed

+151
-35
lines changed

builtin/grep.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
874874
if (len > 4 && is_dir_sep(pager[len - 5]))
875875
pager += len - 4;
876876

877+
if (opt.ignore_case && !strcmp("less", pager))
878+
string_list_append(&path_list, "-I");
879+
877880
if (!strcmp("less", pager) || !strcmp("vi", pager)) {
878881
struct strbuf buf = STRBUF_INIT;
879882
strbuf_addf(&buf, "+/%s%s",

builtin/tag.c

Lines changed: 75 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,38 +80,98 @@ static int in_commit_list(const struct commit_list *want, struct commit *c)
8080
return 0;
8181
}
8282

83-
static int contains_recurse(struct commit *candidate,
83+
enum contains_result {
84+
CONTAINS_UNKNOWN = -1,
85+
CONTAINS_NO = 0,
86+
CONTAINS_YES = 1,
87+
};
88+
89+
/*
90+
* Test whether the candidate or one of its parents is contained in the list.
91+
* Do not recurse to find out, though, but return -1 if inconclusive.
92+
*/
93+
static enum contains_result contains_test(struct commit *candidate,
8494
const struct commit_list *want)
8595
{
86-
struct commit_list *p;
87-
8896
/* was it previously marked as containing a want commit? */
8997
if (candidate->object.flags & TMP_MARK)
9098
return 1;
9199
/* or marked as not possibly containing a want commit? */
92100
if (candidate->object.flags & UNINTERESTING)
93101
return 0;
94102
/* or are we it? */
95-
if (in_commit_list(want, candidate))
103+
if (in_commit_list(want, candidate)) {
104+
candidate->object.flags |= TMP_MARK;
96105
return 1;
106+
}
97107

98108
if (parse_commit(candidate) < 0)
99109
return 0;
100110

101-
/* Otherwise recurse and mark ourselves for future traversals. */
102-
for (p = candidate->parents; p; p = p->next) {
103-
if (contains_recurse(p->item, want)) {
104-
candidate->object.flags |= TMP_MARK;
105-
return 1;
106-
}
107-
}
108-
candidate->object.flags |= UNINTERESTING;
109-
return 0;
111+
return -1;
110112
}
111113

112-
static int contains(struct commit *candidate, const struct commit_list *want)
114+
/*
115+
* Mimicking the real stack, this stack lives on the heap, avoiding stack
116+
* overflows.
117+
*
118+
* At each recursion step, the stack items points to the commits whose
119+
* ancestors are to be inspected.
120+
*/
121+
struct stack {
122+
int nr, alloc;
123+
struct stack_entry {
124+
struct commit *commit;
125+
struct commit_list *parents;
126+
} *stack;
127+
};
128+
129+
static void push_to_stack(struct commit *candidate, struct stack *stack)
130+
{
131+
int index = stack->nr++;
132+
ALLOC_GROW(stack->stack, stack->nr, stack->alloc);
133+
stack->stack[index].commit = candidate;
134+
stack->stack[index].parents = candidate->parents;
135+
}
136+
137+
static enum contains_result contains(struct commit *candidate,
138+
const struct commit_list *want)
113139
{
114-
return contains_recurse(candidate, want);
140+
struct stack stack = { 0, 0, NULL };
141+
int result = contains_test(candidate, want);
142+
143+
if (result != CONTAINS_UNKNOWN)
144+
return result;
145+
146+
push_to_stack(candidate, &stack);
147+
while (stack.nr) {
148+
struct stack_entry *entry = &stack.stack[stack.nr - 1];
149+
struct commit *commit = entry->commit;
150+
struct commit_list *parents = entry->parents;
151+
152+
if (!parents) {
153+
commit->object.flags |= UNINTERESTING;
154+
stack.nr--;
155+
}
156+
/*
157+
* If we just popped the stack, parents->item has been marked,
158+
* therefore contains_test will return a meaningful 0 or 1.
159+
*/
160+
else switch (contains_test(parents->item, want)) {
161+
case CONTAINS_YES:
162+
commit->object.flags |= TMP_MARK;
163+
stack.nr--;
164+
break;
165+
case CONTAINS_NO:
166+
entry->parents = parents->next;
167+
break;
168+
case CONTAINS_UNKNOWN:
169+
push_to_stack(parents->item, &stack);
170+
break;
171+
}
172+
}
173+
free(stack.stack);
174+
return contains_test(candidate, want);
115175
}
116176

117177
static void show_tag_lines(const unsigned char *sha1, int lines)

cache.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,6 @@ int normalize_path_copy(char *dst, const char *src);
809809
int longest_ancestor_length(const char *path, struct string_list *prefixes);
810810
char *strip_path_suffix(const char *path, const char *suffix);
811811
int daemon_avoid_alias(const char *path);
812-
int offset_1st_component(const char *path);
813812

814813
/* object replacement */
815814
#define LOOKUP_REPLACE_OBJECT 1

compat/mingw.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,3 +1823,27 @@ pid_t waitpid(pid_t pid, int *status, int options)
18231823
errno = EINVAL;
18241824
return -1;
18251825
}
1826+
1827+
int mingw_offset_1st_component(const char *path)
1828+
{
1829+
int offset = 0;
1830+
if (has_dos_drive_prefix(path))
1831+
offset = 2;
1832+
1833+
/* unc paths */
1834+
else if (is_dir_sep(path[0]) && is_dir_sep(path[1])) {
1835+
1836+
/* skip server name */
1837+
char *pos = strpbrk(path + 2, "\\/");
1838+
if (!pos)
1839+
return 0; /* Error: malformed unc path */
1840+
1841+
do {
1842+
pos++;
1843+
} while (*pos && !is_dir_sep(*pos));
1844+
1845+
offset = pos - path;
1846+
}
1847+
1848+
return offset + is_dir_sep(path[offset]);
1849+
}

compat/mingw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ static inline char *mingw_find_last_dir_sep(const char *path)
339339
return ret;
340340
}
341341
#define find_last_dir_sep mingw_find_last_dir_sep
342+
int mingw_offset_1st_component(const char *path);
343+
#define offset_1st_component mingw_offset_1st_component
342344
#define PATH_SEP ';'
343345
#define PRIuMAX "I64u"
344346
#define PRId64 "I64d"

compat/poll/poll.c

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

606606
if (!rc && timeout == INFTIM)
607607
{
608-
SwitchToThread();
608+
SleepEx (1, TRUE);
609609
goto restart;
610610
}
611611

config.mak.uname

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,16 @@ ifeq ($(uname_S),Windows)
358358
compat/win32/pthread.o compat/win32/syslog.o \
359359
compat/win32/dirent.o
360360
COMPAT_CFLAGS = -D__USE_MINGW_ACCESS -DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -DSTRIP_EXTENSION=\".exe\"
361-
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE -NODEFAULTLIB:MSVCRT.lib
361+
BASIC_LDFLAGS = -IGNORE:4217 -IGNORE:4049 -NOLOGO -SUBSYSTEM:CONSOLE
362362
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj
363363
PTHREAD_LIBS =
364364
lib =
365365
ifndef DEBUG
366-
BASIC_CFLAGS += -GL -Os -MT
366+
BASIC_CFLAGS += -GL -Os -MD
367367
BASIC_LDFLAGS += -LTCG
368368
AR += -LTCG
369369
else
370-
BASIC_CFLAGS += -Zi -MTd
370+
BASIC_CFLAGS += -Zi -MDd
371371
endif
372372
X = .exe
373373
endif

contrib/credential/wincred/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
all: git-credential-wincred.exe
22

3-
CC = gcc
4-
RM = rm -f
5-
CFLAGS = -O2 -Wall
6-
73
-include ../../../config.mak.autogen
84
-include ../../../config.mak
95

6+
CC ?= gcc
7+
RM ?= rm -f
8+
CFLAGS ?= -O2 -Wall
9+
10+
prefix ?= /usr/local
11+
libexecdir ?= $(prefix)/libexec/git-core
12+
13+
INSTALL ?= install
14+
1015
git-credential-wincred.exe : git-credential-wincred.c
1116
$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@
1217

18+
install: git-credential-wincred.exe
19+
$(INSTALL) -m 755 $^ $(libexecdir)
20+
1321
clean:
1422
$(RM) git-credential-wincred.exe

git-compat-util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ extern char *gitbasename(char *);
267267
#define has_dos_drive_prefix(path) 0
268268
#endif
269269

270+
#ifndef offset_1st_component
271+
#define offset_1st_component(path) (is_dir_sep((path)[0]))
272+
#endif
273+
270274
#ifndef is_dir_sep
271275
#define is_dir_sep(c) ((c) == '/')
272276
#endif

git-submodule.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,6 @@ module_clone()
291291
# resolve any symlinks that might be present in $PWD
292292
a=$(cd_to_toplevel && cd "$gitdir" && pwd)/
293293
b=$(cd_to_toplevel && cd "$sm_path" && pwd)/
294-
# normalize Windows-style absolute paths to POSIX-style absolute paths
295-
case $a in [a-zA-Z]:/*) a=/${a%%:*}${a#*:} ;; esac
296-
case $b in [a-zA-Z]:/*) b=/${b%%:*}${b#*:} ;; esac
297294
# Remove all common leading directories after a sanity check
298295
if test "${a#$b}" != "$a" || test "${b#$a}" != "$b"; then
299296
die "$(eval_gettext "Gitdir '\$a' is part of the submodule path '\$b' or vice versa")"

0 commit comments

Comments
 (0)