diff options
-rw-r--r-- | builtin-fast-export.c | 3 | ||||
-rw-r--r-- | builtin-rev-list.c | 3 | ||||
-rw-r--r-- | index-pack.c | 2 | ||||
-rw-r--r-- | revision.c | 34 | ||||
-rw-r--r-- | revision.h | 3 | ||||
-rwxr-xr-x | t/t3300-funny-names.sh | 2 | ||||
-rwxr-xr-x | t/t3902-quoted.sh | 8 | ||||
-rwxr-xr-x | t/t4016-diff-quote.sh | 4 | ||||
-rwxr-xr-x | t/t4202-log.sh | 22 |
9 files changed, 46 insertions, 35 deletions
diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 070971616d..7c93eb878d 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -417,7 +417,8 @@ static void export_marks(char *file) for (i = 0; i < idnums.size; i++) { if (deco->base && deco->base->type == 1) { mark = ptr_to_mark(deco->decoration); - fprintf(f, ":%u %s\n", mark, sha1_to_hex(deco->base->sha1)); + fprintf(f, ":%"PRIu32" %s\n", mark, + sha1_to_hex(deco->base->sha1)); } deco++; } diff --git a/builtin-rev-list.c b/builtin-rev-list.c index 893762c80f..c023003b2b 100644 --- a/builtin-rev-list.c +++ b/builtin-rev-list.c @@ -645,7 +645,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix) revs.diff) usage(rev_list_usage); - save_commit_buffer = revs.verbose_header || revs.grep_filter; + save_commit_buffer = revs.verbose_header || + revs.grep_filter.pattern_list; if (bisect_list) revs.limited = 1; diff --git a/index-pack.c b/index-pack.c index 52064befdb..728af7da9c 100644 --- a/index-pack.c +++ b/index-pack.c @@ -876,7 +876,9 @@ int main(int argc, char **argv) char *index_name_buf = NULL, *keep_name_buf = NULL; struct pack_idx_entry **idx_objects; unsigned char sha1[20]; + int nongit = 0; + setup_git_directory_gently(&nongit); git_config(git_index_pack_config, NULL); for (i = 1; i < argc; i++) { diff --git a/revision.c b/revision.c index e75079a6e1..36291b6b86 100644 --- a/revision.c +++ b/revision.c @@ -782,6 +782,10 @@ void init_revisions(struct rev_info *revs, const char *prefix) revs->commit_format = CMIT_FMT_DEFAULT; + revs->grep_filter.status_only = 1; + revs->grep_filter.pattern_tail = &(revs->grep_filter.pattern_list); + revs->grep_filter.regflags = REG_NEWLINE; + diff_setup(&revs->diffopt); if (prefix && !revs->diffopt.prefix) { revs->diffopt.prefix = prefix; @@ -946,15 +950,7 @@ void read_revisions_from_stdin(struct rev_info *revs) static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what) { - if (!revs->grep_filter) { - struct grep_opt *opt = xcalloc(1, sizeof(*opt)); - opt->status_only = 1; - opt->pattern_tail = &(opt->pattern_list); - opt->regflags = REG_NEWLINE; - revs->grep_filter = opt; - } - append_grep_pattern(revs->grep_filter, ptn, - "command line", 0, what); + append_grep_pattern(&revs->grep_filter, ptn, "command line", 0, what); } static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern) @@ -1164,17 +1160,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg } else if (!prefixcmp(arg, "--grep=")) { add_message_grep(revs, arg+7); } else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) { - if (revs->grep_filter) - revs->grep_filter->regflags |= REG_EXTENDED; + revs->grep_filter.regflags |= REG_EXTENDED; } else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) { - if (revs->grep_filter) - revs->grep_filter->regflags |= REG_ICASE; + revs->grep_filter.regflags |= REG_ICASE; } else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) { - if (revs->grep_filter) - revs->grep_filter->fixed = 1; + revs->grep_filter.fixed = 1; } else if (!strcmp(arg, "--all-match")) { - if (revs->grep_filter) - revs->grep_filter->all_match = 1; + revs->grep_filter.all_match = 1; } else if (!prefixcmp(arg, "--encoding=")) { arg += 11; if (strcmp(arg, "none")) @@ -1349,9 +1341,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch if (diff_setup_done(&revs->diffopt) < 0) die("diff_setup_done failed"); - if (revs->grep_filter) { - compile_grep_patterns(revs->grep_filter); - } + compile_grep_patterns(&revs->grep_filter); if (revs->reverse && revs->reflog_info) die("cannot combine --reverse with --walk-reflogs"); @@ -1492,9 +1482,9 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit) static int commit_match(struct commit *commit, struct rev_info *opt) { - if (!opt->grep_filter) + if (!opt->grep_filter.pattern_list) return 1; - return grep_buffer(opt->grep_filter, + return grep_buffer(&opt->grep_filter, NULL, /* we say nothing, not even filename */ commit->buffer, strlen(commit->buffer)); } diff --git a/revision.h b/revision.h index 1b045669ae..91f194478b 100644 --- a/revision.h +++ b/revision.h @@ -2,6 +2,7 @@ #define REVISION_H #include "parse-options.h" +#include "grep.h" #define SEEN (1u<<0) #define UNINTERESTING (1u<<1) @@ -92,7 +93,7 @@ struct rev_info { int show_log_size; /* Filter by commit log message */ - struct grep_opt *grep_filter; + struct grep_opt grep_filter; /* Display history graph */ struct git_graph *graph; diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh index 0574ef1f10..db46d53e82 100755 --- a/t/t3300-funny-names.sh +++ b/t/t3300-funny-names.sh @@ -21,7 +21,7 @@ cat >"$p0" <<\EOF 3. A quick brown fox jumps over the lazy cat, oops dog. EOF -cat >"$p1" "$p0" +cat 2>/dev/null >"$p1" "$p0" echo 'Foo Bar Baz' >"$p2" test -f "$p1" && cmp "$p0" "$p1" || { diff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh index fe4fb5116a..5868052425 100755 --- a/t/t3902-quoted.sh +++ b/t/t3902-quoted.sh @@ -7,12 +7,6 @@ test_description='quoted output' . ./test-lib.sh -P1='pathname with HT' -: >"$P1" 2>&1 && test -f "$P1" && rm -f "$P1" || { - echo >&2 'Filesystem does not support HT in names' - test_done -} - FN='濱野' GN='純' HT=' ' @@ -20,7 +14,7 @@ LF=' ' DQ='"' -echo foo > "Name and an${HT}HT" +echo foo 2>/dev/null > "Name and an${HT}HT" test -f "Name and an${HT}HT" || { # since FAT/NTFS does not allow tabs in filenames, skip this test say 'Your filesystem does not allow tabs in filenames, test skipped.' diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh index f07035ab7e..55eb5f83f1 100755 --- a/t/t4016-diff-quote.sh +++ b/t/t4016-diff-quote.sh @@ -13,8 +13,8 @@ P1='pathname with HT' P2='pathname with SP' P3='pathname with LF' -: >"$P1" 2>&1 && test -f "$P1" && rm -f "$P1" || { - echo >&2 'Filesystem does not support tabs in names' +: 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || { + say 'Your filesystem does not allow tabs in filenames, test skipped.' test_done } diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 4c8af45f83..0ab925c4e4 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -69,7 +69,29 @@ test_expect_success 'diff-filter=D' ' ' +test_expect_success 'setup case sensitivity tests' ' + echo case >one && + test_tick && + git commit -a -m Second +' + +test_expect_success 'log --grep' ' + echo second >expect && + git log -1 --pretty="tformat:%s" --grep=sec >actual && + test_cmp expect actual +' +test_expect_success 'log -i --grep' ' + echo Second >expect && + git log -1 --pretty="tformat:%s" -i --grep=sec >actual && + test_cmp expect actual +' + +test_expect_success 'log --grep -i' ' + echo Second >expect && + git log -1 --pretty="tformat:%s" --grep=sec -i >actual && + test_cmp expect actual +' test_done |