summaryrefslogtreecommitdiff
path: root/git-submodule.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-06-13 12:49:50 -0700
committerJunio C Hamano <gitster@pobox.com>2009-06-13 12:49:50 -0700
commit7d40f89137b456820d51ebc1cbb3ffbb966e7fec (patch)
tree7df8d4af9f00ed7ebb6023405db103a29a06f326 /git-submodule.sh
parent436f66b7e908d5ce2f292d1fd4e7f6f9de7c6fa1 (diff)
parent329484256e0fe42676e93669122e7a5a007ef4ed (diff)
downloadgit-7d40f89137b456820d51ebc1cbb3ffbb966e7fec.tar.gz
Merge branch 'ph/submodule-rebase' (early part)
* 'ph/submodule-rebase' (early part): Rename submodule.<name>.rebase to submodule.<name>.update git-submodule: add support for --rebase. Conflicts: Documentation/git-submodule.txt git-submodule.sh
Diffstat (limited to 'git-submodule.sh')
-rwxr-xr-xgit-submodule.sh35
1 files changed, 31 insertions, 4 deletions
diff --git a/git-submodule.sh b/git-submodule.sh
index ab1ed02a66..19a3a840fd 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -18,6 +18,7 @@ quiet=
reference=
cached=
nofetch=
+update=
#
# print stuff on stdout unless -q was specified
@@ -310,6 +311,11 @@ cmd_init()
git config submodule."$name".url "$url" ||
die "Failed to register url for submodule path '$path'"
+ upd="$(git config -f .gitmodules submodule."$name".update)"
+ test -z "$upd" ||
+ git config submodule."$name".update "$upd" ||
+ die "Failed to register update mode for submodule path '$path'"
+
say "Submodule '$name' ($url) registered for path '$path'"
done
}
@@ -337,6 +343,10 @@ cmd_update()
shift
nofetch=1
;;
+ -r|--rebase)
+ shift
+ update="rebase"
+ ;;
--reference)
case "$2" in '') usage ;; esac
reference="--reference=$2"
@@ -369,6 +379,7 @@ cmd_update()
do
name=$(module_name "$path") || exit
url=$(git config submodule."$name".url)
+ update_module=$(git config submodule."$name".update)
if test -z "$url"
then
# Only mention uninitialized submodules when its
@@ -389,6 +400,11 @@ cmd_update()
die "Unable to find current revision in submodule path '$path'"
fi
+ if ! test -z "$update"
+ then
+ update_module=$update
+ fi
+
if test "$subsha1" != "$sha1"
then
force=
@@ -404,11 +420,22 @@ cmd_update()
die "Unable to fetch in submodule path '$path'"
fi
- (unset GIT_DIR; cd "$path" &&
- git-checkout $force -q "$sha1") ||
- die "Unable to checkout '$sha1' in submodule path '$path'"
+ case "$update_module" in
+ rebase)
+ command="git rebase"
+ action="rebase"
+ msg="rebased onto"
+ ;;
+ *)
+ command="git checkout $force -q"
+ action="checkout"
+ msg="checked out"
+ ;;
+ esac
- say "Submodule path '$path': checked out '$sha1'"
+ (unset GIT_DIR; cd "$path" && $command "$sha1") ||
+ die "Unable to $action '$sha1' in submodule path '$path'"
+ say "Submodule path '$path': $msg '$sha1'"
fi
done
}