From: Junio C Hamano Date: Mon, 10 Oct 2011 22:56:16 +0000 (-0700) Subject: Merge branch 'fg/submodule-git-file-git-dir' X-Git-Tag: v1.7.8-rc0~115 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=efc5fb6a77780c53c6636326ca82ff87b17e4c5f;p=git.git Merge branch 'fg/submodule-git-file-git-dir' * fg/submodule-git-file-git-dir: Move git-dir for submodules rev-parse: add option --resolve-git-dir Conflicts: cache.h git-submodule.sh --- efc5fb6a77780c53c6636326ca82ff87b17e4c5f diff --cc cache.h index 82e12c862,55ae6976b..c989f7983 --- a/cache.h +++ b/cache.h @@@ -435,10 -434,9 +435,11 @@@ extern char *get_object_directory(void) extern char *get_index_file(void); extern char *get_graft_file(void); extern int set_git_dir(const char *path); +extern const char *get_git_namespace(void); +extern const char *strip_namespace(const char *namespaced_ref); extern const char *get_git_work_tree(void); -extern const char *read_gitfile_gently(const char *path); +extern const char *read_gitfile(const char *path); + extern const char *resolve_gitdir(const char *suspect); extern void set_git_work_tree(const char *tree); #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" diff --cc git-submodule.sh index 814d0d914,7576d1476..928a62f62 --- a/git-submodule.sh +++ b/git-submodule.sh @@@ -122,19 -122,49 +122,55 @@@ module_clone( path=$1 url=$2 reference="$3" + quiet= + if test -n "$GIT_QUIET" + then + quiet=-q + fi + - if test -n "$reference" + gitdir= + gitdir_base= + name=$(module_name "$path") + base_path=$(dirname "$path") + + gitdir=$(git rev-parse --git-dir) + gitdir_base="$gitdir/modules/$base_path" + gitdir="$gitdir/modules/$path" + + case $gitdir in + /*) + a="$(cd_to_toplevel && pwd)/" + b=$gitdir + while [ "$b" ] && [ "${a%%/*}" = "${b%%/*}" ] + do + a=${a#*/} b=${b#*/}; + done + + rel="$a$name" + rel=`echo $rel | sed -e 's|[^/]*|..|g'` + rel_gitdir="$rel/$b" + ;; + *) + rel=`echo $name | sed -e 's|[^/]*|..|g'` + rel_gitdir="$rel/$gitdir" + ;; + esac + + if test -d "$gitdir" then - git-clone $quiet "$reference" -n "$url" "$path" + mkdir -p "$path" + echo "gitdir: $rel_gitdir" >"$path/.git" + rm -f "$gitdir/index" else - git-clone $quiet -n "$url" "$path" - fi || - die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")" + mkdir -p "$gitdir_base" + if test -n "$reference" + then - git-clone "$reference" -n "$url" "$path" --separate-git-dir "$gitdir" ++ git-clone $quiet "$reference" -n "$url" "$path" --separate-git-dir "$gitdir" + else - git-clone -n "$url" "$path" --separate-git-dir "$gitdir" ++ git-clone $quiet -n "$url" "$path" --separate-git-dir "$gitdir" + fi || + die "$(eval_gettext "Clone of '\$url' into submodule path '\$path' failed")" + fi } # @@@ -426,6 -459,6 +462,9 @@@ cmd_update( --recursive) recursive=1 ;; ++ --checkout) ++ update="checkout" ++ ;; --) shift break @@@ -458,7 -491,7 +497,19 @@@ fi name=$(module_name "$path") || exit url=$(git config submodule."$name".url) -- update_module=$(git config submodule."$name".update) ++ if ! test -z "$update" ++ then ++ update_module=$update ++ else ++ update_module=$(git config submodule."$name".update) ++ fi ++ ++ if test "$update_module" = "none" ++ then ++ echo "Skipping submodule '$path'" ++ continue ++ fi ++ if test -z "$url" then # Only mention uninitialized submodules when its @@@ -480,11 -513,11 +531,6 @@@ Maybe you want to use 'update --init'?" die "$(eval_gettext "Unable to find current revision in submodule path '\$path'")" fi -- if ! test -z "$update" -- then -- update_module=$update -- fi -- if test "$subsha1" != "$sha1" then subforce=$force diff --cc setup.c index 27c1d4787,efad002ed..b2b4872b7 --- a/setup.c +++ b/setup.c @@@ -812,3 -808,10 +812,10 @@@ const char *setup_git_directory(void { return setup_git_directory_gently(NULL); } + + const char *resolve_gitdir(const char *suspect) + { + if (is_git_directory(suspect)) + return suspect; - return read_gitfile_gently(suspect); ++ return read_gitfile(suspect); + }