summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4577370)
raw | patch | inline | side by side (parent: 4577370)
author | Daniel Barkalow <barkalow@iabervon.org> | |
Tue, 30 Oct 2007 01:05:43 +0000 (21:05 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 3 Nov 2007 05:40:44 +0000 (22:40 -0700) |
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile | patch | blob | history | |
builtin-peek-remote.c | [new file with mode: 0644] | patch | blob |
builtin.h | patch | blob | history | |
git.c | patch | blob | history | |
peek-remote.c | [deleted file] | patch | blob | history |
diff --git a/Makefile b/Makefile
index 042f79ef8f9e5863605e7ef19136b39b1487a07a..14f25ff8ecb828198ee3384525a4340a537d0387 100644 (file)
--- a/Makefile
+++ b/Makefile
git-fast-import$X \
git-daemon$X \
git-merge-index$X git-mktag$X git-mktree$X git-patch-id$X \
- git-peek-remote$X git-receive-pack$X \
+ git-receive-pack$X \
git-send-pack$X git-shell$X \
git-show-index$X \
git-unpack-file$X \
builtin-mv.o \
builtin-name-rev.o \
builtin-pack-objects.o \
+ builtin-peek-remote.o \
builtin-prune.o \
builtin-prune-packed.o \
builtin-push.o \
diff --git a/builtin-peek-remote.c b/builtin-peek-remote.c
--- /dev/null
+++ b/builtin-peek-remote.c
@@ -0,0 +1,70 @@
+#include "builtin.h"
+#include "cache.h"
+#include "transport.h"
+#include "remote.h"
+
+static const char peek_remote_usage[] =
+"git-peek-remote [--upload-pack=<git-upload-pack>] [<host>:]<directory>";
+
+int cmd_peek_remote(int argc, const char **argv, const char *prefix)
+{
+ int i;
+ const char *dest = NULL;
+ int nongit = 0;
+ unsigned flags = 0;
+ const char *uploadpack = NULL;
+
+ struct transport *transport;
+ const struct ref *ref;
+
+ setup_git_directory_gently(&nongit);
+
+ for (i = 1; i < argc; i++) {
+ const char *arg = argv[i];
+
+ if (*arg == '-') {
+ if (!prefixcmp(arg, "--upload-pack=")) {
+ uploadpack = arg + 14;
+ continue;
+ }
+ if (!prefixcmp(arg, "--exec=")) {
+ uploadpack = arg + 7;
+ continue;
+ }
+ if (!strcmp("--tags", arg)) {
+ flags |= REF_TAGS;
+ continue;
+ }
+ if (!strcmp("--heads", arg)) {
+ flags |= REF_HEADS;
+ continue;
+ }
+ if (!strcmp("--refs", arg)) {
+ flags |= REF_NORMAL;
+ continue;
+ }
+ usage(peek_remote_usage);
+ }
+ dest = arg;
+ break;
+ }
+
+ if (!dest || i != argc - 1)
+ usage(peek_remote_usage);
+
+ transport = transport_get(NULL, dest);
+ if (uploadpack != NULL)
+ transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
+
+ ref = transport_get_remote_refs(transport);
+
+ if (!ref)
+ return 1;
+
+ while (ref) {
+ if (check_ref_type(ref, flags))
+ printf("%s %s\n", sha1_to_hex(ref->old_sha1), ref->name);
+ ref = ref->next;
+ }
+ return 0;
+}
diff --git a/builtin.h b/builtin.h
index 9a6213af126212dc131133cc2e9bf8b8d7a34557..62ee5373dc27e408bf8729de72b6b0715900edc8 100644 (file)
--- a/builtin.h
+++ b/builtin.h
extern int cmd_mv(int argc, const char **argv, const char *prefix);
extern int cmd_name_rev(int argc, const char **argv, const char *prefix);
extern int cmd_pack_objects(int argc, const char **argv, const char *prefix);
+extern int cmd_peek_remote(int argc, const char **argv, const char *prefix);
extern int cmd_pickaxe(int argc, const char **argv, const char *prefix);
extern int cmd_prune(int argc, const char **argv, const char *prefix);
extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
index 4e10581101c26444da5c7c44a80219b11607705b..c55a13de17eb563edd1d8ba2f6309bc5720257c2 100644 (file)
--- a/git.c
+++ b/git.c
{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
{ "name-rev", cmd_name_rev, RUN_SETUP },
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
+ { "peek-remote", cmd_peek_remote },
{ "pickaxe", cmd_blame, RUN_SETUP },
{ "prune", cmd_prune, RUN_SETUP },
{ "prune-packed", cmd_prune_packed, RUN_SETUP },
diff --git a/peek-remote.c b/peek-remote.c
--- a/peek-remote.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include "cache.h"
-#include "refs.h"
-#include "pkt-line.h"
-
-static const char peek_remote_usage[] =
-"git-peek-remote [--upload-pack=<git-upload-pack>] [<host>:]<directory>";
-static const char *uploadpack = "git-upload-pack";
-
-static int peek_remote(int fd[2], unsigned flags)
-{
- struct ref *ref;
-
- get_remote_heads(fd[0], &ref, 0, NULL, flags);
- packet_flush(fd[1]);
-
- while (ref) {
- printf("%s %s\n", sha1_to_hex(ref->old_sha1), ref->name);
- ref = ref->next;
- }
- return 0;
-}
-
-int main(int argc, char **argv)
-{
- int i, ret;
- char *dest = NULL;
- int fd[2];
- struct child_process *conn;
- int nongit = 0;
- unsigned flags = 0;
-
- setup_git_directory_gently(&nongit);
-
- for (i = 1; i < argc; i++) {
- char *arg = argv[i];
-
- if (*arg == '-') {
- if (!prefixcmp(arg, "--upload-pack=")) {
- uploadpack = arg + 14;
- continue;
- }
- if (!prefixcmp(arg, "--exec=")) {
- uploadpack = arg + 7;
- continue;
- }
- if (!strcmp("--tags", arg)) {
- flags |= REF_TAGS;
- continue;
- }
- if (!strcmp("--heads", arg)) {
- flags |= REF_HEADS;
- continue;
- }
- if (!strcmp("--refs", arg)) {
- flags |= REF_NORMAL;
- continue;
- }
- usage(peek_remote_usage);
- }
- dest = arg;
- break;
- }
-
- if (!dest || i != argc - 1)
- usage(peek_remote_usage);
-
- conn = git_connect(fd, dest, uploadpack, 0);
- ret = peek_remote(fd, flags);
- close(fd[0]);
- close(fd[1]);
- ret |= finish_connect(conn);
- return !!ret;
-}