[PATCH 1/4] git-gc --auto: add pre-auto-gc hook

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Bj?rn Steinbrink <B.Steinbrink@...>, Junio C Hamano <gitster@...>, <git@...>
Date: Monday, March 31, 2008 - 5:35 am

If such a hook is available and exits with a non-zero status, then
git-gc --auto won't run.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 builtin-gc.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/builtin-gc.c b/builtin-gc.c
index 8cef36f..acd63be 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -157,6 +157,25 @@ static int too_many_packs(void)
 	return gc_auto_pack_limit <= cnt;
 }
 
+static int run_hook()
+{
+	const char *argv[2];
+	struct child_process hook;
+
+	argv[0] = git_path("hooks/pre-auto-gc");
+	argv[1] = NULL;
+
+	if (access(argv[0], X_OK) < 0)
+		return 0;
+
+	memset(&hook, 0, sizeof(hook));
+	hook.argv = argv;
+	hook.no_stdin = 1;
+	hook.stdout_to_stderr = 1;
+
+	return run_command(&hook);
+}
+
 static int need_to_gc(void)
 {
 	/*
@@ -176,6 +195,9 @@ static int need_to_gc(void)
 		append_option(argv_repack, "-A", MAX_ADD);
 	else if (!too_many_loose_objects())
 		return 0;
+
+	if (run_hook())
+		return 0;
 	return 1;
 }
 
-- 
1.5.5.rc2.4.g283c6

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] git gc --auto: defer on battery, Miklos Vajna, (Sun Mar 30, 7:14 pm)
Re: [PATCH] git gc --auto: defer on battery, Brandon Casey, (Mon Mar 31, 12:24 pm)
Re: [PATCH] git gc --auto: defer on battery, Miklos Vajna, (Mon Mar 31, 1:38 pm)
Re: [PATCH] git gc --auto: defer on battery, Brandon Casey, (Mon Mar 31, 2:31 pm)
Re: [PATCH] git gc --auto: defer on battery, Johannes Schindelin, (Sun Mar 30, 7:41 pm)
Re: [PATCH] git gc --auto: defer on battery, Miklos Vajna, (Sun Mar 30, 7:53 pm)
Re: [PATCH] git gc --auto: defer on battery, Björn, (Sun Mar 30, 7:26 pm)
Re: [PATCH] git gc --auto: defer on battery, Linus Torvalds, (Sun Mar 30, 7:46 pm)
Re: [PATCH] git gc --auto: defer on battery, Joey Hess, (Mon Mar 31, 2:08 pm)
[PATCH 4/4] templates: add an example pre-auto-gc hook, Miklos Vajna, (Mon Mar 31, 5:37 am)
Re: [PATCH 4/4] templates: add an example pre-auto-gc hook, Brian Gernhardt, (Mon Mar 31, 2:30 pm)
[PATCH 3/4] Documentation/hooks: add pre-auto-gc hook, Miklos Vajna, (Mon Mar 31, 5:36 am)
[PATCH 1/4] git-gc --auto: add pre-auto-gc hook, Miklos Vajna, (Mon Mar 31, 5:35 am)
[PATCH 0/4] add pre-auto-gc hook for git-gc --auto, Miklos Vajna, (Mon Mar 31, 5:35 am)
Re: [PATCH] git gc --auto: defer on battery, Junio C Hamano, (Sun Mar 30, 10:06 pm)
[PATCH] commit: resurrect "gc --auto" at the end, Johannes Schindelin, (Wed Apr 2, 9:40 am)
Re: [PATCH] commit: resurrect "gc --auto" at the end, Johannes Schindelin, (Wed May 14, 11:07 am)
Re: [PATCH] commit: resurrect "gc --auto" at the end, Junio C Hamano, (Wed May 14, 2:13 pm)
Re: [PATCH] commit: resurrect "gc --auto" at the end, Holger Schurig, (Thu May 15, 2:44 am)
Re: [PATCH] commit: resurrect "gc --auto" at the end, Johannes Schindelin, (Wed May 14, 2:40 pm)
Re: [PATCH] git gc --auto: defer on battery, Linus Torvalds, (Mon Mar 31, 11:02 am)
Re: [PATCH] git gc --auto: defer on battery, Björn, (Mon Mar 31, 12:43 pm)
fetchmail (Re: [PATCH] git gc --auto: defer on battery), Linus Torvalds, (Mon Mar 31, 1:00 pm)
Re: [PATCH] git gc --auto: defer on battery, Björn, (Sun Mar 30, 8:00 pm)
[PATCH] git gc --auto: defer on battery, Miklos Vajna, (Sun Mar 30, 7:39 pm)
Re: [PATCH] git gc --auto: defer on battery, Björn, (Sun Mar 30, 7:55 pm)