summaryrefslogtreecommitdiff
path: root/missing-revs.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2005-07-25 22:42:18 -0700
committerLibravatar Junio C Hamano <junkio@cox.net>2005-07-31 11:56:44 -0700
commit96155e55e175e7fed1d8ebd73557d339f35629d8 (patch)
treebeefc211f75f0fc195f8992d696353881fc9fa16 /missing-revs.c
parentMerge with gitk. (diff)
downloadtgif-96155e55e175e7fed1d8ebd73557d339f35629d8.tar.xz
Fetch from a packed repository on dumb servers.
Implement fetching from a packed repository over http/https using the dumb server support files. I consider some parts of the logic should be in a separate C program, but it appears to work with my simple tests. I have backburnered it for a bit too long for my liking, so let's throw it out in the open and see what happens. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'missing-revs.c')
-rw-r--r--missing-revs.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/missing-revs.c b/missing-revs.c
new file mode 100644
index 0000000000..afe41e33d4
--- /dev/null
+++ b/missing-revs.c
@@ -0,0 +1,63 @@
+#include "cache.h"
+#include "rev-cache.h"
+
+static const char missing_revs_usage[] =
+"git-missing-revs <rev-cache-file> <want-sha1>...";
+
+#define REV_WANT 01
+#define REV_HAVE 02
+
+static void process(struct rev_cache *head_list)
+{
+ while (head_list) {
+ struct rev_cache *rc = head_list;
+ struct rev_list_elem *e;
+ head_list = rc->head_list;
+ rc->head_list = NULL;
+ if (has_sha1_file(rc->sha1)) {
+ rc->work |= REV_HAVE;
+ continue;
+ }
+ if (rc->work & (REV_WANT|REV_HAVE))
+ continue;
+ rc->work |= REV_WANT;
+ printf("%s\n", sha1_to_hex(rc->sha1));
+ for (e = rc->parents; e; e = e->next) {
+ if (e->ri->work & REV_HAVE)
+ continue;
+ e->ri->head_list = head_list;
+ head_list = e->ri;
+ }
+ }
+}
+
+int main(int ac, char **av)
+{
+ const char *rev_cache_file;
+ struct rev_cache *head_list = NULL;
+ int i;
+
+ if (ac < 3)
+ usage(missing_revs_usage);
+ rev_cache_file = av[1];
+ read_rev_cache(rev_cache_file, NULL, 0);
+ for (i = 2; i < ac; i++) {
+ unsigned char sha1[20];
+ int pos;
+ struct rev_cache *rc;
+ if (get_sha1_hex(av[i], sha1))
+ die("%s: not an SHA1", av[i]);
+ if ((pos = find_rev_cache(sha1)) < 0) {
+ /* We could be asked for tags, which would not
+ * appear in the rev-cache.
+ */
+ puts(av[i]);
+ continue;
+ }
+ rc = rev_cache[pos];
+ rc->head_list = head_list;
+ head_list = rc;
+ }
+ process(head_list);
+ return 0;
+}