Skip to content

Commit

Permalink
Prefer $XDG_CONFIG_HOME/ag/ignore over ~/.agignore
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongable authored Jun 16, 2021
1 parent a61f178 commit 4f4c779
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ void parse_options(int argc, char **argv, char **base_paths[], char **paths[]) {
int opt_index = 0;
char *num_end;
const char *home_dir = getenv("HOME");
const char *config_dir = getenv("XDG_CONFIG_HOME");
char *ignore_file_path = NULL;
int accepts_query = 1;
int needs_query = 1;
Expand Down Expand Up @@ -685,10 +686,15 @@ void parse_options(int argc, char **argv, char **base_paths[], char **paths[]) {
exit(1);
}

if (home_dir && !opts.search_all_files) {
log_debug("Found user's home dir: %s", home_dir);
ag_asprintf(&ignore_file_path, "%s/.agignore", home_dir);
load_ignore_patterns(root_ignores, ignore_file_path);
if (!opts.search_all_files) {
if (config_home) {
ag_asprintf(&ignore_file_path, "%s/%s", config_home, "ag/ignore");
} else if (home_dir) {
ag_asprintf(&ignore_file_path, "%s/%s", home_dir, ".agignore");
}
if (ignore_file_path) {
load_ignore_patterns(root_ignores, ignore_file_path);
}
free(ignore_file_path);
}

Expand Down

0 comments on commit 4f4c779

Please sign in to comment.