Re: dumb transports not being welcomed..
- From
- Sven Verdoolaege <skimo@kotnet.org>
- Date
- Sep 14, 2005, 10:45 UTC
- Message-ID
- <20050914104539.GP15165MdfPADPa@greensroom.kotnet.org>
- In-Reply-To
- <7vpsrcwrc1.fsf@assigned-by-dhcp.cox.net>
On Tue, Sep 13, 2005 at 03:11:42PM -0700, Junio C Hamano wrote:
> The file $GIT_DIR/info/refs was introduced to solve this by > listing the available refs for discovery, and hooks/post-update, > when enabled, runs update-server-info to update the file (among > other things) whenever you push into the repository.
It doesn't help that update-server-info crashes if you run it for the first time on an old repo. Maybe it should create the appropriate directory structure on the fly, but the patch below at least checks whether new rev-cache could be created.
skimo --
write_rev_cache: check whether new cache could be created.
--- commit d30b87459c690ff68e65dfe8ecdc585dab64323a tree 51127c1af00f8fd63e7b996384e86d7d31ad5562 parent 2ba6c47be1762726ad0c1d5779064c489150d789 author Sven Verdoolaege <skimo@liacs.nl> Wed, 14 Sep 2005 12:40:28 +0200 committer Sven Verdoolaege <skimo@liacs.nl> Wed, 14 Sep 2005 12:40:28 +0200
rev-cache.c | 8 +++++++- rev-cache.h | 2 +- server-info.c | 7 ++++--- 3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/rev-cache.c b/rev-cache.c --- a/rev-cache.c +++ b/rev-cache.c @@ -103,7 +103,7 @@ static void write_one_rev_cache(FILE *re write_one_rev_cache(rev_cache_file, rle->ri); } -void write_rev_cache(const char *newpath, const char *oldpath) +int write_rev_cache(const char *newpath, const char *oldpath) { /* write the following commit ancestry information in * $GIT_DIR/info/rev-cache. @@ -131,6 +131,11 @@ void write_rev_cache(const char *newpath size_t sz; FILE *oldfp = fopen(oldpath, "r"); rev_cache_file = fopen(newpath, "w"); + if (!rev_cache_file) { + if (oldfp) + fclose(oldfp); + return error("cannot open %s", newpath); + } if (oldfp) { while (1) { sz = fread(buf, 1, sizeof(buf), oldfp); @@ -161,6 +166,7 @@ void write_rev_cache(const char *newpath write_one_rev_cache(rev_cache_file, ri); } fclose(rev_cache_file); + return 0; } static void add_parent(struct rev_cache *child, diff --git a/rev-cache.h b/rev-cache.h --- a/rev-cache.h +++ b/rev-cache.h @@ -24,6 +24,6 @@ struct rev_list_elem { extern int find_rev_cache(const unsigned char *); extern int read_rev_cache(const char *, FILE *, int); extern int record_rev_cache(const unsigned char *, FILE *); -extern void write_rev_cache(const char *new, const char *old); +extern int write_rev_cache(const char *new, const char *old); #endif diff --git a/server-info.c b/server-info.c --- a/server-info.c +++ b/server-info.c @@ -536,6 +536,7 @@ static int update_info_revs(int force) char *path0 = strdup(git_path("info/rev-cache")); int len = strlen(path0); char *path1 = xmalloc(len + 2); + int errs = 0; strcpy(path1, path0); strcpy(path1 + len, "+"); @@ -548,11 +549,11 @@ static int update_info_revs(int force) for_each_ref(record_rev_cache_ref); /* update the rev-cache database */ - write_rev_cache(path1, force ? "/dev/null" : path0); - rename(path1, path0); + errs = errs || write_rev_cache(path1, force ? "/dev/null" : path0); + errs = errs || rename(path1, path0); free(path1); free(path0); - return 0; + return errs; } /* public */