From: Junio C Hamano Subject: [PATCH 5/5] reflog expire --fix-stale Date: Sat, 06 Jan 2007 02:16:19 -0800 Message-ID: <7vodpc5uks.fsf@assigned-by-dhcp.cox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-From: git-owner@vger.kernel.org Sat Jan 06 11:16:37 2007 Return-path: Envelope-to: gcvg-git@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1H38bJ-0001Uy-Uw for gcvg-git@gmane.org; Sat, 06 Jan 2007 11:16:34 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751333AbXAFKQX (ORCPT ); Sat, 6 Jan 2007 05:16:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751325AbXAFKQW (ORCPT ); Sat, 6 Jan 2007 05:16:22 -0500 Received: from fed1rmmtao02.cox.net ([68.230.241.37]:54967 "EHLO fed1rmmtao02.cox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751333AbXAFKQV (ORCPT ); Sat, 6 Jan 2007 05:16:21 -0500 Received: from fed1rmimpo02.cox.net ([70.169.32.72]) by fed1rmmtao02.cox.net (InterMail vM.6.01.06.03 201-2131-130-104-20060516) with ESMTP id <20070106101620.JIGH97.fed1rmmtao02.cox.net@fed1rmimpo02.cox.net>; Sat, 6 Jan 2007 05:16:20 -0500 Received: from assigned-by-dhcp.cox.net ([68.5.247.80]) by fed1rmimpo02.cox.net with bizsmtp id 7mGb1W00N1kojtg0000000; Sat, 06 Jan 2007 05:16:36 -0500 To: git@vger.kernel.org User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: The logic in an earlier round to detect reflog entries that point at a broken commit was not sufficient. Just like we do not trust presense of a commit during pack transfer (we trust only our refs), we should not trust a commit's presense, even if the tree of that commit is complete. A repository that had reflog enabled on some of the refs that was rewound and then run git-repack or git-prune from older versions of git can have reflog entries that point at a commit that still exist but lack commits (or trees and blobs needed for that commit) between it and some commit that is reachable from one of the refs. This revamps the logic -- the definition of "broken commit" becomes: a commit that is not reachable from any of the refs and there is a missing object among the commit, tree, or blob objects reachable from it that is not reachable from any of the refs. Entries in the reflog that refer to such a commit are expired. Since this computation involves traversing all the reachable objects, i.e. it has the same cost as 'git prune', it is enabled only when a new option --fix-stale. Fortunately, once this is run, we should not have to ever worry about missing objects, because the current prune and pack-objects know about reflogs and protect objects referred by them. Unfortunately, this will be absolutely necessary to help people migrate to the newer prune and repack. Signed-off-by: Junio C Hamano --- builtin-reflog.c | 159 +++++++++++++++++++++++++++++++++++++++++++------- t/t1410-reflog.sh | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 308 insertions(+), 21 deletions(-) diff --git a/builtin-reflog.c b/builtin-reflog.c index d3f2f50..1da7da0 100644 --- a/builtin-reflog.c +++ b/builtin-reflog.c @@ -4,16 +4,34 @@ #include "refs.h" #include "dir.h" #include "tree-walk.h" +#include "diff.h" +#include "revision.h" +#include "reachable.h" + +/* + * reflog expire + */ + +static const char reflog_expire_usage[] = +"git-reflog expire [--verbose] [--dry-run] [--fix-stale] [--expire=