Re: [PATCH 3/4] add -u: only show pathless 'add -u' warning when changes exist outside cwd
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 19, 2013, 14:57 UTC
- Message-ID
- <7va9pzl9nh.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20130319052805.GO5062@elie.Belkin>
Jonathan Nieder <jrnieder@gmail.com> writes:
> Yes, that can work, for example like this (replacing the patch you're > replying to).
I think that would be a better approach if we were to do this. I still have the same reservation that "this is fundamentally not worse but still hurts the users more".
Show 11 quoted lines
> + /*
> + * Check if "git add -A" or "git add -u" was run from a
> + * subdirectory with a modified file outside that directory,
> + * and warn if so.
> + *
> + * "git add -u" will behave like "git add -u :/" instead of
> + * "git add -u ." in the future. This warning prepares for
> + * that change.
> + */
> + if (implicit_dot &&
> + !match_pathspec(implicit_dot, path, strlen(path), 0, NULL)) {This one really should *not* use match_pathspec(), I think.
It is a special case where we were asked to limit to our directory but decided to grab everything instead and filtering the outcome outselves. We should have a "path to the starting directory" aka "prefix" in implicit_dot and check if path is covered by the prefix instead.
Show 6 quoted lines
> + warn_pathless_add();
> + continue;
> + }
> switch (fix_unmerged_status(p, data)) {
> default:
> die(_("unexpected diff status %c"), p->status);