git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-gc: by default use safer "-A" option to repack when not --prune'ing

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Oct 11, 2007, 00:59 UTC
Message-ID
<470D7567.6010208@nrlssc.navy.mil>
In-Reply-To
<Pine.LNX.4.64.0710110149100.4174@racer.site>

This makes use of repack's new "-A" option which does not drop packed unreachable objects. This makes git-gc safe to call at any time, particularly when a repository is referenced as an alternate by another repository.

git-gc --prune will use the "-a" option to repack instead of "-A", so that packed unreachable objects will be removed.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 builtin-gc.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/builtin-gc.c b/builtin-gc.c
index 23ad2b6..6323e0d 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -26,7 +26,7 @@ static int gc_auto_pack_limit = 20;
 #define MAX_ADD 10
 static const char *argv_pack_refs[] = {"pack-refs", "--all", "--prune", NULL};
 static const char *argv_reflog[] = {"reflog", "expire", "--all", NULL};
-static const char *argv_repack[MAX_ADD] = {"repack", "-a", "-d", "-l", NULL};
+static const char *argv_repack[MAX_ADD] = {"repack", "-d", "-l", NULL};
 static const char *argv_prune[] = {"prune", NULL};
 static const char *argv_rerere[] = {"rerere", "gc", NULL};
 
@@ -211,6 +211,16 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
 		prune = 0;
 		if (!need_to_gc())
 			return 0;
+	} else {
+		/*
+		 * Use safer (for shared repos) "-A" option to
+		 * repack when not pruning. Auto-gc makes its
+		 * own decision.
+		 */
+		if (prune)
+			append_option(argv_repack, "-a", MAX_ADD);
+		else
+			append_option(argv_repack, "-A", MAX_ADD);
 	}
 
 	if (pack_refs && run_command_v_opt(argv_pack_refs, RUN_GIT_CMD))
-- 
1.5.3.4.208.g729c0
Previous: Johannes SchindelinNext: Brandon Casey
Message 5 of 6 in “git-gc: by default use safer "-A" option to repack when not --prune'ing”
  1. git-gc: by default use safer "-A" option to repack when not --prune'ingBrandon Casey, Oct 10, 2007
  2. Johannes SchindelinOct 11, 2007
  3. Brandon CaseyOct 11, 2007
  4. Johannes SchindelinOct 11, 2007
  5. Brandon CaseyOct 11, 2007
  6. git-gc --auto: simplify "repack" command line buildingBrandon Casey, Oct 11, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.