the_silver_searcher/5a1c8d83ba.patch
2023-09-16 18:23:31 +08:00

877 lines
27 KiB
Diff

diff -Nur a/ag.bashcomp.sh b/ag.bashcomp.sh
--- a/ag.bashcomp.sh 2018-08-07 14:43:51.000000000 +0800
+++ b/ag.bashcomp.sh 2020-07-05 03:27:44.000000000 +0800
@@ -67,7 +67,7 @@
--parallel
--passthrough
--passthru
- --path-to-agignore
+ --path-to-ignore
--print-long-lines
--print0
--recurse
@@ -106,7 +106,7 @@
--ignore-dir) # directory completion
_filedir -d
return 0;;
- --path-to-agignore) # file completion
+ --path-to-ignore) # file completion
_filedir
return 0;;
--pager) # command completion
diff -Nur a/README.md b/README.md
--- a/README.md 2018-08-07 14:43:51.000000000 +0800
+++ b/README.md 2020-07-05 03:27:44.000000000 +0800
@@ -76,14 +76,18 @@
sbopkg -i the_silver_searcher
-* openSUSE:
+* openSUSE
zypper install the_silver_searcher
-* CentOS:
-
+* CentOS
+
yum install the_silver_searcher
+* NixOS/Nix/Nixpkgs
+
+ nix-env -iA silver-searcher
+
* SUSE Linux Enterprise: Follow [these simple instructions](https://software.opensuse.org/download.html?project=utilities&package=the_silver_searcher).
@@ -102,6 +106,20 @@
Unofficial daily builds are [available](https://github.com/k-takata/the_silver_searcher-win32).
+* winget
+
+ winget install "The Silver Searcher"
+
+ Notes:
+ - This installs a [release](https://github.com/JFLarvoire/the_silver_searcher/releases) of ag.exe optimized for Windows.
+ - winget is intended to become the default package manager client for Windows.
+ As of June 2020, it's still in beta, and can be installed using instructions [there](https://github.com/microsoft/winget-cli).
+ - The setup script in the Ag's winget package installs ag.exe in the first directory that matches one of these criteria:
+ 1. Over a previous instance of ag.exe *from the same [origin](https://github.com/JFLarvoire/the_silver_searcher)* found in the PATH
+ 2. In the directory defined in environment variable bindir_%PROCESSOR_ARCHITECTURE%
+ 3. In the directory defined in environment variable bindir
+ 4. In the directory defined in environment variable windir
+
* Chocolatey
choco install ag
@@ -132,7 +150,7 @@
* CentOS:
yum -y groupinstall "Development Tools"
- yum -y install pcre-devel xz-devel
+ yum -y install pcre-devel xz-devel zlib-devel
* openSUSE:
zypper source-install --build-deps-only the_silver_searcher
@@ -190,9 +208,10 @@
## Other stuff you might like
-* [Ack](https://github.com/petdance/ack2) - Better than grep. Without Ack, Ag would not exist.
+* [Ack](https://github.com/petdance/ack3) - Better than grep. Without Ack, Ag would not exist.
* [ack.vim](https://github.com/mileszs/ack.vim)
* [Exuberant Ctags](http://ctags.sourceforge.net/) - Faster than Ag, but it builds an index beforehand. Good for *really* big codebases.
* [Git-grep](http://git-scm.com/docs/git-grep) - As fast as Ag but only works on git repos.
+* [fzf](https://github.com/junegunn/fzf) - A command-line fuzzy finder
* [ripgrep](https://github.com/BurntSushi/ripgrep)
* [Sack](https://github.com/sampson-chen/sack) - A utility that wraps Ack and Ag. It removes a lot of repetition from searching and opening matching files.
diff -Nur a/src/ignore.c b/src/ignore.c
--- a/src/ignore.c 2018-08-07 14:43:51.000000000 +0800
+++ b/src/ignore.c 2020-07-05 03:27:44.000000000 +0800
@@ -20,6 +20,8 @@
const int fnmatch_flags = FNM_PATHNAME;
#endif
+ignores *root_ignores;
+
/* TODO: build a huge-ass list of files we want to ignore by default (build cache stuff, pyc files, etc) */
const char *evil_hardcoded_ignore_files[] = {
@@ -206,6 +208,7 @@
/* This is the hottest code in Ag. 10-15% of all execution time is spent here */
static int path_ignore_search(const ignores *ig, const char *path, const char *filename) {
char *temp;
+ int temp_start_pos;
size_t i;
int match_pos;
@@ -216,9 +219,12 @@
}
ag_asprintf(&temp, "%s/%s", path[0] == '.' ? path + 1 : path, filename);
+ //ig->abs_path has its leading slash stripped, so we have to strip the leading slash
+ //of temp as well
+ temp_start_pos = (temp[0] == '/') ? 1 : 0;
- if (strncmp(temp, ig->abs_path, ig->abs_path_len) == 0) {
- char *slash_filename = temp + ig->abs_path_len;
+ if (strncmp(temp + temp_start_pos, ig->abs_path, ig->abs_path_len) == 0) {
+ char *slash_filename = temp + temp_start_pos + ig->abs_path_len;
if (slash_filename[0] == '/') {
slash_filename++;
}
diff -Nur a/src/ignore.h b/src/ignore.h
--- a/src/ignore.h 2018-08-07 14:43:51.000000000 +0800
+++ b/src/ignore.h 2020-07-05 03:27:44.000000000 +0800
@@ -29,7 +29,7 @@
};
typedef struct ignores ignores;
-ignores *root_ignores;
+extern ignores *root_ignores;
extern const char *evil_hardcoded_ignore_files[];
extern const char *ignore_pattern_files[];
diff -Nur a/src/lang.c b/src/lang.c
--- a/src/lang.c 2018-08-07 14:43:51.000000000 +0800
+++ b/src/lang.c 2020-07-05 03:27:44.000000000 +0800
@@ -10,18 +10,22 @@
{ "asciidoc", { "adoc", "ad", "asc", "asciidoc" } },
{ "apl", { "apl" } },
{ "asm", { "asm", "s" } },
+ { "asp", { "asp", "asa", "aspx", "asax", "ashx", "ascx", "asmx" } },
+ { "aspx", { "asp", "asa", "aspx", "asax", "ashx", "ascx", "asmx" } },
{ "batch", { "bat", "cmd" } },
+ { "bazel", { "bazel" } },
{ "bitbake", { "bb", "bbappend", "bbclass", "inc" } },
- { "bro", { "bro", "bif" } },
{ "cc", { "c", "h", "xs" } },
{ "cfmx", { "cfc", "cfm", "cfml" } },
{ "chpl", { "chpl" } },
- { "clojure", { "clj", "cljs", "cljc", "cljx" } },
+ { "clojure", { "clj", "cljs", "cljc", "cljx", "edn" } },
{ "coffee", { "coffee", "cjsx" } },
+ { "config", { "config" } },
{ "coq", { "coq", "g", "v" } },
{ "cpp", { "cpp", "cc", "C", "cxx", "m", "hpp", "hh", "h", "H", "hxx", "tpp" } },
{ "crystal", { "cr", "ecr" } },
{ "csharp", { "cs" } },
+ { "cshtml", { "cshtml" } },
{ "css", { "css" } },
{ "cython", { "pyx", "pxd", "pxi" } },
{ "delphi", { "pas", "int", "dfm", "nfm", "dof", "dpk", "dpr", "dproj", "groupproj", "bdsgroup", "bdsproj" } },
@@ -34,11 +38,12 @@
{ "elm", { "elm" } },
{ "erlang", { "erl", "hrl" } },
{ "factor", { "factor" } },
- { "fortran", { "f", "f77", "f90", "f95", "f03", "for", "ftn", "fpp" } },
+ { "fortran", { "f", "F", "f77", "f90", "F90", "f95", "f03", "for", "ftn", "fpp", "FPP" } },
{ "fsharp", { "fs", "fsi", "fsx" } },
{ "gettext", { "po", "pot", "mo" } },
{ "glsl", { "vert", "tesc", "tese", "geom", "frag", "comp" } },
{ "go", { "go" } },
+ { "gradle", { "gradle" } },
{ "groovy", { "groovy", "gtmpl", "gpp", "grunit", "gradle" } },
{ "haml", { "haml" } },
{ "handlebars", { "hbs" } },
@@ -88,13 +93,16 @@
{ "pike", { "pike", "pmod" } },
{ "plist", { "plist" } },
{ "plone", { "pt", "cpt", "metadata", "cpy", "py", "xml", "zcml" } },
+ { "powershell", { "ps1" } },
{ "proto", { "proto" } },
+ { "ps1", { "ps1" } },
{ "pug", { "pug" } },
{ "puppet", { "pp" } },
{ "python", { "py" } },
{ "qml", { "qml" } },
{ "racket", { "rkt", "ss", "scm" } },
{ "rake", { "Rakefile" } },
+ { "razor", { "cshtml" } },
{ "restructuredtext", { "rst" } },
{ "rs", { "rs" } },
{ "r", { "r", "R", "Rmd", "Rnw", "Rtex", "Rrst" } },
@@ -124,14 +132,17 @@
{ "vala", { "vala", "vapi" } },
{ "vb", { "bas", "cls", "frm", "ctl", "vb", "resx" } },
{ "velocity", { "vm", "vtl", "vsl" } },
- { "verilog", { "v", "vh", "sv" } },
+ { "verilog", { "v", "vh", "sv", "svh" } },
{ "vhdl", { "vhd", "vhdl" } },
{ "vim", { "vim" } },
+ { "vue", { "vue" } },
{ "wix", { "wxi", "wxs" } },
{ "wsdl", { "wsdl" } },
{ "wadl", { "wadl" } },
- { "xml", { "xml", "dtd", "xsl", "xslt", "ent", "tld", "plist" } },
- { "yaml", { "yaml", "yml" } }
+ { "xml", { "xml", "dtd", "xsl", "xslt", "xsd", "ent", "tld", "plist", "wsdl" } },
+ { "yaml", { "yaml", "yml" } },
+ { "zeek", { "zeek", "bro", "bif" } },
+ { "zephir", { "zep" } }
};
size_t get_lang_count() {
diff -Nur a/src/log.c b/src/log.c
--- a/src/log.c 2018-08-07 14:43:51.000000000 +0800
+++ b/src/log.c 2020-07-05 03:27:44.000000000 +0800
@@ -4,6 +4,7 @@
#include "log.h"
#include "util.h"
+pthread_mutex_t print_mtx = PTHREAD_MUTEX_INITIALIZER;
static enum log_level log_threshold = LOG_LEVEL_ERR;
void set_log_level(enum log_level threshold) {
diff -Nur a/src/log.h b/src/log.h
--- a/src/log.h 2018-08-07 14:43:51.000000000 +0800
+++ b/src/log.h 2020-07-05 03:27:44.000000000 +0800
@@ -9,7 +9,7 @@
#include <pthread.h>
#endif
-pthread_mutex_t print_mtx;
+extern pthread_mutex_t print_mtx;
enum log_level {
LOG_LEVEL_DEBUG = 10,
diff -Nur a/src/main.c b/src/main.c
--- a/src/main.c 2018-08-07 14:43:51.000000000 +0800
+++ b/src/main.c 2020-07-05 03:27:44.000000000 +0800
@@ -154,7 +154,7 @@
}
#if defined(HAVE_PTHREAD_SETAFFINITY_NP) && (defined(USE_CPU_SET) || defined(HAVE_SYS_CPUSET_H))
if (opts.use_thread_affinity) {
-#ifdef __linux__
+#if defined(__linux__) || defined(__midipix__)
cpu_set_t cpu_set;
#elif __FreeBSD__
cpuset_t cpu_set;
diff -Nur a/src/options.c b/src/options.c
--- a/src/options.c 2018-08-07 14:43:51.000000000 +0800
+++ b/src/options.c 2020-07-05 03:27:44.000000000 +0800
@@ -20,6 +20,8 @@
const char *color_match = "\033[30;43m"; /* black with yellow background */
const char *color_path = "\033[1;32m"; /* bold green */
+cli_options opts;
+
/* TODO: try to obey out_fd? */
void usage(void) {
printf("\n");
@@ -143,9 +145,14 @@
}
void init_options(void) {
+ char *term = getenv("TERM");
+
memset(&opts, 0, sizeof(opts));
opts.casing = CASE_DEFAULT;
opts.color = TRUE;
+ if (term && !strcmp(term, "dumb")) {
+ opts.color = FALSE;
+ }
opts.color_win_ansi = FALSE;
opts.max_matches_per_file = 0;
opts.max_search_depth = DEFAULT_MAX_SEARCH_DEPTH;
@@ -446,8 +453,9 @@
opts.casing = CASE_INSENSITIVE;
break;
case 'L':
- opts.invert_match = 1;
- /* fall through */
+ opts.print_nonmatching_files = 1;
+ opts.print_path = PATH_PRINT_TOP;
+ break;
case 'l':
needs_query = 0;
opts.print_filename_only = 1;
@@ -705,8 +713,10 @@
const char *config_home = getenv("XDG_CONFIG_HOME");
if (config_home) {
ag_asprintf(&gitconfig_res, "%s/%s", config_home, "git/ignore");
- } else {
+ } else if (home_dir) {
ag_asprintf(&gitconfig_res, "%s/%s", home_dir, ".config/git/ignore");
+ } else {
+ gitconfig_res = ag_strdup("");
}
}
log_debug("global core.excludesfile: %s", gitconfig_res);
diff -Nur a/src/options.h b/src/options.h
--- a/src/options.h 2018-08-07 14:43:51.000000000 +0800
+++ b/src/options.h 2020-07-05 03:27:44.000000000 +0800
@@ -60,6 +60,7 @@
int print_break;
int print_count;
int print_filename_only;
+ int print_nonmatching_files;
int print_path;
int print_all_paths;
int print_line_numbers;
@@ -91,7 +92,7 @@
} cli_options;
/* global options. parse_options gives it sane values, everything else reads from it */
-cli_options opts;
+extern cli_options opts;
typedef struct option option_t;
diff -Nur a/src/search.c b/src/search.c
--- a/src/search.c 2018-08-07 14:43:51.000000000 +0800
+++ b/src/search.c 2020-07-05 03:27:44.000000000 +0800
@@ -2,8 +2,22 @@
#include "print.h"
#include "scandir.h"
-void search_buf(const char *buf, const size_t buf_len,
- const char *dir_full_path) {
+size_t alpha_skip_lookup[256];
+size_t *find_skip_lookup;
+uint8_t h_table[H_SIZE] __attribute__((aligned(64)));
+
+work_queue_t *work_queue = NULL;
+work_queue_t *work_queue_tail = NULL;
+int done_adding_files = 0;
+pthread_cond_t files_ready = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t stats_mtx = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t work_queue_mtx = PTHREAD_MUTEX_INITIALIZER;
+
+symdir_t *symhash = NULL;
+
+/* Returns: -1 if skipped, otherwise # of matches */
+ssize_t search_buf(const char *buf, const size_t buf_len,
+ const char *dir_full_path) {
int binary = -1; /* 1 = yes, 0 = no, -1 = don't know */
size_t buf_offset = 0;
@@ -13,7 +27,7 @@
binary = is_binary((const void *)buf, buf_len);
if (binary) {
log_debug("File %s is binary. Skipping...", dir_full_path);
- return;
+ return -1;
}
}
@@ -174,25 +188,16 @@
pthread_mutex_unlock(&stats_mtx);
}
- if (matches_len > 0 || opts.print_all_paths) {
+ if (!opts.print_nonmatching_files && (matches_len > 0 || opts.print_all_paths)) {
if (binary == -1 && !opts.print_filename_only) {
binary = is_binary((const void *)buf, buf_len);
}
pthread_mutex_lock(&print_mtx);
if (opts.print_filename_only) {
- /* If the --files-without-matches or -L option is passed we should
- * not print a matching line. This option currently sets
- * opts.print_filename_only and opts.invert_match. Unfortunately
- * setting the latter has the side effect of making matches.len = 1
- * on a file-without-matches which is not desired behaviour. See
- * GitHub issue 206 for the consequences if this behaviour is not
- * checked. */
- if (!opts.invert_match || matches_len < 2) {
- if (opts.print_count) {
- print_path_count(dir_full_path, opts.path_sep, (size_t)matches_len);
- } else {
- print_path(dir_full_path, opts.path_sep);
- }
+ if (opts.print_count) {
+ print_path_count(dir_full_path, opts.path_sep, (size_t)matches_len);
+ } else {
+ print_path(dir_full_path, opts.path_sep);
}
} else if (binary) {
print_binary_file_matches(dir_full_path);
@@ -214,11 +219,16 @@
if (matches_size > 0) {
free(matches);
}
+
+ /* FIXME: handle case where matches_len > SSIZE_MAX */
+ return (ssize_t)matches_len;
}
+/* Return value: -1 if skipped, otherwise # of matches */
/* TODO: this will only match single lines. multi-line regexes silently don't match */
-void search_stream(FILE *stream, const char *path) {
+ssize_t search_stream(FILE *stream, const char *path) {
char *line = NULL;
+ ssize_t matches_count = 0;
ssize_t line_len = 0;
size_t line_cap = 0;
size_t i;
@@ -226,8 +236,17 @@
print_init_context();
for (i = 1; (line_len = getline(&line, &line_cap, stream)) > 0; i++) {
+ ssize_t result;
opts.stream_line_num = i;
- search_buf(line, line_len, path);
+ result = search_buf(line, line_len, path);
+ if (result > 0) {
+ if (matches_count == -1) {
+ matches_count = 0;
+ }
+ matches_count += result;
+ } else if (matches_count <= 0 && result == -1) {
+ matches_count = -1;
+ }
if (line[line_len - 1] == '\n') {
line_len--;
}
@@ -236,6 +255,7 @@
free(line);
print_cleanup_context();
+ return matches_count;
}
void search_file(const char *file_full_path) {
@@ -244,6 +264,7 @@
char *buf = NULL;
struct stat statbuf;
int rv = 0;
+ int matches_count = -1;
FILE *fp = NULL;
rv = stat(file_full_path, &statbuf);
@@ -293,7 +314,7 @@
if (statbuf.st_mode & S_IFIFO) {
log_debug("%s is a named pipe. stream searching", file_full_path);
fp = fdopen(fd, "r");
- search_stream(fp, file_full_path);
+ matches_count = search_stream(fp, file_full_path);
fclose(fp);
goto cleanup;
}
@@ -302,7 +323,7 @@
if (f_len == 0) {
if (opts.query[0] == '.' && opts.query_len == 1 && !opts.literal && opts.search_all_files) {
- search_buf(buf, f_len, file_full_path);
+ matches_count = search_buf(buf, f_len, file_full_path);
} else {
log_debug("Skipping %s: file is empty.", file_full_path);
}
@@ -374,7 +395,7 @@
#if HAVE_FOPENCOOKIE
log_debug("%s is a compressed file. stream searching", file_full_path);
fp = decompress_open(fd, "r", zip_type);
- search_stream(fp, file_full_path);
+ matches_count = search_stream(fp, file_full_path);
fclose(fp);
#else
int _buf_len = (int)f_len;
@@ -383,17 +404,24 @@
log_err("Cannot decompress zipped file %s", file_full_path);
goto cleanup;
}
- search_buf(_buf, _buf_len, file_full_path);
+ matches_count = search_buf(_buf, _buf_len, file_full_path);
free(_buf);
#endif
goto cleanup;
}
}
- search_buf(buf, f_len, file_full_path);
+ matches_count = search_buf(buf, f_len, file_full_path);
cleanup:
+ if (opts.print_nonmatching_files && matches_count == 0) {
+ pthread_mutex_lock(&print_mtx);
+ print_path(file_full_path, opts.path_sep);
+ pthread_mutex_unlock(&print_mtx);
+ opts.match_found = 1;
+ }
+
print_cleanup_context();
if (buf != NULL) {
#ifdef _WIN32
diff -Nur a/src/search.h b/src/search.h
--- a/src/search.h 2018-08-07 14:43:51.000000000 +0800
+++ b/src/search.h 2020-07-05 03:27:44.000000000 +0800
@@ -31,9 +31,9 @@
#include "uthash.h"
#include "util.h"
-size_t alpha_skip_lookup[256];
-size_t *find_skip_lookup;
-uint8_t h_table[H_SIZE] __attribute__((aligned(64)));
+extern size_t alpha_skip_lookup[256];
+extern size_t *find_skip_lookup;
+extern uint8_t h_table[H_SIZE] __attribute__((aligned(64)));
struct work_queue_t {
char *path;
@@ -41,12 +41,12 @@
};
typedef struct work_queue_t work_queue_t;
-work_queue_t *work_queue;
-work_queue_t *work_queue_tail;
-int done_adding_files;
-pthread_cond_t files_ready;
-pthread_mutex_t stats_mtx;
-pthread_mutex_t work_queue_mtx;
+extern work_queue_t *work_queue;
+extern work_queue_t *work_queue_tail;
+extern int done_adding_files;
+extern pthread_cond_t files_ready;
+extern pthread_mutex_t stats_mtx;
+extern pthread_mutex_t work_queue_mtx;
/* For symlink loop detection */
@@ -64,11 +64,11 @@
UT_hash_handle hh;
} symdir_t;
-symdir_t *symhash;
+extern symdir_t *symhash;
-void search_buf(const char *buf, const size_t buf_len,
- const char *dir_full_path);
-void search_stream(FILE *stream, const char *path);
+ssize_t search_buf(const char *buf, const size_t buf_len,
+ const char *dir_full_path);
+ssize_t search_stream(FILE *stream, const char *path);
void search_file(const char *file_full_path);
void *search_file_worker(void *i);
diff -Nur a/src/util.c b/src/util.c
--- a/src/util.c 2018-08-07 14:43:51.000000000 +0800
+++ b/src/util.c 2020-07-05 03:27:44.000000000 +0800
@@ -21,6 +21,8 @@
} \
return ptr;
+FILE *out_fd = NULL;
+ag_stats stats;
void *ag_malloc(size_t size) {
void *ptr = malloc(size);
CHECK_AND_RETURN(ptr)
@@ -516,7 +518,7 @@
int is_named_pipe(const char *path, const struct dirent *d) {
#ifdef HAVE_DIRENT_DTYPE
- if (d->d_type != DT_UNKNOWN) {
+ if (d->d_type != DT_UNKNOWN && d->d_type != DT_LNK) {
return d->d_type == DT_FIFO || d->d_type == DT_SOCK;
}
#endif
diff -Nur a/src/util.h b/src/util.h
--- a/src/util.h 2018-08-07 14:43:51.000000000 +0800
+++ b/src/util.h 2020-07-05 03:27:44.000000000 +0800
@@ -12,7 +12,7 @@
#include "log.h"
#include "options.h"
-FILE *out_fd;
+extern FILE *out_fd;
#ifndef TRUE
#define TRUE 1
@@ -51,7 +51,7 @@
} ag_stats;
-ag_stats stats;
+extern ag_stats stats;
/* Union to translate between chars and words without violating strict aliasing */
typedef union {
diff -Nur a/tests/empty_environment.t b/tests/empty_environment.t
--- a/tests/empty_environment.t 1970-01-01 08:00:00.000000000 +0800
+++ b/tests/empty_environment.t 2020-07-05 03:27:44.000000000 +0800
@@ -0,0 +1,9 @@
+Setup:
+
+ $ . $TESTDIR/setup.sh
+ $ printf "hello world\n" >test.txt
+
+Verify ag runs with an empty environment:
+
+ $ env -i $TESTDIR/../ag --noaffinity --nocolor --workers=1 --parallel hello
+ test.txt:1:hello world
diff -Nur a/tests/files_with_matches.t b/tests/files_with_matches.t
--- a/tests/files_with_matches.t 2018-08-07 14:43:51.000000000 +0800
+++ b/tests/files_with_matches.t 2020-07-05 03:27:44.000000000 +0800
@@ -3,6 +3,10 @@
$ . $TESTDIR/setup.sh
$ printf 'foo\n' > ./foo.txt
$ printf 'bar\n' > ./bar.txt
+ $ printf 'foo\nbar\nbaz\n' > ./baz.txt
+ $ printf 'duck\nanother duck\nyet another duck\n' > ./duck.txt
+ $ cp duck.txt goose.txt
+ $ echo "GOOSE!!!" >> ./goose.txt
Files with matches:
@@ -12,8 +16,17 @@
foo.txt
$ ag --files-with-matches foo bar.txt
[1]
+ $ ag --files-with-matches foo foo.txt bar.txt baz.txt
+ foo.txt
+ baz.txt
+ $ ag --files-with-matches bar foo.txt bar.txt baz.txt
+ bar.txt
+ baz.txt
+ $ ag --files-with-matches foo bar.txt baz.txt
+ baz.txt
Files without matches:
+(Prints names of files in which no line matches query)
$ ag --files-without-matches bar foo.txt
foo.txt
@@ -21,3 +34,30 @@
foo.txt
$ ag --files-without-matches bar bar.txt
[1]
+ $ ag --files-without-matches foo foo.txt bar.txt baz.txt
+ bar.txt
+ $ ag --files-without-matches bar foo.txt bar.txt baz.txt
+ foo.txt
+
+Files with inverted matches:
+(Prints names of files in which some line doesn't match query)
+
+ $ ag --files-with-matches --invert-match bar bar.txt
+ [1]
+ $ ag --files-with-matches --invert-match foo foo.txt bar.txt baz.txt
+ bar.txt
+ baz.txt
+ $ ag --files-with-matches --invert-match bar foo.txt bar.txt baz.txt
+ foo.txt
+ baz.txt
+
+Files without inverted matches:
+(Prints names of files in which no line doesn't match query,
+ i.e. where every line matches query)
+
+ $ ag --files-without-matches --invert-match duck duck.txt
+ duck.txt
+ $ ag --files-without-matches --invert-match duck goose.txt
+ [1]
+ $ ag --files-without-matches --invert-match duck duck.txt goose.txt
+ duck.txt
diff -Nur a/tests/ignore_slash_in_subdir.t b/tests/ignore_slash_in_subdir.t
--- a/tests/ignore_slash_in_subdir.t 1970-01-01 08:00:00.000000000 +0800
+++ b/tests/ignore_slash_in_subdir.t 2020-07-05 03:27:44.000000000 +0800
@@ -0,0 +1,19 @@
+Setup:
+
+ $ . $TESTDIR/setup.sh
+ $ mkdir -p subdir/ignoredir
+ $ mkdir ignoredir
+ $ printf 'match1\n' > subdir/ignoredir/file1.txt
+ $ printf 'match1\n' > ignoredir/file1.txt
+ $ printf '/ignoredir\n' > subdir/.ignore
+
+Ignore file in subdir/ignoredir, but not in ignoredir:
+
+ $ ag match
+ ignoredir/file1.txt:1:match1
+
+From subdir, ignore file in subdir/ignoredir:
+
+ $ cd subdir
+ $ ag match
+ [1]
diff -Nur a/tests/list_file_types.t b/tests/list_file_types.t
--- a/tests/list_file_types.t 2018-08-07 14:43:51.000000000 +0800
+++ b/tests/list_file_types.t 2020-07-05 03:27:44.000000000 +0800
@@ -21,15 +21,21 @@
--asm
.asm .s
+ --asp
+ .asp .asa .aspx .asax .ashx .ascx .asmx
+
+ --aspx
+ .asp .asa .aspx .asax .ashx .ascx .asmx
+
--batch
.bat .cmd
+ --bazel
+ .bazel
+
--bitbake
.bb .bbappend .bbclass .inc
- --bro
- .bro .bif
-
--cc
.c .h .xs
@@ -40,11 +46,14 @@
.chpl
--clojure
- .clj .cljs .cljc .cljx
+ .clj .cljs .cljc .cljx .edn
--coffee
.coffee .cjsx
+ --config
+ .config
+
--coq
.coq .g .v
@@ -57,6 +66,9 @@
--csharp
.cs
+ --cshtml
+ .cshtml
+
--css
.css
@@ -94,7 +106,7 @@
.factor
--fortran
- .f .f77 .f90 .f95 .f03 .for .ftn .fpp
+ .f .F .f77 .f90 .F90 .f95 .f03 .for .ftn .fpp .FPP
--fsharp
.fs .fsi .fsx
@@ -108,6 +120,9 @@
--go
.go
+ --gradle
+ .gradle
+
--groovy
.groovy .gtmpl .gpp .grunit .gradle
@@ -255,9 +270,15 @@
--plone
.pt .cpt .metadata .cpy .py .xml .zcml
+ --powershell
+ .ps1
+
--proto
.proto
+ --ps1
+ .ps1
+
--pug
.pug
@@ -276,6 +297,9 @@
--rake
.Rakefile
+ --razor
+ .cshtml
+
--restructuredtext
.rst
@@ -364,7 +388,7 @@
.vm .vtl .vsl
--verilog
- .v .vh .sv
+ .v .vh .sv .svh
--vhdl
.vhd .vhdl
@@ -372,6 +396,9 @@
--vim
.vim
+ --vue
+ .vue
+
--wix
.wxi .wxs
@@ -382,8 +409,14 @@
.wadl
--xml
- .xml .dtd .xsl .xslt .ent .tld .plist
+ .xml .dtd .xsl .xslt .xsd .ent .tld .plist .wsdl
--yaml
.yaml .yml
+ --zeek
+ .zeek .bro .bif
+
+ --zephir
+ .zep
+
\ No newline at end of file
diff -Nur a/the_silver_searcher.spec.in b/the_silver_searcher.spec.in
--- a/the_silver_searcher.spec.in 2018-08-07 14:43:51.000000000 +0800
+++ b/the_silver_searcher.spec.in 2020-07-05 03:27:44.000000000 +0800
@@ -1,5 +1,5 @@
%define _bashcompdir %_sysconfdir/bash_completion.d
-
+%define _zshcompdir %{_datadir}/zsh/site-functions
Name: the_silver_searcher
Version: @VERSION@
@@ -62,7 +62,7 @@
%{_mandir}/*
%config %{_bashcompdir}/ag.bashcomp.sh
%config %{_datadir}/%{name}/completions/ag.bashcomp.sh
-
+%config %{_datadir}/zsh/site-functions/_the_silver_searcher
%changelog
* Thu Dec 5 2013 Emily Strickland <code@emily.st> - 0.18.1-1
diff -Nur a/.travis.yml b/.travis.yml
--- a/.travis.yml 2018-08-07 14:43:51.000000000 +0800
+++ b/.travis.yml 2020-07-05 03:27:44.000000000 +0800
@@ -1,4 +1,5 @@
language: c
+dist: xenial
sudo: false
branches:
@@ -22,12 +23,12 @@
env:
global:
- - LLVM_VERSION=3.8.0
+ - LLVM_VERSION=6.0.1
- LLVM_PATH=$HOME/clang+llvm
- CLANG_FORMAT=$LLVM_PATH/bin/clang-format
before_install:
- - wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O $LLVM_PATH.tar.xz
+ - wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-16.04.tar.xz -O $LLVM_PATH.tar.xz
- mkdir $LLVM_PATH
- tar xf $LLVM_PATH.tar.xz -C $LLVM_PATH --strip-components=1
- export PATH=$HOME/.local/bin:$PATH
@@ -37,3 +38,9 @@
script:
- ./build.sh && make test
+
+notifications:
+ irc: 'chat.freenode.net#ag'
+ on_success: change
+ on_failure: always
+ use_notice: true