summaryrefslogtreecommitdiff
path: root/t/t9902-completion.sh
diff options
context:
space:
mode:
authorSZEDER Gábor <szeder.dev@gmail.com>2017-02-03 02:48:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-02-04 06:18:40 (GMT)
commit69a775963b76824511fe4bdaf949f2e44df4b7a5 (patch)
treeea9831f56bd49a98e07b6a764473ee46fb9de875 /t/t9902-completion.sh
parent5c12f642df48a0ddee24554fbd2067c4958273d8 (diff)
downloadgit-69a775963b76824511fe4bdaf949f2e44df4b7a5.zip
git-69a775963b76824511fe4bdaf949f2e44df4b7a5.tar.gz
git-69a775963b76824511fe4bdaf949f2e44df4b7a5.tar.bz2
completion: list refs from remote when remote's name matches a directory
If the remote given to __git_refs() happens to match both the name of a configured remote and the name of a directory in the current working directory, then that directory is assumed to be a git repository, and listing refs from that directory will be attempted. This is wrong, because in such a situation git commands (e.g. 'git fetch|pull|push <remote>' whom these refs will eventually be passed to) give precedence to the configured remote. Therefore, __git_refs() should list refs from the configured remote as well. Add the helper function __git_is_configured_remote() that checks whether its argument matches the name of a configured remote. Use this helper to decide how to handle the remote passed to __git_refs(). Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9902-completion.sh')
-rwxr-xr-xt/t9902-completion.sh11
1 files changed, 10 insertions, 1 deletions
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 6e64cd6..a201b52 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -373,6 +373,15 @@ test_expect_success '__git_remotes - list remotes from $GIT_DIR/remotes and from
test_cmp expect actual
'
+test_expect_success '__git_is_configured_remote' '
+ test_when_finished "git remote remove remote_1" &&
+ git remote add remote_1 git://remote_1 &&
+ test_when_finished "git remote remove remote_2" &&
+ git remote add remote_2 git://remote_2 &&
+ verbose __git_is_configured_remote remote_2 &&
+ test_must_fail __git_is_configured_remote non-existent
+'
+
test_expect_success 'setup for ref completion' '
git commit --allow-empty -m initial &&
git branch matching-branch &&
@@ -516,7 +525,7 @@ test_expect_success '__git_refs - configured remote - full refs - repo given on
test_cmp expected "$actual"
'
-test_expect_failure '__git_refs - configured remote - remote name matches a directory' '
+test_expect_success '__git_refs - configured remote - remote name matches a directory' '
cat >expected <<-EOF &&
HEAD
branch-in-other