Merge branch 'jl/submodule-ignore-diff' · wolfpython/git@cc34bb0 · GitHub
Skip to content

Commit cc34bb0

Browse files
committed
Merge branch 'jl/submodule-ignore-diff'
* jl/submodule-ignore-diff: Add tests for the diff.ignoreSubmodules config option Add the 'diff.ignoreSubmodules' config setting Submodules: Use "ignore" settings from .gitmodules too for diff and status Submodules: Add the new "ignore" config option for diff and status Conflicts: diff.c
2 parents 06d11b2 + 90e1452 commit cc34bb0

17 files changed

Lines changed: 526 additions & 21 deletions

Documentation/config.txt

Lines changed: 18 additions & 0 deletions

Documentation/diff-options.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,11 @@ endif::git-format-patch[]
355355

356356
--ignore-submodules[=<when>]::
357357
Ignore changes to submodules in the diff generation. <when> can be
358-
either "untracked", "dirty" or "all", which is the default. When
358+
either "none", "untracked", "dirty" or "all", which is the default
359+
Using "none" will consider the submodule modified when it either contains
360+
untracked or modified files or its HEAD differs from the commit recorded
361+
in the superproject and can be used to override any settings of the
362+
'ignore' option in linkgit:git-config[1] or linkgit:gitmodules[5]. When
359363
"untracked" is used submodules are not considered dirty when they only
360364
contain untracked content (but they are still scanned for modified
361365
content). Using "dirty" ignores all changes to the work tree of submodules,

Documentation/git-status.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ specified.
5555

5656
--ignore-submodules[=<when>]::
5757
Ignore changes to submodules when looking for changes. <when> can be
58-
either "untracked", "dirty" or "all", which is the default. When
58+
either "none", "untracked", "dirty" or "all", which is the default.
59+
Using "none" will consider the submodule modified when it either contains
60+
untracked or modified files or its HEAD differs from the commit recorded
61+
in the superproject and can be used to override any settings of the
62+
'ignore' option in linkgit:git-config[1] or linkgit:gitmodules[5]. When
5963
"untracked" is used submodules are not considered dirty when they only
6064
contain untracked content (but they are still scanned for modified
6165
content). Using "dirty" ignores all changes to the work tree of submodules,

Documentation/gitmodules.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ submodule.<name>.update::
4444
This config option is overridden if 'git submodule update' is given
4545
the '--merge' or '--rebase' options.
4646

47+
submodule.<name>.ignore::
48+
Defines under what circumstances "git status" and the diff family show
49+
a submodule as modified. When set to "all", it will never be considered
50+
modified, "dirty" will ignore all changes to the submodules work tree and
51+
takes only differences between the HEAD of the submodule and the commit
52+
recorded in the superproject into account. "untracked" will additionally
53+
let submodules with modified tracked files in their work tree show up.
54+
Using "none" (the default when this option is not set) also shows
55+
submodules that have untracked files in their work tree as changed.
56+
If this option is also present in the submodules entry in .git/config of
57+
the superproject, the setting there will override the one found in
58+
.gitmodules.
59+
Both settings can be overriden on the command line by using the
60+
"--ignore-submodule" option.
61+
4762

4863
EXAMPLES
4964
--------

builtin/commit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "rerere.h"
2626
#include "unpack-trees.h"
2727
#include "quote.h"
28+
#include "submodule.h"
2829

2930
static const char * const builtin_commit_usage[] = {
3031
"git commit [options] [--] <filepattern>...",
@@ -1073,6 +1074,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
10731074
status_format = STATUS_FORMAT_PORCELAIN;
10741075

10751076
wt_status_prepare(&s);
1077+
gitmodules_config();
10761078
git_config(git_status_config, &s);
10771079
in_merge = file_exists(git_path("MERGE_HEAD"));
10781080
argc = parse_options(argc, argv, prefix,

builtin/diff-files.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "commit.h"
99
#include "revision.h"
1010
#include "builtin.h"
11+
#include "submodule.h"
1112

1213
static const char diff_files_usage[] =
1314
"git diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
@@ -20,6 +21,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
2021
unsigned options = 0;
2122

2223
init_revisions(&rev, prefix);
24+
gitmodules_config();
2325
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
2426
rev.abbrev = 0;
2527

builtin/diff-index.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "commit.h"
44
#include "revision.h"
55
#include "builtin.h"
6+
#include "submodule.h"
67

78
static const char diff_cache_usage[] =
89
"git diff-index [-m] [--cached] "
@@ -17,6 +18,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
1718
int result;
1819

1920
init_revisions(&rev, prefix);
21+
gitmodules_config();
2022
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
2123
rev.abbrev = 0;
2224

builtin/diff-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "commit.h"
44
#include "log-tree.h"
55
#include "builtin.h"
6+
#include "submodule.h"
67

78
static struct rev_info log_tree_opt;
89

@@ -112,6 +113,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
112113
int read_stdin = 0;
113114

114115
init_revisions(opt, prefix);
116+
gitmodules_config();
115117
git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
116118
opt->abbrev = 0;
117119
opt->diff = 1;

builtin/diff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "revision.h"
1414
#include "log-tree.h"
1515
#include "builtin.h"
16+
#include "submodule.h"
1617

1718
struct blobinfo {
1819
unsigned char sha1[20];
@@ -279,6 +280,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
279280
*/
280281

281282
prefix = setup_git_directory_gently(&nongit);
283+
gitmodules_config();
282284
git_config(git_diff_ui_config, NULL);
283285

284286
if (diff_use_color_default == -1)

diff-lib.c

Lines changed: 10 additions & 5 deletions

0 commit comments

Comments
 (0)