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

Re: [PATCH] prune: --expire=time

From
Junio C Hamano <junkio@cox.net>
Date
Jan 22, 2007, 05:17 UTC
Message-ID
<7v3b63wsh3.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0701211851310.14248@woody.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> ... I at the same time have to 
> admit that I worry about loose objects (and scary messages from 
> git-fsck-objects) potentially confusing new people.

I've been annoyed by those scary messages fsck-objects enough and was wondering if we could make it less scary. Especially annoying is that the message about missing blobs and trees that are only referred to by dangling commits.

> So hiding "git prune" behind "git gc" is probably a good thing (make 
> people learn just one thing they need to interface to), but maybe we need 
> a "--prune" flag to the gc command, and then perhaps just document that 
> you should be careful.
I am still undecided which one should be the default.

For interactive use by developers who work in their own repositories, git-prune is safe because nothing else would be working on their repositories at the time. While I do not think we should recommend using git-gc from a cron job, if they want to do so, giving an extra --no-prune option in their cron script would be much less annoying.

-- >8 -- [PATCH] git-gc: do not run prune mindlessly.

You should pass --no-prune if you ever want to run git-gc from a cron job.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 Documentation/git-gc.txt |   15 +++++++++++++--
 git-gc.sh                |   18 ++++++++++++++++--
 2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt
index 2bcc949..7b650a7 100644
--- a/Documentation/git-gc.txt
+++ b/Documentation/git-gc.txt
@@ -8,7 +8,7 @@ git-gc - Cleanup unnecessary files and optimize the local repository
 
 SYNOPSIS
 --------
-'git-gc'
+'git-gc' [--no-prune]
 
 DESCRIPTION
 -----------
@@ -21,6 +21,18 @@ Users are encouraged to run this task on a regular basis within
 each repository to maintain good disk space utilization and good
 operating performance.
 
+OPTIONS
+-------
+
+--no-prune::
+	Usually `git-gc` packs refs, expires old reflog entries,
+	packs loose objects, removes unreferenced loose objects,
+	and removes old 'rerere' records.  Among these, removal
+	of unreferenced loose objects is an unsafe operation
+	while other git operations are in progress.  This option
+	disables this unsafe step.
+
+
 Configuration
 -------------
 
@@ -50,7 +62,6 @@ kept.  This defaults to 15 days.
 
 See Also
 --------
-gitlink:git-prune[1]
 gitlink:git-reflog[1]
 gitlink:git-repack[1]
 gitlink:git-rerere[1]
diff --git a/git-gc.sh b/git-gc.sh
index 6de55f7..ecd4b0e 100755
--- a/git-gc.sh
+++ b/git-gc.sh
@@ -4,12 +4,26 @@
 #
 # Cleanup unreachable files and optimize the repository.
 
-USAGE=''
+USAGE='git-gc [--no-prune]'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 
+no_prune=
+while case $# in 0) break ;; esac
+do
+	case "$1" in
+	--no-prune)
+		no_prune=:
+		;;
+	--)
+		usage
+		;;
+	esac
+	shift
+done
+
 git-pack-refs --prune &&
 git-reflog expire --all &&
 git-repack -a -d -l &&
-git-prune &&
+$no_prune git-prune &&
 git-rerere gc || exit
-- 
1.5.0.rc2
Previous: Linus TorvaldsNext: Linus Torvalds
Message 23 of 30 in “prune-packed: new option --min-age=N”
  1. prune-packed: new option --min-age=NMatthias Lederhofer, Jan 18, 2007
  2. Shawn O. PearceJan 18, 2007
  3. Matthias LederhoferJan 18, 2007
  4. Shawn O. PearceJan 18, 2007
  5. [RFC] prune: --expire=secondsMatthias Lederhofer, Jan 18, 2007
  6. Junio C HamanoJan 18, 2007
  7. Shawn O. PearceJan 19, 2007
  8. prune: --expire=timeMatthias Lederhofer, Jan 19, 2007
  9. Nicolas PitreJan 19, 2007
  10. Junio C HamanoJan 19, 2007
  11. Matthias LederhoferJan 20, 2007
  12. Junio C HamanoJan 21, 2007
  13. Shawn O. PearceJan 21, 2007
  14. Matthias LederhoferJan 21, 2007
  15. Junio C HamanoJan 21, 2007
  16. Jeff KingJan 21, 2007
  17. Steven GrimmJan 22, 2007
  18. Jeff KingJan 22, 2007
  19. Junio C HamanoJan 22, 2007
  20. Linus TorvaldsJan 22, 2007
  21. Junio C HamanoJan 22, 2007
  22. Linus TorvaldsJan 22, 2007
  23. Junio C HamanoJan 22, 2007
  24. Linus TorvaldsJan 22, 2007
  25. Shawn O. PearceJan 22, 2007
  26. Junio C HamanoJan 22, 2007
  27. Jakub NarebskiJan 22, 2007
  28. v1.5.0.txt: update description of git-gcJeff King, Jan 22, 2007
  29. Junio C HamanoJan 22, 2007
  30. Simon 'corecode' SchubertJan 20, 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.