git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCHv2 2/5] grep: output the path from cwd to worktree

From
Chris Packham <judge.packham@gmail.com>
Date
Oct 15, 2010, 23:26 UTC
Message-ID
<1287185204-843-3-git-send-email-judge.packham@gmail.com>
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
Previous: Chris PackhamNext: Chris Packham
Message 7 of 15 in “[RGC/PATCHv2] grep: submodule support”
  1. Chris PackhamOct 15, 2010
  2. 1/5 worktree: provide better prefix to go back to original cwdChris Packham, Oct 15, 2010
  3. Jonathan NiederOct 16, 2010
  4. Chris PackhamOct 17, 2010
  5. Nguyen Thai Ngoc DuyOct 17, 2010
  6. Chris PackhamOct 18, 2010
  7. 2/5 grep: output the path from cwd to worktreeChris Packham, Oct 15, 2010
  8. 3/5 grep_cache: check pathspec firstChris Packham, Oct 15, 2010
  9. 4/5 add test for git grep --recursiveChris Packham, Oct 15, 2010
  10. 5/5 grep: add support for grepping in submodulesChris Packham, Oct 15, 2010
  11. Nguyen Thai Ngoc DuyOct 17, 2010
  12. Chris PackhamOct 18, 2010
  13. Nguyen Thai Ngoc DuyOct 18, 2010
  14. Jens LehmannOct 16, 2010
  15. Chris PackhamOct 17, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.