File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ is the superproject and submodule repositories will be kept
95
95
together in the same relative location, and only the
96
96
superproject's URL needs to be provided: git-submodule will correctly
97
97
locate the submodule using the relative URL in .gitmodules.
98
+ +
99
+ The submodule will be added with "git add --force <path>". I.e. git
100
+ doesn't care if the new path is in a `gitignore`. Your invocation of
101
+ "git submodule add" is considered enough to override it.
98
102
99
103
status::
100
104
Show the status of the submodules. This will print the SHA-1 of the
Original file line number Diff line number Diff line change @@ -234,12 +234,12 @@ cmd_add()
234
234
) || die " Unable to checkout submodule '$path '"
235
235
fi
236
236
237
- git add " $path " ||
237
+ git add --force " $path " ||
238
238
die " Failed to add submodule '$path '"
239
239
240
240
git config -f .gitmodules submodule." $path " .path " $path " &&
241
241
git config -f .gitmodules submodule." $path " .url " $repo " &&
242
- git add .gitmodules ||
242
+ git add --force .gitmodules ||
243
243
die " Failed to register submodule '$path '"
244
244
}
245
245
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ test_expect_success 'setup - hide init subdirectory' '
42
42
'
43
43
44
44
test_expect_success ' setup - repository to add submodules to' '
45
- git init addtest
45
+ git init addtest &&
46
+ git init addtest-ignore
46
47
'
47
48
48
49
# The 'submodule add' tests need some repository to add as a submodule.
@@ -85,6 +86,27 @@ test_expect_success 'submodule add' '
85
86
test_cmp empty untracked
86
87
'
87
88
89
+ test_expect_success ' submodule add to .gitignored path' '
90
+ echo "refs/heads/master" >expect &&
91
+ >empty &&
92
+
93
+ (
94
+ cd addtest-ignore &&
95
+ # Does not use test_commit due to the ignore
96
+ echo "*" > .gitignore &&
97
+ git add --force .gitignore &&
98
+ git commit -m"Ignore everything" &&
99
+ git submodule add "$submodurl" submod &&
100
+ git submodule init
101
+ ) &&
102
+
103
+ rm -f heads head untracked &&
104
+ inspect addtest/submod ../.. &&
105
+ test_cmp expect heads &&
106
+ test_cmp expect head &&
107
+ test_cmp empty untracked
108
+ '
109
+
88
110
test_expect_success ' submodule add --branch' '
89
111
echo "refs/heads/initial" >expect-head &&
90
112
cat <<-\EOF >expect-heads &&
You can’t perform that action at this time.
0 commit comments