]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ignore: note info/exclude lives in GIT_COMMON_DIR, not GIT_DIR
authorD. Ben Knoble <ben.knoble+github@gmail.com>
Tue, 12 May 2026 21:21:43 +0000 (17:21 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 13 May 2026 01:25:52 +0000 (10:25 +0900)
gitignore(5) says that the per-repository ignore file is
$GIT_DIR/info/exclude, but in a worktree that is not the case:

    git rev-parse --git-path info/exclude
    /path/to/main/worktree/.git/info/exclude
    git rev-parse --git-common-dir
    /path/to/main/worktree/.git

We actually use $GIT_COMMON_DIR/info/exclude. Adjust the documentation
and some code comments to say so.

Signed-off-by: D. Ben Knoble <ben.knoble+github@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-ls-files.adoc
Documentation/git-svn.adoc
Documentation/gitformat-index.adoc
Documentation/gitignore.adoc
dir.c
dir.h

index 58c529afbee4c5534cf34f3250161f2eeddf254f..2b175388e1c84444a0a4eae26c61cf1e68332751 100644 (file)
@@ -331,7 +331,7 @@ can give `--exclude-per-directory=.gitignore`, and then specify:
   1. The file specified by the `core.excludesfile` configuration
      variable, if exists, or the `$XDG_CONFIG_HOME/git/ignore` file.
 
-  2. The `$GIT_DIR/info/exclude` file.
+  2. The `$GIT_COMMON_DIR/info/exclude` file.
 
 via the `--exclude-from=` option.
 
index c26c12bab37abfd01a29395ed39b2df3a46cb2d7..2a7fa60465c5fbd4ba9d02db65ca5595e8ecfc64 100644 (file)
@@ -439,7 +439,7 @@ Any other arguments are passed directly to 'git log'
 'show-ignore'::
        Recursively finds and lists the svn:ignore and svn:global-ignores
        properties on directories. The output is suitable for appending to
-       the $GIT_DIR/info/exclude file.
+       the $GIT_COMMON_DIR/info/exclude file.
 
 'mkdirs'::
        Attempts to recreate empty directories that core Git cannot track
index 145cace1fe9fd3a583aaa7c0f605b64b78ef7554..f6a427cb495990ba0818eec41fe837b326725d4e 100644 (file)
@@ -291,14 +291,14 @@ Git index format
     sequence in variable width encoding. Each string describes the
     environment where the cache can be used.
 
-  - Stat data of $GIT_DIR/info/exclude. See "Index entry" section from
+  - Stat data of $GIT_COMMON_DIR/info/exclude. See "Index entry" section from
     ctime field until "file size".
 
   - Stat data of core.excludesFile
 
   - 32-bit dir_flags (see struct dir_struct)
 
-  - Hash of $GIT_DIR/info/exclude. A null hash means the file
+  - Hash of $GIT_COMMON_DIR/info/exclude. A null hash means the file
     does not exist.
 
   - Hash of core.excludesFile. A null hash means the file does
index a3d24e5c34aabc1b2f2776b77296768ef6da1c22..7979e50f187e2362082f08632cc11c45d975d817 100644 (file)
@@ -7,7 +7,7 @@ gitignore - Specifies intentionally untracked files to ignore
 
 SYNOPSIS
 --------
-$XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore
+$XDG_CONFIG_HOME/git/ignore, $GIT_COMMON_DIR/info/exclude, .gitignore
 
 DESCRIPTION
 -----------
@@ -34,7 +34,7 @@ precedence, the last matching pattern decides the outcome):
    includes such `.gitignore` files in its repository, containing patterns for
    files generated as part of the project build.
 
- * Patterns read from `$GIT_DIR/info/exclude`.
+ * Patterns read from `$GIT_COMMON_DIR/info/exclude`.
 
  * Patterns read from the file specified by the configuration
    variable `core.excludesFile`.
@@ -50,7 +50,7 @@ be used.
    specific to a particular repository but which do not need to be shared
    with other related repositories (e.g., auxiliary files that live inside
    the repository but are specific to one user's workflow) should go into
-   the `$GIT_DIR/info/exclude` file.
+   the `$GIT_COMMON_DIR/info/exclude` file.
 
  * Patterns which a user wants Git to
    ignore in all situations (e.g., backup or temporary files generated by
@@ -97,7 +97,7 @@ PATTERN FORMAT
    match at any level below the `.gitignore` level.
 
  - Patterns read from exclude sources that are outside the working tree,
-   such as $GIT_DIR/info/exclude and core.excludesFile, are treated as if
+   such as $GIT_COMMON_DIR/info/exclude and core.excludesFile, are treated as if
    they are specified at the root of the working tree, i.e. a leading "/"
    in such patterns anchors the match at the root of the repository.
 
@@ -146,8 +146,8 @@ CONFIGURATION
 
 The optional configuration variable `core.excludesFile` indicates a path to a
 file containing patterns of file names to exclude, similar to
-`$GIT_DIR/info/exclude`.  Patterns in the exclude file are used in addition to
-those in `$GIT_DIR/info/exclude`.
+`$GIT_COMMON_DIR/info/exclude`. Patterns in the exclude file are used in
+addition to those in `$GIT_COMMON_DIR/info/exclude`.
 
 NOTES
 -----
diff --git a/dir.c b/dir.c
index fcb8f6dd2aa96938cb79af05603cd78d25ead58c..33c81c256ee925862b9f1e9651194cfd497e6cff 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -2985,7 +2985,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
                return NULL;
 
        /*
-        * We only support $GIT_DIR/info/exclude and core.excludesfile
+        * We only support $GIT_COMMON_DIR/info/exclude and core.excludesfile
         * as the global ignore rule files. Any other additions
         * (e.g. from command line) invalidate the cache. This
         * condition also catches running setup_standard_excludes()
@@ -3078,7 +3078,7 @@ static struct untracked_cache_dir *validate_untracked_cache(struct dir_struct *d
                istate->cache_changed |= UNTRACKED_CHANGED;
        }
 
-       /* Validate $GIT_DIR/info/exclude and core.excludesfile */
+       /* Validate $GIT_COMMON_DIR/info/exclude and core.excludesfile */
        root = dir->untracked->root;
        if (!oideq(&dir->internal.ss_info_exclude.oid,
                   &dir->untracked->ss_info_exclude.oid)) {
diff --git a/dir.h b/dir.h
index 20d4a078d61ef8851c668b37d250860fc5d6f677..83e0f648a81f362e0a9366063703f9fb603582a6 100644 (file)
--- a/dir.h
+++ b/dir.h
@@ -153,7 +153,7 @@ struct oid_stat {
  *   - The list of files and directories of the directory in question
  *   - The $GIT_DIR/index
  *   - dir_struct flags
- *   - The content of $GIT_DIR/info/exclude
+ *   - The content of $GIT_COMMON_DIR/info/exclude
  *   - The content of core.excludesfile
  *   - The content (or the lack) of .gitignore of all parent directories
  *     from $GIT_WORK_TREE