Revision adc446fe5d5f6dc1fb5edeaa9aa016ef94e70da1 authored by Junio C Hamano on 08 October 2006, 19:56:19 UTC, committed by Junio C Hamano on 09 October 2006, 00:13:15 UTC
Sean <seanlkml@sympatico.ca> writes: > On Sat, 07 Oct 2006 21:52:02 -0700 > Junio C Hamano <junkio@cox.net> wrote: > >> Using DAV, if it works with the server, has the advantage of not >> having to keep objects/info/packs up-to-date from repository >> owner's point of view. But the repository owner ends up keeping >> up-to-date as a side effect of keeping info/refs up-to-date >> anyway (as I do not see a code to read that information over >> DAV), so there is no point doing this over DAV in practice. >> >> Perhaps we should remove call to remote_ls() from >> fetch_indices() unconditionally, not just protected with >> NO_EXPAT and be done with it? > > That makes a lot of sense. A server really has to always provide > a objects/info/packs anyway, just to be fetchable today by clients > that are compiled with NO_EXPAT. And even for an isolated group where everybody knows that everybody else runs DAV-enabled clients, they need info/refs prepared for ls-remote and git-fetch script, which means you will run update-server-info to keep objects/info/packs up to date. Nick, do you see holes in my logic? -- >8 -- http-fetch.c: drop remote_ls() While doing remote_ls() over DAV potentially allows the server side not to keep objects/info/pack up-to-date, misconfigured or buggy servers can silently ignore or not to respond to DAV requests and makes the client hang. The server side (unfortunately) needs to run git-update-server-info even if remote_ls() removes the need to keep objects/info/pack file up-to-date, because the caller of git-http-fetch (git-fetch) and other clients that interact with the repository (e.g. git-ls-remote) need to read from info/refs file (there is no code to make that unnecessary by using DAV yet). Perhaps the right solution in the longer-term is to make info/refs also unnecessary by using DAV, and we would want to resurrect the code this patch removes when we do so, but let's drop remote_ls() implementation for now. It is causing problems without really helping anything yet. git will keep it for us until we need it next time. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 9a7a62f
mktree.c
/*
* GIT - the stupid content tracker
*
* Copyright (c) Junio C Hamano, 2006
*/
#include "cache.h"
#include "strbuf.h"
#include "quote.h"
#include "tree.h"
static struct treeent {
unsigned mode;
unsigned char sha1[20];
int len;
char name[FLEX_ARRAY];
} **entries;
static int alloc, used;
static void append_to_tree(unsigned mode, unsigned char *sha1, char *path)
{
struct treeent *ent;
int len = strlen(path);
if (strchr(path, '/'))
die("path %s contains slash", path);
if (alloc <= used) {
alloc = alloc_nr(used);
entries = xrealloc(entries, sizeof(*entries) * alloc);
}
ent = entries[used++] = xmalloc(sizeof(**entries) + len + 1);
ent->mode = mode;
ent->len = len;
hashcpy(ent->sha1, sha1);
memcpy(ent->name, path, len+1);
}
static int ent_compare(const void *a_, const void *b_)
{
struct treeent *a = *(struct treeent **)a_;
struct treeent *b = *(struct treeent **)b_;
return base_name_compare(a->name, a->len, a->mode,
b->name, b->len, b->mode);
}
static void write_tree(unsigned char *sha1)
{
char *buffer;
unsigned long size, offset;
int i;
qsort(entries, used, sizeof(*entries), ent_compare);
for (size = i = 0; i < used; i++)
size += 32 + entries[i]->len;
buffer = xmalloc(size);
offset = 0;
for (i = 0; i < used; i++) {
struct treeent *ent = entries[i];
if (offset + ent->len + 100 < size) {
size = alloc_nr(offset + ent->len + 100);
buffer = xrealloc(buffer, size);
}
offset += sprintf(buffer + offset, "%o ", ent->mode);
offset += sprintf(buffer + offset, "%s", ent->name);
buffer[offset++] = 0;
hashcpy((unsigned char*)buffer + offset, ent->sha1);
offset += 20;
}
write_sha1_file(buffer, offset, tree_type, sha1);
}
static const char mktree_usage[] = "git-mktree [-z]";
int main(int ac, char **av)
{
struct strbuf sb;
unsigned char sha1[20];
int line_termination = '\n';
setup_git_directory();
while ((1 < ac) && av[1][0] == '-') {
char *arg = av[1];
if (!strcmp("-z", arg))
line_termination = 0;
else
usage(mktree_usage);
ac--;
av++;
}
strbuf_init(&sb);
while (1) {
int len;
char *ptr, *ntr;
unsigned mode;
char type[20];
char *path;
read_line(&sb, stdin, line_termination);
if (sb.eof)
break;
len = sb.len;
ptr = sb.buf;
/* Input is non-recursive ls-tree output format
* mode SP type SP sha1 TAB name
*/
mode = strtoul(ptr, &ntr, 8);
if (ptr == ntr || !ntr || *ntr != ' ')
die("input format error: %s", sb.buf);
ptr = ntr + 1; /* type */
ntr = strchr(ptr, ' ');
if (!ntr || sb.buf + len <= ntr + 41 ||
ntr[41] != '\t' ||
get_sha1_hex(ntr + 1, sha1))
die("input format error: %s", sb.buf);
if (sha1_object_info(sha1, type, NULL))
die("object %s unavailable", sha1_to_hex(sha1));
*ntr++ = 0; /* now at the beginning of SHA1 */
if (strcmp(ptr, type))
die("object type %s mismatch (%s)", ptr, type);
ntr += 41; /* at the beginning of name */
if (line_termination && ntr[0] == '"')
path = unquote_c_style(ntr, NULL);
else
path = ntr;
append_to_tree(mode, sha1, path);
if (path != ntr)
free(path);
}
write_tree(sha1);
puts(sha1_to_hex(sha1));
exit(0);
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...