author | Junio C Hamano <gitster@pobox.com> | |
Mon, 10 Oct 2011 22:56:16 +0000 (15:56 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 10 Oct 2011 22:56:17 +0000 (15:56 -0700) |
* fg/submodule-git-file-git-dir:
Move git-dir for submodules
rev-parse: add option --resolve-git-dir <path>
Conflicts:
cache.h
git-submodule.sh
Move git-dir for submodules
rev-parse: add option --resolve-git-dir <path>
Conflicts:
cache.h
git-submodule.sh
1 | 2 | |||
---|---|---|---|---|
cache.h | patch | | diff1 | | diff2 | | blob | history |
git-submodule.sh | patch | | diff1 | | diff2 | | blob | history |
setup.c | patch | | diff1 | | diff2 | | blob | history |
t/t7400-submodule-basic.sh | patch | | diff1 | | diff2 | | blob | history |
diff --cc cache.h
index 82e12c862c0ed4fb0da7fb86fc3cef26558810dc,55ae6976b6961bcc967cf277b95d018009ec57dc..c989f79835a332d879333ee8b927ede150784e54
+++ b/cache.h
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 814d0d914eaf994462e61559b0692c958f97513b,7576d147695955f3a2b8a92944b5315a2b0f5395..928a62f626fe7ff1db8239713d94ff9aa25158eb
--- 1/git-submodule.sh
--- 2/git-submodule.sh
+++ b/git-submodule.sh
path=$1
url=$2
reference="$3"
- if test -n "$reference"
+ quiet=
+ if test -n "$GIT_QUIET"
+ then
+ quiet=-q
+ fi
+
+ 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
}
#
--recursive)
recursive=1
;;
++ --checkout)
++ update="checkout"
++ ;;
--)
shift
break
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
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 27c1d4787a2c2efd8420a225b43e36b76464ce42,efad002ed2ec8e54e922baefb9c12d494fb668d7..b2b4872b700ab9776144f145dfb27d5d16dfc945
+++ b/setup.c
{
return setup_git_directory_gently(NULL);
}
- return read_gitfile_gently(suspect);
+
+ const char *resolve_gitdir(const char *suspect)
+ {
+ if (is_git_directory(suspect))
+ return suspect;
++ return read_gitfile(suspect);
+ }
diff --cc t/t7400-submodule-basic.sh
Simple merge