@@ -6,6 +6,7 @@
#include "builtin.h"
#include "config.h"
+#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "lockfile.h"
@@ -65,7 +66,7 @@ static int exclude_per_directory_cb(const struct option *opt, const char *arg,
if (!opts->update)
die("--exclude-per-directory is meaningless unless -u");
- if (strcmp(arg, ".gitignore"))
+ if (strcmp(arg, GITIGNORE_FILE))
die("--exclude-per-directory argument must be .gitignore");
return 0;
}
@@ -2888,7 +2888,7 @@ static void new_untracked_cache(struct index_state *istate, int flags)
{
struct untracked_cache *uc = xcalloc(1, sizeof(*uc));
strbuf_init(&uc->ident, 100);
- uc->exclude_per_dir = ".gitignore";
+ uc->exclude_per_dir = GITIGNORE_FILE;
uc->dir_flags = flags >= 0 ? flags : new_untracked_cache_flags(istate);
set_untracked_ident(uc);
istate->untracked = uc;
@@ -3428,7 +3428,7 @@ static GIT_PATH_FUNC(git_path_info_exclude, "info/exclude")
void setup_standard_excludes(struct dir_struct *dir)
{
- dir->exclude_per_dir = ".gitignore";
+ dir->exclude_per_dir = GITIGNORE_FILE;
/* core.excludesfile defaulting to $XDG_CONFIG_HOME/git/ignore */
if (!excludes_file)
@@ -43,6 +43,7 @@ const char *getenv_safe(struct strvec *argv, const char *name);
#define GITMODULES_FILE ".gitmodules"
#define GITMODULES_INDEX ":.gitmodules"
#define GITMODULES_HEAD "HEAD:.gitmodules"
+#define GITIGNORE_FILE ".gitignore"
#define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF"
#define GIT_NOTES_DEFAULT_REF "refs/notes/commits"
#define GIT_NOTES_DISPLAY_REF_ENVIRONMENT "GIT_NOTES_DISPLAY_REF"
GITATTRIBUTES_FILE and GITMODULES_FILE have their own CPP macros that resolve to their string literals to help compilers catch typos. Add one for ".gitignore" as well. Signed-off-by: Junio C Hamano <gitster@pobox.com> --- builtin/read-tree.c | 3 ++- dir.c | 4 ++-- environment.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-)