Merge branch 'uk/ls-remote-in-get-remote-url'
* uk/ls-remote-in-get-remote-url: git-request-pull: open-code the only invocation of get_remote_url get_remote_url(): use the same data source as ls-remote to get remote urls
This commit is contained in:
commit
32b31ab7f3
@ -33,6 +33,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
|
|||||||
int i;
|
int i;
|
||||||
const char *dest = NULL;
|
const char *dest = NULL;
|
||||||
unsigned flags = 0;
|
unsigned flags = 0;
|
||||||
|
int get_url = 0;
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
const char *uploadpack = NULL;
|
const char *uploadpack = NULL;
|
||||||
const char **pattern = NULL;
|
const char **pattern = NULL;
|
||||||
@ -69,6 +70,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
|
|||||||
quiet = 1;
|
quiet = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp("--get-url", arg)) {
|
||||||
|
get_url = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
usage(ls_remote_usage);
|
usage(ls_remote_usage);
|
||||||
}
|
}
|
||||||
dest = arg;
|
dest = arg;
|
||||||
@ -94,6 +99,12 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
if (!remote->url_nr)
|
if (!remote->url_nr)
|
||||||
die("remote %s has no configured URL", dest);
|
die("remote %s has no configured URL", dest);
|
||||||
|
|
||||||
|
if (get_url) {
|
||||||
|
printf("%s\n", *remote->url);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
transport = transport_get(remote, NULL);
|
transport = transport_get(remote, NULL);
|
||||||
if (uploadpack != NULL)
|
if (uploadpack != NULL)
|
||||||
transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
|
transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
|
||||||
|
@ -4,56 +4,6 @@
|
|||||||
# this would fail in that case and would issue an error message.
|
# this would fail in that case and would issue an error message.
|
||||||
GIT_DIR=$(git rev-parse -q --git-dir) || :;
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
get_default_remote () {
|
get_default_remote () {
|
||||||
curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
|
curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
|
||||||
origin=$(git config --get "branch.$curr_branch.remote")
|
origin=$(git config --get "branch.$curr_branch.remote")
|
||||||
|
@ -15,7 +15,6 @@ p show patch text as well
|
|||||||
'
|
'
|
||||||
|
|
||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
. git-parse-remote
|
|
||||||
|
|
||||||
GIT_PAGER=
|
GIT_PAGER=
|
||||||
export GIT_PAGER
|
export GIT_PAGER
|
||||||
@ -55,7 +54,7 @@ branch=$(git ls-remote "$url" \
|
|||||||
p
|
p
|
||||||
q
|
q
|
||||||
}")
|
}")
|
||||||
url=$(get_remote_url "$url")
|
url=$(git ls-remote --get-url "$url")
|
||||||
if [ -z "$branch" ]; then
|
if [ -z "$branch" ]; then
|
||||||
echo "warn: No branch of $url is at:" >&2
|
echo "warn: No branch of $url is at:" >&2
|
||||||
git log --max-count=1 --pretty='tformat:warn: %h: %s' $headrev >&2
|
git log --max-count=1 --pretty='tformat:warn: %h: %s' $headrev >&2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user