From f22ca7c50d79fcfd769ddcda988e0981fb883a16 Mon Sep 17 00:00:00 2001 From: "robfitz@273k.net" Date: Sat, 8 Oct 2005 15:54:35 -0700 Subject: Reduce memory usage in git-update-server-info. Modify parse_object_cheap() to also free all the entries from the tree data structures. Signed-off-by: Robert Fitzsimons Signed-off-by: Junio C Hamano --- server-info.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'server-info.c') diff --git a/server-info.c b/server-info.c index a9e5607f2f..3c08a288db 100644 --- a/server-info.c +++ b/server-info.c @@ -59,6 +59,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; } -- cgit v1.3-6-g1900 From f6b42a81fd97a55dec0766685aac722a838a11a6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 13 Oct 2005 18:57:40 -0700 Subject: Show peeled onion from upload-pack and server-info. This updates git-ls-remote to show SHA1 names of objects that are referred by tags, in the "ref^{}" notation. This would make git-findtags (without -t flag) almost trivial. git-peek-remote . | sed -ne "s:^$target "'refs/tags/\(.*\)^{}$:\1:p' Also Pasky could do: git-ls-remote --tags $remote | sed -ne 's:\( refs/tags/.*\)^{}$:\1:p' to find out what object each of the remote tags refers to, and if he has one locally, run "git-fetch $remote tag $tagname" to automatically catch up with the upstream tags. Signed-off-by: Junio C Hamano --- git-fetch.sh | 1 + server-info.c | 7 +++++++ upload-pack.c | 8 ++++++++ 3 files changed, 16 insertions(+) (limited to 'server-info.c') diff --git a/git-fetch.sh b/git-fetch.sh index 7c05880bcf..0cb1596f50 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -176,6 +176,7 @@ if test "$tags" then taglist=$(git-ls-remote --tags "$remote" | sed -e ' + /\^{}$/d s/^[^ ]* // s/.*/&:&/') if test "$#" -gt 1 diff --git a/server-info.c b/server-info.c index 3c08a288db..ba5359108d 100644 --- a/server-info.c +++ b/server-info.c @@ -9,7 +9,14 @@ static FILE *info_ref_fp; 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; } diff --git a/upload-pack.c b/upload-pack.c index 83f5a35d26..21b4b8b757 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1,6 +1,8 @@ #include "cache.h" #include "refs.h" #include "pkt-line.h" +#include "tag.h" +#include "object.h" static const char upload_pack_usage[] = "git-upload-pack "; @@ -165,7 +167,13 @@ static int receive_needs(void) static int send_ref(const char *refname, const unsigned char *sha1) { + struct object *o = parse_object(sha1); + packet_write(1, "%s %s\n", sha1_to_hex(sha1), refname); + if (o->type == tag_type) { + o = deref_tag(o); + packet_write(1, "%s %s^{}\n", sha1_to_hex(o->sha1), refname); + } return 0; } -- cgit v1.3-6-g1900