{"thread":{"id":"6122","subject":"[PATCH] Create 'git gc' to perform common maintenance operations.","startedAt":"2006-12-27T07:17:59Z","lastAt":"2006-12-27T18:46:03Z","messageCount":8,"participants":["Shawn O. Pearce","Junio C Hamano","Shawn Pearce","Martin Waitz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"30331","messageId":"20061227071759.GA23057@spearce.org","threadId":"6122","inReplyTo":null,"subject":"[PATCH] Create 'git gc' to perform common maintenance operations.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-27T07:17:59Z","receivedAt":"2006-12-27T07:17:59Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio asked for a 'git gc' utility which users can execute on a\nregular basis to perform basic repository actions such as:\n\n * pack-refs --prune\n * reflog expire\n * repack -a -d\n * prune\n * rerere gc\n\nSo here is a command which does exactly that.  The parameters fed\nto reflog's expire subcommand can be chosen by the user by setting\nconfiguration options in .git/config (or ~/.gitconfig), as users may\nwant different expiration windows for each repository but shouldn't\nbe bothered to remember what they are all of the time.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n This is a resend, as Linus pointed out prune runs faster if\n its done after the repack and not before.  Thanks Linus!\n\n .gitignore               |    1 +\n Documentation/git-gc.txt |   55 ++++++++++++++++++++++++++++++++++++++++++++++\n Makefile                 |    2 +-\n git-gc.sh                |   30 +++++++++++++++++++++++++\n 4 files changed, 87 insertions(+), 1 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex 91e6966..f92e359 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -41,6 +41,7 @@ git-fmt-merge-msg\n git-for-each-ref\n git-format-patch\n git-fsck-objects\n+git-gc\n git-get-tar-commit-id\n git-grep\n git-hash-object\ndiff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\nnew file mode 100644\nindex 0000000..a494b1f\n--- /dev/null\n+++ b/Documentation/git-gc.txt\n@@ -0,0 +1,55 @@\n+git-gc(1)\n+===========\n+\n+NAME\n+----\n+git-gc - Cleanup unnecessary files and optimize the local repository.\n+\n+\n+SYNOPSIS\n+--------\n+'git-gc'\n+\n+DESCRIPTION\n+-----------\n+Runs a number of housekeeping tasks within the current repository,\n+such as compressing file revisions (to reduce disk space and increase\n+performance) and removing unreachable objects which may have been\n+created from prior invocations of gitlink:git-add[1].\n+\n+Users are encouraged to run this task on a regular basis within\n+each repository to maintain good disk space utilization and good\n+operating performance.\n+\n+Configuration\n+-------------\n+\n+The optional configuration variable 'gc.reflogExpire' can be\n+set to indicate how long historical entries within each branch's\n+reflog should remain available in this repository.  The setting is\n+expressed as a length of time, for example '90 days' or '3 months'.\n+It defaults to '90 days'.\n+\n+The optional configuration variable 'gc.reflogExpireUnreachable'\n+can be set to indicate how long historical reflog entries which\n+are not part of the current branch should remain available in\n+this repository.  These types of entries are generally created as\n+a result of using `git commit \\--amend` or `git rebase` and are the\n+commits prior to the amend or rebase occuring.  Since these changes\n+are not part of the current project most users will want to expire\n+them sooner.  This option defaults to '60 days'.\n+\n+See Also\n+--------\n+gitlink:git-prune[1]\n+gitlink:git-repack[1]\n+gitlink:git-rerere[1]\n+\n+Author\n+------\n+Written by Shawn O. Pearce <spearce@spearce.org>\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\n+\ndiff --git a/Makefile b/Makefile\nindex b8b746f..fb6ba27 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -157,7 +157,7 @@ BASIC_LDFLAGS =\n SCRIPT_SH = \\\n \tgit-bisect.sh git-checkout.sh \\\n \tgit-clean.sh git-clone.sh git-commit.sh \\\n-\tgit-fetch.sh \\\n+\tgit-fetch.sh git-gc.sh \\\n \tgit-ls-remote.sh \\\n \tgit-merge-one-file.sh git-parse-remote.sh \\\n \tgit-pull.sh git-rebase.sh \\\ndiff --git a/git-gc.sh b/git-gc.sh\nnew file mode 100755\nindex 0000000..8b1172b\n--- /dev/null\n+++ b/git-gc.sh\n@@ -0,0 +1,30 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2006, Shawn O. Pearce\n+#\n+# Cleanup unreachable files and optimize the repository.\n+\n+USAGE=''\n+SUBDIRECTORY_OK=Yes\n+. git-sh-setup\n+\n+reflog_expire=$(git-repo-config gc.reflogExpire)\n+if [ -z \"$reflog_expire\" ]\n+then\n+\treflog_expire=\"90 days\"\n+fi\n+\n+reflog_unreachable=$(git-repo-config gc.reflogExpireUnreachable)\n+if [ -z \"$reflog_unreachable\" ]\n+then\n+\treflog_unreachable=\"60 days\"\n+fi\n+\n+git-pack-refs --prune &&\n+git-reflog expire \\\n+\t--expire=\"$reflog_expire\" \\\n+\t--expire-unreachable=\"$reflog_unreachable\" \\\n+\t--all &&\n+git-repack -a -d &&\n+git-prune &&\n+git-rerere gc || exit\n-- \n1.4.4.3.gd2e4\n"},{"id":"30334","messageId":"7vr6ul93wz.fsf@assigned-by-dhcp.cox.net","threadId":"6122","inReplyTo":"20061227071759.GA23057@spearce.org","subject":"Re: [PATCH] Create 'git gc' to perform common maintenance operations.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-27T07:46:52Z","receivedAt":"2006-12-27T07:46:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> +The optional configuration variable 'gc.reflogExpireUnreachable'\n> +can be set to indicate how long historical reflog entries which\n> +are not part of the current branch should remain available in\n> +this repository.  These types of entries are generally created as\n> +a result of using `git commit \\--amend` or `git rebase` and are the\n> +commits prior to the amend or rebase occuring.  Since these changes\n> +are not part of the current project most users will want to expire\n> +them sooner.  This option defaults to '60 days'.\n\nShould I update the default expire-unreachable in builtin-reflog\nto match 60 days?\n"},{"id":"30335","messageId":"20061227075330.GA23022@spearce.org","threadId":"6122","inReplyTo":"7vr6ul93wz.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Create 'git gc' to perform common maintenance operations.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-27T07:53:30Z","receivedAt":"2006-12-27T07:53:30Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> \n> > +The optional configuration variable 'gc.reflogExpireUnreachable'\n> > +can be set to indicate how long historical reflog entries which\n> > +are not part of the current branch should remain available in\n> > +this repository.  These types of entries are generally created as\n> > +a result of using `git commit \\--amend` or `git rebase` and are the\n> > +commits prior to the amend or rebase occuring.  Since these changes\n> > +are not part of the current project most users will want to expire\n> > +them sooner.  This option defaults to '60 days'.\n> \n> Should I update the default expire-unreachable in builtin-reflog\n> to match 60 days?\n\nDoh, I meant for git-gc to match the default in 'git-reflog expire'.\nWhoops.\n\nI don't care either way.  60 days may be too long for some users,\nbut for others it may be nice to have.  I think the two defaults\nshould match just because.  Feel free to edit my patch before\napplying to be whatever 'git-reflog expire' uses if you want.\n\n-- \nShawn.\n"},{"id":"30338","messageId":"7vhcvh922r.fsf@assigned-by-dhcp.cox.net","threadId":"6122","inReplyTo":"20061227075330.GA23022@spearce.org","subject":"Re: [PATCH] Create 'git gc' to perform common maintenance operations.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-27T08:26:36Z","receivedAt":"2006-12-27T08:26:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shawn Pearce <spearce@spearce.org> writes:\n\n> I don't care either way.  60 days may be too long for some users,\n> but for others it may be nice to have.  I think the two defaults\n> should match just because.  Feel free to edit my patch before\n> applying to be whatever 'git-reflog expire' uses if you want.\n\nI think the built-in git-reflog should be updated to honor the\nconfiguration in the absense of command line options; if we do\nthat git-gc.sh does not even have to call repo-config anymore.\n"},{"id":"30339","messageId":"20061227083328.GD23022@spearce.org","threadId":"6122","inReplyTo":"7vhcvh922r.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Create 'git gc' to perform common maintenance operations.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-12-27T08:33:28Z","receivedAt":"2006-12-27T08:33:28Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Shawn Pearce <spearce@spearce.org> writes:\n> \n> > I don't care either way.  60 days may be too long for some users,\n> > but for others it may be nice to have.  I think the two defaults\n> > should match just because.  Feel free to edit my patch before\n> > applying to be whatever 'git-reflog expire' uses if you want.\n> \n> I think the built-in git-reflog should be updated to honor the\n> configuration in the absense of command line options; if we do\n> that git-gc.sh does not even have to call repo-config anymore.\n\nSure, but then maybe the configuration options shouldn't be\n'gc.reflog*' but instead 'reflog.*'.\n\ngit-gc.sh was a quick hack while I was waiting for that huge disk\nIO to repack a git.git with 1.3.3.  I was trying to avoid hacking\nC code for it, but you are probably right, better to just make the\nC code do the right thing from \"day one\".\n\n-- \nShawn.\n"},{"id":"30340","messageId":"7v8xgt9026.fsf@assigned-by-dhcp.cox.net","threadId":"6122","inReplyTo":"20061227083328.GD23022@spearce.org","subject":"Re: [PATCH] Create 'git gc' to perform common maintenance operations.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-27T09:10:09Z","receivedAt":"2006-12-27T09:10:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shawn Pearce <spearce@spearce.org> writes:\n\n> Junio C Hamano <junkio@cox.net> wrote:\n>> Shawn Pearce <spearce@spearce.org> writes:\n>> \n>> > I don't care either way.  60 days may be too long for some users,\n>> > but for others it may be nice to have.  I think the two defaults\n>> > should match just because.  Feel free to edit my patch before\n>> > applying to be whatever 'git-reflog expire' uses if you want.\n>> \n>> I think the built-in git-reflog should be updated to honor the\n>> configuration in the absense of command line options; if we do\n>> that git-gc.sh does not even have to call repo-config anymore.\n>\n> Sure, but then maybe the configuration options shouldn't be\n> 'gc.reflog*' but instead 'reflog.*'.\n\nActually I think gc.reflog, gc.rerere and friends make more\nsense.  In other words, I think it is better to match the\nconfiguration group to what the end user primarily sees, which\nis \"gc\"; \"reflog expire\" and \"rerere gc\" are implementation\ndetails of it.\n"},{"id":"30351","messageId":"20061227131113.GB6115@admingilde.org","threadId":"6122","inReplyTo":"20061227071759.GA23057@spearce.org","subject":"Re: [PATCH] Create 'git gc' to perform common maintenance operations.","fromName":"Martin Waitz","fromEmail":"tali@admingilde.org","sentAt":"2006-12-27T13:11:13Z","receivedAt":"2006-12-27T13:11:13Z","isPatch":true,"sender":{"key":"tali@admingilde.org","avatar":"https://gravatar.com/avatar/3f89b03eee362187effabe257898735b475673a12265c398ea9161259ae91553?d=mp&s=160"},"body":"hoi :)\n\nOn Wed, Dec 27, 2006 at 02:17:59AM -0500, Shawn O. Pearce wrote:\n> Junio asked for a 'git gc' utility which users can execute on a\n> regular basis to perform basic repository actions such as:\n> \n>  * pack-refs --prune\n>  * reflog expire\n>  * repack -a -d\n\nwhat about doing \"git-repack -a -d -l\" by default?\n\n-- \nMartin Waitz\n"},{"id":"30356","messageId":"7vr6ul6utw.fsf@assigned-by-dhcp.cox.net","threadId":"6122","inReplyTo":"20061227131113.GB6115@admingilde.org","subject":"Re: [PATCH] Create 'git gc' to perform common maintenance operations.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-27T18:46:03Z","receivedAt":"2006-12-27T18:46:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin Waitz <tali@admingilde.org> writes:\n\n> On Wed, Dec 27, 2006 at 02:17:59AM -0500, Shawn O. Pearce wrote:\n>> Junio asked for a 'git gc' utility which users can execute on a\n>> regular basis to perform basic repository actions such as:\n>> \n>>  * pack-refs --prune\n>>  * reflog expire\n>>  * repack -a -d\n>\n> what about doing \"git-repack -a -d -l\" by default?\n\nI think that is sensible.\n"}]}