summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6abd0fb)
raw | patch | inline | side by side (parent: 6abd0fb)
author | Lars Hjemli <hjemli@gmail.com> | |
Wed, 6 Jun 2007 09:13:01 +0000 (11:13 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 6 Jun 2007 09:49:08 +0000 (02:49 -0700) |
This is just a simple refactoring of modules_init() with no change in
functionality.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
functionality.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-submodule.sh | patch | blob | history |
diff --git a/git-submodule.sh b/git-submodule.sh
index 6ed5a6ced23d99794de56e326bd46438d8c64707..486d3b212484b2ac8d33f1fb8a1c65c6fded7dc5 100755 (executable)
--- a/git-submodule.sh
+++ b/git-submodule.sh
fi
}
+
+#
+# Clone a submodule
+#
+module_clone()
+{
+ path=$1
+ url=$2
+
+ # If there already is a directory at the submodule path,
+ # expect it to be empty (since that is the default checkout
+ # action) and try to remove it.
+ # Note: if $path is a symlink to a directory the test will
+ # succeed but the rmdir will fail. We might want to fix this.
+ if test -d "$path"
+ then
+ rmdir "$path" 2>/dev/null ||
+ die "Directory '$path' exist, but is neither empty nor a git repository"
+ fi
+
+ test -e "$path" &&
+ die "A file already exist at path '$path'"
+
+ git-clone -n "$url" "$path" ||
+ die "Clone of submodule '$path' failed"
+}
+
#
# Run clone + checkout on missing submodules
#
# repository
test -d "$path"/.git && continue
- # If there already is a directory at the submodule path,
- # expect it to be empty (since that is the default checkout
- # action) and try to remove it.
- # Note: if $path is a symlink to a directory the test will
- # succeed but the rmdir will fail. We might want to fix this.
- if test -d "$path"
- then
- rmdir "$path" 2>/dev/null ||
- die "Directory '$path' exist, but is neither empty nor a git repository"
- fi
-
- test -e "$path" &&
- die "A file already exist at path '$path'"
-
url=$(GIT_CONFIG=.gitmodules git-config module."$path".url)
test -z "$url" &&
die "No url found for submodule '$path' in .gitmodules"
# logical modulename (if present) as key. But this would need
# another fallback mechanism if the module wasn't named.
- git-clone -n "$url" "$path" ||
- die "Clone of submodule '$path' failed"
+ module_clone "$path" "$url" || exit
(unset GIT_DIR && cd "$path" && git-checkout -q "$sha1") ||
die "Checkout of submodule '$path' failed"