From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Lehmann Subject: [RFC PATCH] Teach checkout the -n|--dry-run option Date: Sat, 04 Sep 2010 22:19:50 +0200 Message-ID: <4C82A9E6.6050407@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: Junio C Hamano To: Git Mailing List X-From: git-owner@vger.kernel.org Sat Sep 04 22:20:06 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OrzDX-0001Jd-OK for gcvg-git-2@lo.gmane.org; Sat, 04 Sep 2010 22:20:04 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753475Ab0IDUT5 (ORCPT ); Sat, 4 Sep 2010 16:19:57 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:50962 "EHLO fmmailgate02.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336Ab0IDUT4 (ORCPT ); Sat, 4 Sep 2010 16:19:56 -0400 Received: from smtp06.web.de ( [172.20.5.172]) by fmmailgate02.web.de (Postfix) with ESMTP id 202A516F7233C; Sat, 4 Sep 2010 22:19:55 +0200 (CEST) Received: from [93.246.50.160] (helo=[192.168.178.29]) by smtp06.web.de with asmtp (WEB.DE 4.110 #24) id 1OrzDO-0007p9-00; Sat, 04 Sep 2010 22:19:54 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 X-Sender: Jens.Lehmann@web.de X-Provags-ID: V01U2FsdGVkX19pRcB8c3sgeVKQOnQogjiQi08KzK1GOSFkSufr Rj82cTU70O3ZRlnaUXrSHUtm1FDkRFCvOjx4JYoaiYDgshKC30 ecH7Ngk/BJip0tgwhImw== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: This option can be used to determine if checking out a branch or commit would touch files which are modified in the work tree. It doesn't change the work tree contents or the index, so it can only tell if the checkout would succeed using trivial merges. It can neither be used when checking out only certain paths nor together with the '-m' option. Signed-off-by: Jens Lehmann --- I need this new option for the recursive submodule checkout. Denying a checkout inside a submodule just because it has modifications is a too limiting condition (and it is way too expensive to check the whole tree, just looking at those paths going to be changed by the checkout should be much faster, especially for large submodules). IMO the same behavior that applies for a checkout in the superproject should apply for the checkout inside the submodule: no local changes may be overwritten by the checkout (and the HEAD must match the commit recorded in the superproject, but that is handled elsewhere). To be able to test that, I added the -n|--dry-run option to checkout. I think I found all relevant places, but a few more eyeballs are highly appreciated as I am not very familiar with this part of the code. A thing I'm not so sure about is the output of show_local_changes(), with -n it doesn't show the changes as they would have been *after* the - not executed - checkout but *without* having done it. Is that a problem here? Documentation/git-checkout.txt | 13 +++++++++++-- builtin/checkout.c | 20 +++++++++++++++----- t/t2018-checkout-branch.sh | 23 +++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index f88e997..32c5c77 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -8,8 +8,8 @@ git-checkout - Checkout a branch or paths to the working tree SYNOPSIS -------- [verse] -'git checkout' [-q] [-f] [-m] [] -'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] ] [] +'git checkout' [-q] [-f] [-m|-n] [] +'git checkout' [-q] [-f] [-m|-n] [[-b|-B|--orphan] ] [] 'git checkout' [-f|--ours|--theirs|-m|--conflict=