git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: git@vger.kernel.org
Cc: Jens.Lehmann@web.de, pclouds@gmail.com, gitster@pobox.com,
	Chris Packham <judge.packham@gmail.com>
Subject: [RFC/PATCHv2 2/5] grep: output the path from cwd to worktree
Date: Fri, 15 Oct 2010 16:26:41 -0700	[thread overview]
Message-ID: <1287185204-843-3-git-send-email-judge.packham@gmail.com> (raw)
In-Reply-To: <1287185204-843-1-git-send-email-judge.packham@gmail.com>

If we have detected that our worktree is not the cwd.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---
 builtin/grep.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/builtin/grep.c b/builtin/grep.c
index da32f3d..a51eb2c 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -531,6 +531,8 @@ static int grep_file(struct grep_opt *opt, const char *filename)
 	struct strbuf buf = STRBUF_INIT;
 	char *name;
 
+	if (startup_info->cwd_to_worktree)
+		strbuf_addstr(&buf,startup_info->cwd_to_worktree);
 	if (opt->relative && opt->prefix_length)
 		quote_path_relative(filename, -1, &buf, opt->prefix);
 	else
@@ -646,6 +648,8 @@ static int grep_tree(struct grep_opt *opt, const char **paths,
 	while (tree_entry(tree, &entry)) {
 		int te_len = tree_entry_len(entry.path, entry.sha1);
 		pathbuf.len = len;
+		if (startup_info->cwd_to_worktree)
+			strbuf_addstr(&pathbuf,startup_info->cwd_to_worktree);
 		strbuf_add(&pathbuf, entry.path, te_len);
 
 		if (S_ISDIR(entry.mode))
-- 
1.7.3.1

  parent reply	other threads:[~2010-10-15 23:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-15 23:26 [RGC/PATCHv2] grep: submodule support Chris Packham
2010-10-15 23:26 ` [RFC/PATCHv2 1/5] worktree: provide better prefix to go back to original cwd Chris Packham
2010-10-16 18:42   ` Jonathan Nieder
2010-10-17  2:48     ` Chris Packham
2010-10-17 10:01       ` Nguyen Thai Ngoc Duy
2010-10-18  2:05         ` Chris Packham
2010-10-15 23:26 ` Chris Packham [this message]
2010-10-15 23:26 ` [RFC/PATCHv2 3/5] grep_cache: check pathspec first Chris Packham
2010-10-15 23:26 ` [RFC/PATCHv2 4/5] add test for git grep --recursive Chris Packham
2010-10-15 23:26 ` [RFC/PATCHv2 5/5] grep: add support for grepping in submodules Chris Packham
2010-10-17 10:28   ` Nguyen Thai Ngoc Duy
2010-10-18  2:01     ` Chris Packham
2010-10-18  3:37       ` Nguyen Thai Ngoc Duy
2010-10-16 15:54 ` [RGC/PATCHv2] grep: submodule support Jens Lehmann
2010-10-17  2:13   ` Chris Packham

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=1287185204-843-3-git-send-email-judge.packham@gmail.com \
    --to=judge.packham@gmail.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.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 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).