From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Lehmann Subject: [PATCH] Teach checkout the -n|--dry-run option Date: Sat, 07 May 2011 00:12:18 +0200 Message-ID: <4DC47242.6060205@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: Git Mailing List To: Junio C Hamano X-From: git-owner@vger.kernel.org Sat May 07 00:12:27 2011 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 1QITG6-0001Z8-Fm for gcvg-git-2@lo.gmane.org; Sat, 07 May 2011 00:12:27 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751897Ab1EFWMV (ORCPT ); Fri, 6 May 2011 18:12:21 -0400 Received: from fmmailgate03.web.de ([217.72.192.234]:41945 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751417Ab1EFWMU (ORCPT ); Fri, 6 May 2011 18:12:20 -0400 Received: from smtp07.web.de ( [172.20.5.215]) by fmmailgate03.web.de (Postfix) with ESMTP id 75C4418E1F682; Sat, 7 May 2011 00:12:18 +0200 (CEST) Received: from [93.246.59.164] (helo=[192.168.178.43]) by smtp07.web.de with asmtp (WEB.DE 4.110 #2) id 1QITFy-0003yp-00; Sat, 07 May 2011 00:12:18 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 X-Sender: Jens.Lehmann@web.de X-Provags-ID: V01U2FsdGVkX18ifQCM2dyIq7IOEiPSE+1LGZ1P+mDP4uI0zdUJ MAQNSxCl3wsuCyNV/jET+b/71pnePpyGH5cea7jAQqXJmWbO+X euC5qJT8cr8xiMhMSmfQ== 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 --- This is a repost of a RFC patch from Sep 04, 2010 I did not receive any responses upon: 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 | 15 ++++++++++++--- builtin/checkout.c | 20 +++++++++++++++----- t/t2018-checkout-branch.sh | 23 +++++++++++++++++++++++ 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 1063f69..ae58762 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -8,9 +8,9 @@ git-checkout - Checkout a branch or paths to the working tree SYNOPSIS -------- [verse] -'git checkout' [-q] [-f] [-m] [] -'git checkout' [-q] [-f] [-m] [--detach] [] -'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] ] [] +'git checkout' [-q] [-f] [-m|-n] [] +'git checkout' [-q] [-f] [-m|-n] [--detach] [] +'git checkout' [-q] [-f] [-m|-n] [[-b|-B|--orphan] ] [] 'git checkout' [-f|--ours|--theirs|-m|--conflict=