All of lore.kernel.org
 help / color / mirror / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Charles Bailey <charles@hashpling.org>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] grep: fix grepping for "intent to add" files
Date: Thu, 16 Jun 2016 14:47:09 +0700	[thread overview]
Message-ID: <20160616074709.GA24412@duynguyen-vnpc.vn.dektech.internal> (raw)
In-Reply-To: <20160616065324.GA14967@hashpling.org>

On Thu, Jun 16, 2016 at 07:53:24AM +0100, Charles Bailey wrote:
> From: Charles Bailey <cbailey32@bloomberg.net>
> 
> This reverts commit 4d552005323034c1d6311796ac1074e9a4b4b57e.
> 
> This commit caused 'git grep' to no longer find matches in new files in
> the working tree where the corresponding index entry had the "intent to
> add" bit set.

I don't think revert is right. It rather needs a re-fix like below.
Basically we want grep_file() to run as normal, but grep_sha1()
(i.e. git grep --cached) should ignore i-t-a entries, because empty
SHA-1 is not the right content to grep. It does not matter in positive
matching, sure, but it may in -v cache.

-- 8< --
diff --git a/builtin/grep.c b/builtin/grep.c
index 462e607..ae73831 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -386,7 +386,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
 
 	for (nr = 0; nr < active_nr; nr++) {
 		const struct cache_entry *ce = active_cache[nr];
-		if (!S_ISREG(ce->ce_mode) || ce_intent_to_add(ce))
+		if (!S_ISREG(ce->ce_mode))
 			continue;
 		if (!ce_path_match(ce, pathspec, NULL))
 			continue;
@@ -396,7 +396,7 @@ static int grep_cache(struct grep_opt *opt, const struct pathspec *pathspec, int
 		 * cache version instead
 		 */
 		if (cached || (ce->ce_flags & CE_VALID) || ce_skip_worktree(ce)) {
-			if (ce_stage(ce))
+			if (ce_stage(ce) || ce_intent_to_add(ce))
 				continue;
 			hit |= grep_sha1(opt, ce->sha1, ce->name, 0, ce->name);
 		}
-- 8< --
--
Duy

  reply	other threads:[~2016-06-16  7:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16  6:53 [PATCH] grep: fix grepping for "intent to add" files Charles Bailey
2016-06-16  7:47 ` Duy Nguyen [this message]
2016-06-16  9:47   ` Charles Bailey
2016-06-16 10:57     ` Duy Nguyen
2016-06-16 11:44       ` Charles Bailey
2016-06-16 12:11         ` Duy Nguyen
2016-06-16 18:18       ` Junio C Hamano
2016-06-16 18:12 ` Junio C Hamano

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=20160616074709.GA24412@duynguyen-vnpc.vn.dektech.internal \
    --to=pclouds@gmail.com \
    --cc=charles@hashpling.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.