From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: Re: Rollback of git commands Date: Tue, 27 Nov 2007 16:51:59 -0800 Message-ID: <7vmyszb39s.fsf@gitster.siamese.dyndns.org> References: <9e4733910711271523p3be94010jac9c79e6b95f010d@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Git Mailing List" To: "Jon Smirl" X-From: git-owner@vger.kernel.org Wed Nov 28 01:52:43 2007 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1IxBAM-00045c-Bx for gcvg-git-2@gmane.org; Wed, 28 Nov 2007 01:52:38 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759295AbXK1AwG (ORCPT ); Tue, 27 Nov 2007 19:52:06 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759266AbXK1AwG (ORCPT ); Tue, 27 Nov 2007 19:52:06 -0500 Received: from sceptre.pobox.com ([207.106.133.20]:35425 "EHLO sceptre.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759189AbXK1AwF (ORCPT ); Tue, 27 Nov 2007 19:52:05 -0500 Received: from sceptre (localhost.localdomain [127.0.0.1]) by sceptre.pobox.com (Postfix) with ESMTP id D1A2C2FA; Tue, 27 Nov 2007 19:52:25 -0500 (EST) Received: from pobox.com (ip68-225-240-77.oc.oc.cox.net [68.225.240.77]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by sceptre.sasl.smtp.pobox.com (Postfix) with ESMTP id 600C09A835; Tue, 27 Nov 2007 19:52:23 -0500 (EST) In-Reply-To: <9e4733910711271523p3be94010jac9c79e6b95f010d@mail.gmail.com> (Jon Smirl's message of "Tue, 27 Nov 2007 18:23:35 -0500") 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: "Jon Smirl" writes: > Could a rollback log be implemented in git? It would make things way > easier when you screw something up. You'd only roll back things that > impacted the object store, not things like checkout. The object store is append only, and if you disregard SHA-1 collisions, I do not think there is much you can gain from being able to roll back only object store. For example, you would want to be able to roll back where your 'master' branch was pointing at before you started that botched operation. That is not in the object store at all (we have reflogs for that). Another example, you might have done quite an elaborate interactive add to stage only some changes to a path, but then accidentally said "git add" that path to stage the whole thing. You may say "oops, that state was only in the index and now it is lost." The blob that records the staged content _DOES_ exist in the object store in such a case so it is not lost --- there is nothing to roll back. What you lost is a pointer into the object store (we do not have anything like reflog for individual index entry --- not that I would suggest adding one). Creating a blob that records all of .git/config, output from for-each-ref, output from "symbolic-ref HEAD" and output from ls-files -s every time you run _any_ git operation, and restore the state when you want to, would conceptually work, as you suggest, but I am not sure how practical it would be, performancewise, spacewise, and semanticswise.