Reteach builtin-ls-remote to understand remotes
Prior to being made a builtin git-ls-remote understood that when it was given a remote name we wanted it to resolve that to the pre-configured URL and connect to that location. That changed when it was converted to a builtin and many of my automation tools broke. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Nov 6, 2007 at 20:29 UTC
7c2c6ee7e0259d591acb3d9841cf5417e6b7a8eb
2 files changed
+57
-1
builtin-ls-remote.c
+5
-1
@@ -14,6 +14,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
14
unsigned flags = 0;
15
const char *uploadpack = NULL;
16
17
+ struct remote *remote;
18
struct transport *transport;
19
const struct ref *ref;
20
@@ -52,7 +53,10 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
53
if (!dest || i != argc - 1)
54
usage(ls_remote_usage);
55
55
- transport = transport_get(NULL, dest);
56
+ remote = nongit ? NULL : remote_get(dest);
57
+ if (remote && !remote->url_nr)
58
+ die("remote %s has no configured URL", dest);
59
+ transport = transport_get(remote, remote ? remote->url[0] : dest);
60
if (uploadpack != NULL)
61
transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
62
t/t5512-ls-remote.sh
new
+52
@@ -0,0 +1,52 @@
1
+#!/bin/sh
2
+
3
+test_description='git ls-remote'
4
+
5
+. ./test-lib.sh
6
+
7
+test_expect_success setup '
8
+
9
+ >file &&
10
+ git add file &&
11
+ test_tick &&
12
+ git commit -m initial &&
13
+ git tag mark &&
14
+ git show-ref --tags -d | sed -e "s/ / /" >expected.tag &&
15
+ (
16
+ echo "$(git rev-parse HEAD) HEAD"
17
+ git show-ref -d | sed -e "s/ / /"
18
+ ) >expected.all &&
19
+
20
+ git remote add self $(pwd)/.git
21
+
22
+'
23
+
24
+test_expect_success 'ls-remote --tags .git' '
25
+
26
+ git ls-remote --tags .git >actual &&
27
+ diff -u expected.tag actual
28
+
29
+'
30
+
31
+test_expect_success 'ls-remote .git' '
32
+
33
+ git ls-remote .git >actual &&
34
+ diff -u expected.all actual
35
+
36
+'
37
+
38
+test_expect_success 'ls-remote --tags self' '
39
+
40
+ git ls-remote --tags self >actual &&
41
+ diff -u expected.tag actual
42
+
43
+'
44
+
45
+test_expect_success 'ls-remote self' '
46
+
47
+ git ls-remote self >actual &&
48
+ diff -u expected.all actual
49
+
50
+'
51
+
52
+test_done