From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Thomas Rast <trast@inf.ethz.ch>
Subject: Re: [PATCH 0/2] "git add -A/--no-all" finishing touches
Date: Fri, 26 Apr 2013 13:44:14 -0700 [thread overview]
Message-ID: <7vd2thvx7l.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vhaiuywps.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Thu, 25 Apr 2013 17:14:23 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Jonathan Nieder <jrnieder@gmail.com> writes:
>
>> Maybe the warning should happen after add_file_to_index() has run,
>> letting git compare the old and new index entries for that path?
>
> Yeah, new and deleted cases we do not have to worry about, so a
> no-op add_file_to_index() is the only case we have to be careful.
> There is a "if verbose, say 'add %s'" logic in the funciton, so it
> should be possible to enhance the API without affecting existing
> callers to extract that necessary information out of it.
I've thought about this a bit more.
One possible solution would go like this:
- Extend add_file_to_index() (the logic is add_to_index() in
read-cache.c) so that it can return an extra boolean "I would add
it, but that would be a no-op---the index already has that
object" to the caller.
- In update_callback(), when we are comparing _all_ paths due to
"implicit-dot" logic, check if the path is outside the current
directory, instead of unconditionally calling warn_pathless_add():
* If fix_unmerged_status() tells us that we would go to the
remove_file_from_index() codepath, instead of calling it, call
warn_pathless_add() instead.
* If we are going to call add_file_to_index(), call it with
ADD_CACHE_PRETEND on using the extended interface to see if it
is adding already up-to-date contents. If not, call
warn_pathless_add().
But I think it is a much better solution to just refresh the index
like the attached patch when implicit_dot is active and we are not
at the top level directory. The paths that are stat-dirty but have
the up-to-date contents need to be hashed at least once _anyway_ to
see if the current contents match with what is in the index. If we
use the approach outlined above, the rehashing will be done in the
extended add_file_to_index(). If we simply refresh the entire cache,
the same check will be done there. The only performance penalty
would be that we may end up running lstat() twice.
Incidentally, I noticed that we set implicit_dot=1 even when we are
already at the top-level directory. I suspect the code may become
somewhat simpler if we set it only when (prefix != NULL), but it
probably would not matter.
builtin/add.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/builtin/add.c b/builtin/add.c
index daf02c6..ec2359c 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -495,6 +495,8 @@ int cmd_add(int argc, const char **argv, const char *prefix)
refresh(verbose, pathspec);
goto finish;
}
+ if (implicit_dot && !prefix)
+ refresh_cache(REFRESH_QUIET);
if (pathspec) {
int i;
next prev parent reply other threads:[~2013-04-26 20:44 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 ` jc/add-2.0-delete-default (Re: What's cooking in git.git (Apr 2013, #05; Mon, 15)) Jonathan Nieder
2013-04-22 1:51 ` 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 [this message]
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=7vd2thvx7l.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).