{"thread":{"id":"1323","subject":"[PATCH 1/6] git-peek-remote: show tags and heads from a remote repository.","startedAt":"2005-07-24T00:54:03Z","lastAt":"2005-07-24T00:54:03Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"6397","messageId":"7vll3xkor8.fsf@assigned-by-dhcp.cox.net","threadId":"1323","inReplyTo":null,"subject":"[PATCH 1/6] git-peek-remote: show tags and heads from a remote repository.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-24T00:54:03Z","receivedAt":"2005-07-24T00:54:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Add a git-peek-remote command that talks with upload-pack the\nsame way git-fetch-pack and git-clone-pack do, to show the\nreferences the remote side has on the standard output.\n\nA later patch introduces git-ls-remote that implements a UI to\nstore tag values retrieved using this command.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n Makefile      |    3 ++-\n peek-remote.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 57 insertions(+), 1 deletions(-)\n create mode 100644 peek-remote.c\n\n06377142267dd3d0c7a37794b3d117531867cf04\ndiff --git a/Makefile b/Makefile\n--- a/Makefile\n+++ b/Makefile\n@@ -49,7 +49,7 @@ PROG=   git-update-cache git-diff-files \n \tgit-diff-stages git-rev-parse git-patch-id git-pack-objects \\\n \tgit-unpack-objects git-verify-pack git-receive-pack git-send-pack \\\n \tgit-prune-packed git-fetch-pack git-upload-pack git-clone-pack \\\n-\tgit-show-index git-daemon git-var\n+\tgit-show-index git-daemon git-var git-peek-remote\n \n all: $(PROG)\n \n@@ -150,6 +150,7 @@ git-send-pack: send-pack.c\n git-prune-packed: prune-packed.c\n git-fetch-pack: fetch-pack.c\n git-var: var.c\n+git-peek-remote: peek-remote.c\n \n git-http-pull: LIBS += -lcurl\n git-rev-list: LIBS += -lssl\ndiff --git a/peek-remote.c b/peek-remote.c\nnew file mode 100644\n--- /dev/null\n+++ b/peek-remote.c\n@@ -0,0 +1,55 @@\n+#include \"cache.h\"\n+#include \"refs.h\"\n+#include \"pkt-line.h\"\n+#include <sys/wait.h>\n+\n+static const char peek_remote_usage[] =\n+\"git-peek-remote [--exec=upload-pack] [host:]directory\";\n+static const char *exec = \"git-upload-pack\";\n+\n+static int peek_remote(int fd[2])\n+{\n+\tstruct ref *ref;\n+\n+\tget_remote_heads(fd[0], &ref, 0, NULL);\n+\tpacket_flush(fd[1]);\n+\n+\twhile (ref) {\n+\t\tprintf(\"%s\t%s\\n\", sha1_to_hex(ref->old_sha1), ref->name);\n+\t\tref = ref->next;\n+\t}\n+\treturn 0;\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\tint i, ret;\n+\tchar *dest = NULL;\n+\tint fd[2];\n+\tpid_t pid;\n+\n+\tfor (i = 1; i < argc; i++) {\n+\t\tchar *arg = argv[i];\n+\n+\t\tif (*arg == '-') {\n+\t\t\tif (!strncmp(\"--exec=\", arg, 7))\n+\t\t\t\texec = arg + 7;\n+\t\t\telse\n+\t\t\t\tusage(peek_remote_usage);\n+\t\t\tcontinue;\n+\t\t}\n+\t\tdest = arg;\n+\t\tbreak;\n+\t}\n+\tif (!dest || i != argc - 1)\n+\t\tusage(peek_remote_usage);\n+\n+\tpid = git_connect(fd, dest, exec);\n+\tif (pid < 0)\n+\t\treturn 1;\n+\tret = peek_remote(fd);\n+\tclose(fd[0]);\n+\tclose(fd[1]);\n+\tfinish_connect(pid);\n+\treturn ret;\n+}\n"}]}