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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Chris Packham <judge.packham@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]