From 45781adb9a89c0c47f61ccf8062be26b86a38a54 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Tue, 1 Mar 2011 10:21:36 +0100 Subject: get_remote_url(): use the same data source as ls-remote to get remote urls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- git-parse-remote.sh | 48 +----------------------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) (limited to 'git-parse-remote.sh') diff --git a/git-parse-remote.sh b/git-parse-remote.sh index 1cc2ba6e09..0ab1192f81 100644 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -4,54 +4,8 @@ # 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 () { -- cgit v1.2.3 From 1a92777504afc09e071d7d828e084e6a4dadfce2 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Tue, 1 Mar 2011 10:21:37 +0100 Subject: git-request-pull: open-code the only invocation of get_remote_url MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So sh:get_remote_url can go now and git-request-pull doesn't need to source git-parse-remote. anymore. Signed-off-by: Uwe Kleine-König Signed-off-by: Junio C Hamano --- git-parse-remote.sh | 4 ---- git-request-pull.sh | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'git-parse-remote.sh') diff --git a/git-parse-remote.sh b/git-parse-remote.sh index 0ab1192f81..e7013f7ba7 100644 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -4,10 +4,6 @@ # this would fail in that case and would issue an error message. GIT_DIR=$(git rev-parse -q --git-dir) || :; -get_remote_url () { - git ls-remote --get-url "$1" -} - get_default_remote () { curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||') origin=$(git config --get "branch.$curr_branch.remote") diff --git a/git-request-pull.sh b/git-request-pull.sh index 6fdea397dd..fc080cc5e4 100755 --- a/git-request-pull.sh +++ b/git-request-pull.sh @@ -15,7 +15,6 @@ p show patch text as well ' . git-sh-setup -. git-parse-remote GIT_PAGER= export GIT_PAGER @@ -55,7 +54,7 @@ branch=$(git ls-remote "$url" \ p q }") -url=$(get_remote_url "$url") +url=$(git ls-remote --get-url "$url") if [ -z "$branch" ]; then echo "warn: No branch of $url is at:" >&2 git log --max-count=1 --pretty='tformat:warn: %h: %s' $headrev >&2 -- cgit v1.2.3