aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-08-11 00:44:42 -0700
committerJunio C Hamano <junkio@cox.net>2006-08-11 19:08:10 -0700
commit0d042fecf2f4130717d198f9cc2d792e72370bda (patch)
tree45f19a371877c20fcae9166795e17143863a0982 /t
parentc8769f76d992ed391d169cd71be009ca17727271 (diff)
downloadgit-0d042fecf2f4130717d198f9cc2d792e72370bda.tar.gz
git-0d042fecf2f4130717d198f9cc2d792e72370bda.tar.xz
git-grep: show pathnames relative to the current directory
By default, the command shows pathnames relative to the current directory. Use --full-name (the same flag to do so in ls-files) if you want to see the full pathname relative to the project root. This makes it very pleasant to run in Emacs compilation (or "grep-find") buffer. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 't')
-rwxr-xr-xt/t7002-grep.sh31
1 files changed, 29 insertions, 2 deletions
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index 00a7d762c..6bfb899ed 100755
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2006 Junio C Hamano
#
-test_description='git grep -w
+test_description='git grep various.
'
. ./test-lib.sh
@@ -19,7 +19,9 @@ test_expect_success setup '
echo x x xx x >x &&
echo y yy >y &&
echo zzz > z &&
- git add file x y z &&
+ mkdir t &&
+ echo test >t/t &&
+ git add file x y z t/t &&
git commit -m initial
'
@@ -80,6 +82,31 @@ do
diff expected actual
fi
'
+
+ test_expect_success "grep $L (t-1)" '
+ echo "${HC}t/t:1:test" >expected &&
+ git grep -n -e test $H >actual &&
+ diff expected actual
+ '
+
+ test_expect_success "grep $L (t-2)" '
+ echo "${HC}t:1:test" >expected &&
+ (
+ cd t &&
+ git grep -n -e test $H
+ ) >actual &&
+ diff expected actual
+ '
+
+ test_expect_success "grep $L (t-3)" '
+ echo "${HC}t/t:1:test" >expected &&
+ (
+ cd t &&
+ git grep --full-name -n -e test $H
+ ) >actual &&
+ diff expected actual
+ '
+
done
test_done