summaryrefslogtreecommitdiff
path: root/t/t7400-submodule-basic.sh
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2010-07-05 17:33:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-07-05 18:53:59 (GMT)
commit31991b0260216d16f2e447e68bcabd9d9cce26ba (patch)
tree355fb9b508b657e3d6edbdbfe981d1ef2c2e98ae /t/t7400-submodule-basic.sh
parent45e9a825edf9064ff76f6ff10357fdc79497f0eb (diff)
downloadgit-31991b0260216d16f2e447e68bcabd9d9cce26ba.zip
git-31991b0260216d16f2e447e68bcabd9d9cce26ba.tar.gz
git-31991b0260216d16f2e447e68bcabd9d9cce26ba.tar.bz2
git submodule: add submodules with git add -f <path>
Change `git submodule add' to add the new submodule <path> with `git add --force'. I keep my /etc in .git with a .gitignore that contains just "*". I.e. `git status' will ignore everything that isn't in the tree already. When I do: git submodule add <url> hlagh git-submodule will get as far as checking out the remote repository into hlagh, but it'll die right afterwards when it fails to add the new path: The following paths are ignored by one of your .gitignore files: hlagh Use -f if you really want to add them. fatal: no files added Failed to add submodule 'hlagh' Currently there's no way to add a submodule in this situation other than to remove the ignored path from the .gitignore while I'm at it. That's silly, when you run `git submodule add' you're explicitly saying that you want to add something *new* to the repository. Instead it should just add the path with `git add --force'. Initially I implemented this by adding new -f and --force options to `git submodule add'. But if the --force option isn't supplied it'll get as far as cloning `hlagh', but won't add it. So the first thing the user has to do is to remove `hlagh' and then try again with the --force option. That sucks, it should just add the path to begin with. I can't think of any usecase where you've gone through the trouble of typing out `git submodule add ..', but wish to be overriden by a `gitignore'. The submodule semantics should be more like `git init', not `git add'. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7400-submodule-basic.sh')
-rwxr-xr-xt/t7400-submodule-basic.sh24
1 files changed, 23 insertions, 1 deletions
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 97ff074..d9f2785 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -42,7 +42,8 @@ test_expect_success 'setup - hide init subdirectory' '
'
test_expect_success 'setup - repository to add submodules to' '
- git init addtest
+ git init addtest &&
+ git init addtest-ignore
'
# The 'submodule add' tests need some repository to add as a submodule.
@@ -85,6 +86,27 @@ test_expect_success 'submodule add' '
test_cmp empty untracked
'
+test_expect_success 'submodule add to .gitignored path' '
+ echo "refs/heads/master" >expect &&
+ >empty &&
+
+ (
+ cd addtest-ignore &&
+ # Does not use test_commit due to the ignore
+ echo "*" > .gitignore &&
+ git add --force .gitignore &&
+ git commit -m"Ignore everything" &&
+ git submodule add "$submodurl" submod &&
+ git submodule init
+ ) &&
+
+ rm -f heads head untracked &&
+ inspect addtest/submod ../.. &&
+ test_cmp expect heads &&
+ test_cmp expect head &&
+ test_cmp empty untracked
+'
+
test_expect_success 'submodule add --branch' '
echo "refs/heads/initial" >expect-head &&
cat <<-\EOF >expect-heads &&