From mboxrd@z Thu Jan 1 00:00:00 1970 From: Felipe Contreras Subject: [PATCH v2 13/14] reset: allow --keep with --stage Date: Mon, 14 Oct 2013 17:29:25 -0500 Message-ID: <1381789769-9893-11-git-send-email-felipe.contreras@gmail.com> References: <1381789769-9893-1-git-send-email-felipe.contreras@gmail.com> Cc: Piotr Krukowiecki , Jay Soffian , Jonathan Nieder , Philip Oakley , Matthieu Moy , William Swanson , Ping Yin , Hilco Wijbenga , Miles Bader , Felipe Contreras To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Tue Oct 15 00:36:29 2013 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VVqkW-0007Oh-As for gcvg-git-2@plane.gmane.org; Tue, 15 Oct 2013 00:36:28 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932263Ab3JNWgS (ORCPT ); Mon, 14 Oct 2013 18:36:18 -0400 Received: from mail-oa0-f42.google.com ([209.85.219.42]:59003 "EHLO mail-oa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932218Ab3JNWgO (ORCPT ); Mon, 14 Oct 2013 18:36:14 -0400 Received: by mail-oa0-f42.google.com with SMTP id k14so1242862oag.15 for ; Mon, 14 Oct 2013 15:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l3+oVgeYwGrwMweYjMi8Zq27EiMSe+K6cbeCM+Huxe0=; b=jMwaykDHymLdvAIOy2Dnzbv/HopxTQwd16enFwE8j60UQhPcsuzBbiaTGzDtnNLsi5 SgwPRhCLwQD14wtOHax6FFNJMT+QE8ghXQ5+jMQTI3In7Cp3ZNmi538r31O8Q6ThiSuu dR7wuQOoLU8273LOzXEiYxXvay2eN3P3mIazum2zilAgXOh13vVIMbh/RqJFEUisoEED Lnj7zohigfoSUCtZKbx9M3B57SDQfu/mLpN6wbm7/wMkmqAMtsNcN+lYl1VZ74u6oTdt gtvBjXRHtjyf6hxXmXiS1W3VCq11S7k2eOKvW+FcGNhTqJX+iVVj5iC1X79qq3/9mRRF A8kQ== X-Received: by 10.182.18.9 with SMTP id s9mr22843894obd.15.1381790174226; Mon, 14 Oct 2013 15:36:14 -0700 (PDT) Received: from localhost (187-162-140-241.static.axtel.net. [187.162.140.241]) by mx.google.com with ESMTPSA id s9sm44533730obu.4.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Oct 2013 15:36:13 -0700 (PDT) X-Mailer: git-send-email 1.8.4-fc In-Reply-To: <1381789769-9893-1-git-send-email-felipe.contreras@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Signed-off-by: Felipe Contreras --- Documentation/git-reset.txt | 2 +- builtin/reset.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt index 5cd75a8..a1419c9 100644 --- a/Documentation/git-reset.txt +++ b/Documentation/git-reset.txt @@ -11,7 +11,7 @@ SYNOPSIS 'git reset' [-q] [] [--] ... 'git reset' (--patch | -p) [] [--] [...] 'git reset' [--soft | --mixed | --hard | --merge | --keep] [-q] [] -'git reset' [--stage | --work] [-q] [] +'git reset' [--stage | --work | --keep] [-q] [] DESCRIPTION ----------- diff --git a/builtin/reset.c b/builtin/reset.c index fbc1abc..dde03a7 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -23,7 +23,7 @@ static const char * const git_reset_usage[] = { N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] []"), - N_("git reset [--stage | --work] [-q] []"), + N_("git reset [--stage | --work | --keep] [-q] []"), N_("git reset [-q] [--] ..."), N_("git reset --patch [] [--] [...]"), NULL @@ -295,8 +295,15 @@ int cmd_reset(int argc, const char **argv, const char *prefix) } if (stage >= 0 || working_tree >= 0) { - if (reset_type != NONE) + int keep = 0; + + if (reset_type == KEEP) { + if (working_tree == 1) + die(_("--keep is incompatible with --work")); + keep = 1; + } else if (reset_type != NONE) { die(_("--{stage,work} are incompatible with --{hard,mixed,soft,merge}")); + } if (working_tree == 1) { if (stage == 0) @@ -304,7 +311,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix) reset_type = HARD; } else { if (stage == 1) - reset_type = NONE; + reset_type = keep ? KEEP : NONE; else reset_type = SOFT; } -- 1.8.4-fc