summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ed863a)
raw | patch | inline | side by side (parent: 7ed863a)
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | |
Tue, 1 Mar 2011 09:21:36 +0000 (10:21 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 2 Mar 2011 20:26:53 +0000 (12:26 -0800) |
The formerly implemented algorithm behaved differently to
remote.c:remote_get() at least for remotes that contain a slash. While the
former just assumes a/b is a path the latter checks the config for
remote."a/b" first which is more reasonable.
This removes the last user of git-parse-remote.sh:get_data_source(), so
this function is removed.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote.c:remote_get() at least for remotes that contain a slash. While the
former just assumes a/b is a path the latter checks the config for
remote."a/b" first which is more reasonable.
This removes the last user of git-parse-remote.sh:get_data_source(), so
this function is removed.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/ls-remote.c | patch | blob | history | |
git-parse-remote.sh | patch | blob | history |
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 97eed4012ba23cfe7f13cf2b6c160ade54f6b2d1..1a1ff87e8f9ed7db84f106960f36888835f7057b 100644 (file)
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
int i;
const char *dest = NULL;
unsigned flags = 0;
+ int get_url = 0;
int quiet = 0;
const char *uploadpack = NULL;
const char **pattern = NULL;
quiet = 1;
continue;
}
+ if (!strcmp("--get-url", arg)) {
+ get_url = 1;
+ continue;
+ }
usage(ls_remote_usage);
}
dest = arg;
}
if (!remote->url_nr)
die("remote %s has no configured URL", dest);
+
+ if (get_url) {
+ printf("%s\n", *remote->url);
+ return 0;
+ }
+
transport = transport_get(remote, NULL);
if (uploadpack != NULL)
transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 1cc2ba6e09614fa55ad205145a3bdacfb78bf283..0ab1192f81217fe22715fd351395e3c9b05c86a0 100644 (file)
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
# this would fail in that case and would issue an error message.
GIT_DIR=$(git rev-parse -q --git-dir) || :;
-get_data_source () {
- case "$1" in
- */*)
- echo ''
- ;;
- .)
- echo self
- ;;
- *)
- if test "$(git config --get "remote.$1.url")"
- then
- echo config
- elif test -f "$GIT_DIR/remotes/$1"
- then
- echo remotes
- elif test -f "$GIT_DIR/branches/$1"
- then
- echo branches
- else
- echo ''
- fi ;;
- esac
-}
-
get_remote_url () {
- data_source=$(get_data_source "$1")
- case "$data_source" in
- '')
- echo "$1"
- ;;
- self)
- echo "$1"
- ;;
- config)
- git config --get "remote.$1.url"
- ;;
- remotes)
- sed -ne '/^URL: */{
- s///p
- q
- }' "$GIT_DIR/remotes/$1"
- ;;
- branches)
- sed -e 's/#.*//' "$GIT_DIR/branches/$1"
- ;;
- *)
- die "internal error: get-remote-url $1" ;;
- esac
+ git ls-remote --get-url "$1"
}
get_default_remote () {