Skip to content

Commit

Permalink
Merge branch 'ab/submodule-add-f'
Browse files Browse the repository at this point in the history
* ab/submodule-add-f:
  git submodule: add submodules with git add -f <path>
  • Loading branch information
Junio C Hamano committed Jul 15, 2010
2 parents aa57328 + 31991b0 commit 8498657
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Documentation/git-submodule.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ is the superproject and submodule repositories will be kept
together in the same relative location, and only the
superproject's URL needs to be provided: git-submodule will correctly
locate the submodule using the relative URL in .gitmodules.
+
The submodule will be added with "git add --force <path>". I.e. git
doesn't care if the new path is in a `gitignore`. Your invocation of
"git submodule add" is considered enough to override it.

status::
Show the status of the submodules. This will print the SHA-1 of the
Expand Down
4 changes: 2 additions & 2 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ cmd_add()
) || die "Unable to checkout submodule '$path'"
fi

git add "$path" ||
git add --force "$path" ||
die "Failed to add submodule '$path'"

git config -f .gitmodules submodule."$path".path "$path" &&
git config -f .gitmodules submodule."$path".url "$repo" &&
git add .gitmodules ||
git add --force .gitmodules ||
die "Failed to register submodule '$path'"
}

Expand Down
24 changes: 23 additions & 1 deletion t/t7400-submodule-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit 8498657

Please sign in to comment.