aboutsummaryrefslogtreecommitdiff
path: root/build-rev-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-07-23 17:54:41 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-23 18:28:19 -0700
commit8f3f9b09dc5ac8a946422422c3c70a4a4c284be3 (patch)
treea237b1468702dce4d5cd41258d4b8a8ea0976896 /build-rev-cache.c
parent0fec0822721cc18d6a62ab78da1ebf87914d4921 (diff)
downloadgit-8f3f9b09dc5ac8a946422422c3c70a4a4c284be3.tar.gz
git-8f3f9b09dc5ac8a946422422c3c70a4a4c284be3.tar.xz
[PATCH] Add update-server-info.
The git-update-server-info command prepares informational files to help clients discover the contents of a repository, and pull from it via a dumb transport protocols. Currently, the following files are produced. - The $repo/info/refs file lists the name of heads and tags available in the $repo/refs/ directory, along with their SHA1. This can be used by git-ls-remote command running on the client side. - The $repo/info/rev-cache file describes the commit ancestry reachable from references in the $repo/refs/ directory. This file is in an append-only binary format to make the server side friendly to rsync mirroring scheme, and can be read by git-show-rev-cache command. - The $repo/objects/info/pack file lists the name of the packs available, the interdependencies among them, and the head commits and tags contained in them. Along with the other two files, this is designed to help clients to make smart pull decisions. The git-receive-pack command is changed to invoke it at the end, so just after a push to a public repository finishes via "git push", the server info is automatically updated. In addition, building of the rev-cache file can be done by a standalone git-build-rev-cache command separately. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'build-rev-cache.c')
-rw-r--r--build-rev-cache.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/build-rev-cache.c b/build-rev-cache.c
new file mode 100644
index 000000000..948898beb
--- /dev/null
+++ b/build-rev-cache.c
@@ -0,0 +1,56 @@
+#include "refs.h"
+#include "cache.h"
+#include "commit.h"
+#include "rev-cache.h"
+
+static void process_head_list(int verbose)
+{
+ char buf[512];
+
+ while (fgets(buf, sizeof(buf), stdin)) {
+ unsigned char sha1[20];
+ struct commit *commit;
+
+ if (get_sha1_hex(buf, sha1)) {
+ error("ignoring: %s", buf);
+ continue;
+ }
+ if (!(commit = lookup_commit_reference(sha1))) {
+ error("not a commit: %s", sha1_to_hex(sha1));
+ continue;
+ }
+ record_rev_cache(commit->object.sha1, verbose ? stderr : NULL);
+ }
+}
+
+
+static const char *build_rev_cache_usage =
+"git-build-rev-cache <rev-cache-file> < list-of-heads";
+
+int main(int ac, char **av)
+{
+ int verbose = 0;
+ const char *path;
+
+ while (1 < ac && av[1][0] == '-') {
+ if (!strcmp(av[1], "-v"))
+ verbose = 1;
+ else
+ usage(build_rev_cache_usage);
+ ac--; av++;
+ }
+
+ if (ac != 2)
+ usage(build_rev_cache_usage);
+
+ path = av[1];
+
+ /* read existing rev-cache */
+ read_rev_cache(path, NULL, 0);
+
+ process_head_list(verbose);
+
+ /* update the rev-cache database by appending newly found one to it */
+ write_rev_cache(path, path);
+ return 0;
+}