X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=server-info.c;h=ba5359108deb4f010be366ef65974ec7db123098;hb=42e2cba20466e50825c55d2642da72bf4f088040;hp=3263035b9316e3822a92201f4dcd35a24bca943d;hpb=0f56479d7325083953be36b8c8ee90380ff27f92;p=git.git diff --git a/server-info.c b/server-info.c index 3263035b..ba535910 100644 --- a/server-info.c +++ b/server-info.c @@ -6,26 +6,22 @@ /* refs */ static FILE *info_ref_fp; -static unsigned long info_ref_time; -static int info_ref_is_stale = 0; - -static int stat_ref(const char *path, const unsigned char *sha1) -{ - struct stat st; - if (!stat(path, &st) && info_ref_time < st.st_mtime) - info_ref_is_stale = 1; - return 0; -} static int add_info_ref(const char *path, const unsigned char *sha1) { + struct object *o = parse_object(sha1); + fprintf(info_ref_fp, "%s %s\n", sha1_to_hex(sha1), path); + if (o->type == tag_type) { + o = deref_tag(o); + fprintf(info_ref_fp, "%s %s^{}\n", + sha1_to_hex(o->sha1), path); + } return 0; } static int update_info_refs(int force) { - struct stat st; char *path0 = strdup(git_path("info/refs")); int len = strlen(path0); char *path1 = xmalloc(len + 2); @@ -33,21 +29,6 @@ static int update_info_refs(int force) strcpy(path1, path0); strcpy(path1 + len, "+"); - if (!force) { - if (stat(path0, &st)) { - if (errno == ENOENT) - info_ref_is_stale = 1; - else - return error("cannot stat %s", path0); - } - else { - info_ref_time = st.st_mtime; - for_each_ref(stat_ref); - } - if (!info_ref_is_stale) - return 0; - } - safe_create_leading_directories(path0); info_ref_fp = fopen(path1, "w"); if (!info_ref_fp) @@ -85,6 +66,16 @@ static struct object *parse_object_cheap(const unsigned char *sha1) struct commit *commit = (struct commit *)o; free(commit->buffer); commit->buffer = NULL; + } else if (o->type == tree_type) { + struct tree *tree = (struct tree *)o; + struct tree_entry_list *e, *n; + for (e = tree->entries; e; e = n) { + free(e->name); + e->name = NULL; + n = e->next; + free(e); + } + tree->entries = NULL; } return o; }