All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Thomas Rast" <trast@inf.ethz.ch>,
	git@vger.kernel.org, "Jan Krüger" <jk@jk.gs>
Subject: jc/add-2.0-delete-default (Re: What's cooking in git.git (Apr 2013, #05; Mon, 15))
Date: Sun, 21 Apr 2013 00:39:18 -0700	[thread overview]
Message-ID: <20130421073918.GD10429@elie.Belkin> (raw)
In-Reply-To: <20130419213455.GB20873@sigill.intra.peff.net>

> On Fri, Apr 19, 2013 at 10:25:46AM -0700, Junio C Hamano wrote:
>>> Junio C Hamano wrote:

>>>>     You ran 'git add' with neither '-A (--all)' or '--no-all', whose
>>>>     behaviour will change in Git 2.0 with respect to paths you
>>>>     removed from your working tree.
>>>>
>>>>     * 'git add --no-all <pathspec>', which is the current default,
>>>>       ignores paths you removed from your working tree.
>>>>
>>>>     * 'git add --all <pathspec>' will let you also record the
>>>>       removals.
>>>>
>>>>     The removed paths (e.g. '%s') are ignored with this version of Git.
>>>>     Run 'git status' to remind yourself what paths you have removed
>>>>     from your working tree.
>>>>
>>>> or something?
[...]
>>                                     Somebody good at phrasing needs
>> to trim it down without losing the essense.

By the way, it was mentioned on IRC that the above is a bit odd for
a different reason: the option --no-all that maintains the old behavior
is not intuitively named.

How about something like this?

	warning: "git add" run on path with files removed (e.g., '%s')
	hint: use "git add --ignore-removals <pathspec>" to ignore removals
	hint: or "git add --no-ignore-removals <pathspec>" to notice them
	hint: --ignore-removals is the default but this will change soon
	hint: see git-add(1) for details

Then the --ignore-removals option could be added using a patch like
the following.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 Documentation/git-add.txt | 24 +++++++++++++++---------
 builtin/add.c             | 28 +++++++++++++++++++++++++---
 2 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index b0944e57..8607cf37 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -9,7 +9,8 @@ SYNOPSIS
 --------
 [verse]
 'git add' [-n] [-v] [--force | -f] [--interactive | -i] [--patch | -p]
-	  [--edit | -e] [--all | [--update | -u]] [--intent-to-add | -N]
+	  [--edit | -e] [--update | -u] [--no-ignore-removals | -A]
+	  [--intent-to-add | -N]
 	  [--refresh] [--ignore-errors] [--ignore-missing] [--]
 	  [<pathspec>...]
 
@@ -109,17 +110,22 @@ If no <pathspec> is given, the current version of Git defaults to
 and its subdirectories. This default will change in a future version
 of Git, hence the form without <pathspec> should not be used.
 
+--ignore-removals::
+--no-ignore-removals::
 -A::
 --all::
-	Update the index not only where the working tree has a file
-	matching <pathspec> but also where the index already has an
-	entry.	This adds, modifies, and removes index entries to
-	match the working tree.
+	Update the index only where the working tree has a file
+	matching <pathspec>.  This adds and modifies index entries
+	to match the working tree but ignores removed files.
 +
-If no <pathspec> is given, the current version of Git defaults to
-"."; in other words, update all files in the current directory
-and its subdirectories. This default will change in a future version
-of Git, hence the form without <pathspec> should not be used.
+This is currently the default.  Git 2.0 will change the default
+to --no-ignore-removals.
++
+With --no-ignore-removals (and its historical synonyms `-A` and
+`--all`), if no <pathspec> is given, the current version of Git
+defaults to "."; in other words, update all files in the current
+directory and its subdirectories. This default will change in a future
+version of Git, hence the form without <pathspec> should not be used.
 
 -N::
 --intent-to-add::
diff --git a/builtin/add.c b/builtin/add.c
index ab1c9e8f..4a4e71ad 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -28,6 +28,14 @@ struct update_callback_data {
 	int add_errors;
 };
 
+static int parse_opt_neg_tertiary(const struct option *opt, const char *arg,
+				  int unset)
+{
+	int *target = opt->value;
+	*target = unset ? 1 : 2;
+	return 0;
+}
+
 static int fix_unmerged_status(struct diff_filepair *p,
 			       struct update_callback_data *data)
 {
@@ -271,7 +279,8 @@ static const char ignore_error[] =
 N_("The following paths are ignored by one of your .gitignore files:\n");
 
 static int verbose = 0, show_only = 0, ignored_too = 0, refresh_only = 0;
-static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
+static int ignore_add_errors, intent_to_add, ignore_missing = 0;
+static int ignore_removals, addremove;
 
 static struct option builtin_add_options[] = {
 	OPT__DRY_RUN(&show_only, N_("dry run")),
@@ -283,10 +292,12 @@ static struct option builtin_add_options[] = {
 	OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files")),
 	OPT_BOOLEAN('u', "update", &take_worktree_changes, N_("update tracked files")),
 	OPT_BOOLEAN('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
-	OPT_BOOLEAN('A', "all", &addremove, N_("add changes from all tracked and untracked files")),
+	OPT_UYN( 0 , "ignore-removals", &ignore_removals, N_("do not record removal of tracked files")),
 	OPT_BOOLEAN( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
 	OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
 	OPT_BOOLEAN( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
+	{ OPTION_CALLBACK, 'A', "all", &ignore_removals, NULL, N_("synonym for --no-ignore-removals"),
+	  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, &parse_opt_neg_tertiary },
 	OPT_END(),
 };
 
@@ -377,8 +388,19 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	argc--;
 	argv++;
 
+	if (ignore_removals == 2) {	/* --no-ignore-removals, or -A */
+		addremove = 1;
+		ignore_removals = 0;
+	}
+	if (ignore_removals && take_worktree_changes)
+		/*
+		 * NEEDSWORK: "git add -u --ignore-removals" should mean
+		 * "git diff --diff-filter=M | git apply --cached"
+		 */
+		die(_("--ignore-removals cannot be used with --update"));
 	if (addremove && take_worktree_changes)
-		die(_("-A and -u are mutually incompatible"));
+		/* -u --no-ignore-removals is the same as -u */
+		addremove = 0;
 	if (!show_only && ignore_missing)
 		die(_("Option --ignore-missing can only be used together with --dry-run"));
 	if (addremove) {
-- 
1.8.2.1

  parent reply	other threads:[~2013-04-21  7:39 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-15 20:28 What's cooking in git.git (Apr 2013, #05; Mon, 15) Junio C Hamano
2013-04-15 22:24 ` Felipe Contreras
2013-04-15 23:14   ` Junio C Hamano
2013-04-15 23:30     ` Felipe Contreras
2013-04-16  4:12       ` Junio C Hamano
2013-04-16  5:32         ` Felipe Contreras
2013-04-16  9:59       ` Thomas Rast
2013-04-16 19:04         ` Felipe Contreras
2013-04-16 19:19           ` Junio C Hamano
2013-04-16 19:48             ` Felipe Contreras
2013-04-16 22:34               ` Phil Hord
2013-04-16 23:50                 ` Felipe Contreras
2013-04-16 22:45           ` Phil Hord
2013-04-17  4:44             ` Junio C Hamano
2013-04-17 18:50             ` Felipe Contreras
2013-04-17 23:56               ` Junio C Hamano
2013-04-18  3:59                 ` Felipe Contreras
2013-04-18  7:44                   ` Matthieu Moy
2013-04-18  9:15                     ` Felipe Contreras
2013-04-18  9:19               ` Ramkumar Ramachandra
2013-04-18  9:53                 ` Felipe Contreras
2013-04-18 10:27                   ` Ramkumar Ramachandra
2013-04-18 10:55                     ` Felipe Contreras
2013-04-18 11:31                       ` Ramkumar Ramachandra
2013-04-18 12:05                         ` Felipe Contreras
2013-04-18 11:46                       ` Ramkumar Ramachandra
2013-04-18 12:16                         ` Felipe Contreras
2013-04-23 18:49                           ` Ramkumar Ramachandra
2013-04-23 19:11                             ` Felipe Contreras
2013-04-18 20:06               ` Phil Hord
2013-04-18 23:48                 ` Felipe Contreras
2013-04-19 21:07                   ` Phil Hord
2013-04-20  1:29                     ` Felipe Contreras
2013-04-15 23:25 ` Jeff King
2013-04-15 23:49   ` Øyvind A. Holm
2013-04-16  0:53     ` Jeff King
2013-04-16  0:30   ` Jeff King
2013-04-16  1:08     ` Eric Sunshine
2013-04-16 17:18     ` Junio C Hamano
2013-04-16  3:21 ` Drew Northup
2013-04-16 23:52 ` "What's cooking" between #05 and #06 Junio C Hamano
2013-04-17  8:40   ` John Keeping
2013-04-17 15:30     ` Junio C Hamano
2013-04-17 21:25   ` Jens Lehmann
2013-04-18  8:49     ` John Keeping
2013-04-17  8:49 ` What's cooking in git.git (Apr 2013, #05; Mon, 15) Lukas Fleischer
2013-04-17 15:11   ` Junio C Hamano
2013-04-17  9:47 ` Thomas Rast
2013-04-17 15:24   ` Junio C Hamano
2013-04-17 15:56     ` Thomas Rast
2013-04-17 17:08       ` Junio C Hamano
2013-04-17 18:14         ` Junio C Hamano
2013-04-17 20:10           ` Jeff King
2013-04-18  1:39             ` Junio C Hamano
2013-04-18  1:47               ` [PATCH] git add <pathspec>... defaults to "-A" Junio C Hamano
2013-04-18 17:27               ` What's cooking in git.git (Apr 2013, #05; Mon, 15) Jeff King
2013-04-18 17:51                 ` Junio C Hamano
2013-04-18 18:00                   ` Jeff King
2013-04-18 18:16                     ` Junio C Hamano
2013-04-18 20:30                       ` Jeff King
2013-04-18 21:37                         ` Junio C Hamano
2013-04-18 21:44                           ` Jeff King
2013-04-18 22:10                             ` Junio C Hamano
2013-04-19  4:14                               ` Jeff King
2013-04-19  4:31                               ` Jonathan Nieder
2013-04-19 17:25                                 ` Junio C Hamano
2013-04-19 21:34                                   ` Jeff King
2013-04-19 21:56                                     ` Junio C Hamano
2013-04-21  7:39                                     ` Jonathan Nieder [this message]
2013-04-22  1:51                                       ` jc/add-2.0-delete-default (Re: What's cooking in git.git (Apr 2013, #05; Mon, 15)) Junio C Hamano
2013-04-22  4:54                                         ` Junio C Hamano
2013-04-22 20:43                                           ` [PATCH 0/2] "git add -A/--no-all" finishing touches Junio C Hamano
2013-04-22 20:43                                             ` [PATCH 1/2] git add: --ignore-removal is a better named --no-all Junio C Hamano
2013-04-22 20:43                                             ` [PATCH 2/2] git add: rephrase -A/--no-all warning Junio C Hamano
2013-04-22 22:41                                             ` [PATCH 3/2] git add <pathspec>... defaults to "-A" Junio C Hamano
2013-04-23  0:42                                               ` Eric Sunshine
2013-04-25 23:06                                             ` [PATCH 0/2] "git add -A/--no-all" finishing touches Junio C Hamano
2013-04-25 23:19                                               ` Junio C Hamano
2013-04-25 23:24                                                 ` Jonathan Nieder
2013-04-25 23:41                                                   ` Junio C Hamano
2013-04-25 23:44                                                     ` Junio C Hamano
2013-04-25 23:56                                                       ` Jonathan Nieder
2013-04-26  0:14                                                         ` Junio C Hamano
2013-04-26 20:44                                                           ` Junio C Hamano
2013-04-26 21:30                                                             ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130421073918.GD10429@elie.Belkin \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jk@jk.gs \
    --cc=peff@peff.net \
    --cc=trast@inf.ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.