From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: Ramkumar Ramachandra <artagnon@gmail.com>,
David Barr <david.barr@cordelta.com>
Subject: [PATCH 8/8] Remove pack file handling dependency from wrapper.o
Date: Sat, 6 Nov 2010 06:52:37 -0500 [thread overview]
Message-ID: <20101106115237.GH27641@burratino> (raw)
In-Reply-To: <20101106113905.GA27405@burratino>
Commands that might access a git repository should discard pack
windows when memory is tight, but helpers like show-index do not need
to.
So stop setting try_to_free_pack_memory as the default
try_to_free_routine and instead set up the try_to_free handler
explicitly in main() for callers that require it.
After this change, a simple program using xmalloc() and no other
functions will not pull in any code from libgit.a aside from wrapper.o
and usage.o.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Thanks for reading. I hope it was not too dull.
Hopefully this will make svn-fe small again (it got big when the
vcs-svn lib started using strbufs).
Good night,
Jonathan
check-racy.c | 1 +
contrib/convert-objects/convert-objects.c | 1 +
daemon.c | 1 +
fast-import.c | 1 +
git.c | 2 ++
http-backend.c | 1 +
http-fetch.c | 1 +
http-push.c | 1 +
imap-send.c | 1 +
remote-curl.c | 1 +
test-dump-cache-tree.c | 4 +++-
test-match-trees.c | 1 +
upload-pack.c | 1 +
wrapper.c | 6 +++++-
14 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/check-racy.c b/check-racy.c
index 00d92a1..d4b2557 100644
--- a/check-racy.c
+++ b/check-racy.c
@@ -6,6 +6,7 @@ int main(int ac, char **av)
int dirty, clean, racy;
dirty = clean = racy = 0;
+ set_try_to_free_routine(try_to_free_pack_memory);
read_cache();
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
diff --git a/contrib/convert-objects/convert-objects.c b/contrib/convert-objects/convert-objects.c
index f3b57bf..983b917 100644
--- a/contrib/convert-objects/convert-objects.c
+++ b/contrib/convert-objects/convert-objects.c
@@ -317,6 +317,7 @@ int main(int argc, char **argv)
struct entry *entry;
setup_git_directory();
+ set_try_to_free_routine(try_to_free_pack_memory);
if (argc != 2)
usage("git-convert-objects <sha1>");
diff --git a/daemon.c b/daemon.c
index 9326d3a..ccf8960 100644
--- a/daemon.c
+++ b/daemon.c
@@ -976,6 +976,7 @@ int main(int argc, char **argv)
int i;
git_extract_argv0_path(argv[0]);
+ set_try_to_free_routine(try_to_free_pack_memory);
for (i = 1; i < argc; i++) {
char *arg = argv[i];
diff --git a/fast-import.c b/fast-import.c
index eab68d5..ccf81b1 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -2917,6 +2917,7 @@ int main(int argc, const char **argv)
unsigned int i;
git_extract_argv0_path(argv[0]);
+ set_try_to_free_routine(try_to_free_pack_memory);
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(fast_import_usage);
diff --git a/git.c b/git.c
index 0409ac9..6386404 100644
--- a/git.c
+++ b/git.c
@@ -272,6 +272,8 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
trace_argv_printf(argv, "trace: built-in: git");
+ set_try_to_free_routine(try_to_free_pack_memory);
+
status = p->fn(argc, argv, prefix);
if (status)
return status;
diff --git a/http-backend.c b/http-backend.c
index 14c90c2..7d02e55 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -551,6 +551,7 @@ int main(int argc, char **argv)
int i;
git_extract_argv0_path(argv[0]);
+ set_try_to_free_routine(try_to_free_pack_memory);
set_die_routine(die_webcgi);
if (!method)
diff --git a/http-fetch.c b/http-fetch.c
index 762c750..98cefc7 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -25,6 +25,7 @@ int main(int argc, const char **argv)
int get_recover = 0;
git_extract_argv0_path(argv[0]);
+ set_try_to_free_routine(try_to_free_pack_memory);
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
diff --git a/http-push.c b/http-push.c
index c9bcd11..fc25aeb 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1792,6 +1792,7 @@ int main(int argc, char **argv)
char *rewritten_url = NULL;
git_extract_argv0_path(argv[0]);
+ set_try_to_free_routine(try_to_free_pack_memory);
repo = xcalloc(sizeof(*repo), 1);
diff --git a/imap-send.c b/imap-send.c
index 71506a8..8056144 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1538,6 +1538,7 @@ int main(int argc, char **argv)
int nongit_ok;
git_extract_argv0_path(argv[0]);
+ set_try_to_free_routine(try_to_free_pack_memory);
if (argc != 1)
usage(imap_send_usage);
diff --git a/remote-curl.c b/remote-curl.c
index 04d4813..4c2b03a 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -788,6 +788,7 @@ int main(int argc, const char **argv)
int nongit;
git_extract_argv0_path(argv[0]);
+ set_try_to_free_routine(try_to_free_pack_memory);
setup_git_directory_gently(&nongit);
if (argc < 2) {
fprintf(stderr, "Remote needed\n");
diff --git a/test-dump-cache-tree.c b/test-dump-cache-tree.c
index 1f73f1e..a6faa89 100644
--- a/test-dump-cache-tree.c
+++ b/test-dump-cache-tree.c
@@ -56,7 +56,9 @@ static int dump_cache_tree(struct cache_tree *it,
int main(int ac, char **av)
{
- struct cache_tree *another = cache_tree();
+ struct cache_tree *another;
+ set_try_to_free_routine(try_to_free_pack_memory);
+ another = cache_tree();
if (read_cache() < 0)
die("unable to read index file");
cache_tree_update(another, active_cache, active_nr, 0, 1);
diff --git a/test-match-trees.c b/test-match-trees.c
index a3c4688..c543fee 100644
--- a/test-match-trees.c
+++ b/test-match-trees.c
@@ -6,6 +6,7 @@ int main(int ac, char **av)
unsigned char hash1[20], hash2[20], shifted[20];
struct tree *one, *two;
+ set_try_to_free_routine(try_to_free_pack_memory);
if (get_sha1(av[1], hash1))
die("cannot parse %s as an object name", av[1]);
if (get_sha1(av[2], hash2))
diff --git a/upload-pack.c b/upload-pack.c
index f05e422..d654e8b 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -683,6 +683,7 @@ int main(int argc, char **argv)
int strict = 0;
git_extract_argv0_path(argv[0]);
+ set_try_to_free_routine(try_to_free_pack_memory);
read_replace_refs = 0;
for (i = 1; i < argc; i++) {
diff --git a/wrapper.c b/wrapper.c
index 6c6579b..4c1639f 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -3,7 +3,11 @@
*/
#include "cache.h"
-static void (*try_to_free_routine)(size_t size) = try_to_free_pack_memory;
+static void do_nothing(size_t size)
+{
+}
+
+static void (*try_to_free_routine)(size_t size) = do_nothing;
try_to_free_t set_try_to_free_routine(try_to_free_t routine)
{
--
1.7.2.3.557.gab647.dirty
next prev parent reply other threads:[~2010-11-06 11:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-06 11:39 [PATCH/RFC 0/8] Remove various dependencies from wrapper.o Jonathan Nieder
2010-11-06 11:44 ` [PATCH 1/8] wrapper: move xmmap() to sha1_file.c Jonathan Nieder
2010-11-06 11:45 ` [PATCH 2/8] wrapper: move odb_* to environment.c Jonathan Nieder
2010-11-06 11:46 ` [PATCH 3/8] path helpers: move git_mkstemp* to wrapper.c Jonathan Nieder
2010-11-06 11:46 ` [PATCH 4/8] strbuf: move strbuf_branchname to sha1_name.c Jonathan Nieder
2010-11-06 11:47 ` [PATCH 5/8] wrapper: give zlib wrappers their own translation unit Jonathan Nieder
2010-11-06 11:47 ` [PATCH 6/8] pack-objects: mark file-local variable static Jonathan Nieder
2010-11-06 11:48 ` [PATCH 7/8] wrapper: expose try_to_free_pack_memory() Jonathan Nieder
2010-11-06 11:52 ` Jonathan Nieder [this message]
2010-11-06 18:07 ` [PATCH 8/8] Remove pack file handling dependency from wrapper.o René Scharfe
2010-11-06 18:42 ` Jonathan Nieder
2010-11-07 16:10 ` René Scharfe
2010-11-07 18:23 ` Jonathan Nieder
2010-11-06 19:00 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101106115237.GH27641@burratino \
--to=jrnieder@gmail.com \
--cc=artagnon@gmail.com \
--cc=david.barr@cordelta.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.