blob: ad3d9e48454d2e72afce682df009cdaaee9ba3c5 [file] [log] [blame]
Junio C Hamano66204982005-05-31 18:46:47 -07001#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Pathspec restrictions
7
8Prepare:
9 file0
10 path1/file1
11'
12. ./test-lib.sh
13. ../diff-lib.sh ;# test-lib chdir's into trash
14
15test_expect_success \
16 setup \
17 'echo frotz >file0 &&
18 mkdir path1 &&
19 echo rezrov >path1/file1 &&
Junio C Hamano5be60072007-07-02 22:52:14 -070020 git update-index --add file0 path1/file1 &&
21 tree=`git write-tree` &&
Junio C Hamano66204982005-05-31 18:46:47 -070022 echo "$tree" &&
23 echo nitfol >file0 &&
24 echo yomin >path1/file1 &&
Junio C Hamano5be60072007-07-02 22:52:14 -070025 git update-index file0 path1/file1'
Junio C Hamano66204982005-05-31 18:46:47 -070026
27cat >expected <<\EOF
28EOF
29test_expect_success \
30 'limit to path should show nothing' \
Junio C Hamano5be60072007-07-02 22:52:14 -070031 'git diff-index --cached $tree -- path >current &&
Junio C Hamano66204982005-05-31 18:46:47 -070032 compare_diff_raw current expected'
33
34cat >expected <<\EOF
35:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M path1/file1
36EOF
37test_expect_success \
38 'limit to path1 should show path1/file1' \
Junio C Hamano5be60072007-07-02 22:52:14 -070039 'git diff-index --cached $tree -- path1 >current &&
Junio C Hamano66204982005-05-31 18:46:47 -070040 compare_diff_raw current expected'
41
42cat >expected <<\EOF
43:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M path1/file1
44EOF
45test_expect_success \
46 'limit to path1/ should show path1/file1' \
Junio C Hamano5be60072007-07-02 22:52:14 -070047 'git diff-index --cached $tree -- path1/ >current &&
Junio C Hamano66204982005-05-31 18:46:47 -070048 compare_diff_raw current expected'
49
50cat >expected <<\EOF
51:100644 100644 766498d93a4b06057a8e49d23f4068f1170ff38f 0a41e115ab61be0328a19b29f18cdcb49338d516 M file0
52EOF
53test_expect_success \
54 'limit to file0 should show file0' \
Junio C Hamano5be60072007-07-02 22:52:14 -070055 'git diff-index --cached $tree -- file0 >current &&
Junio C Hamano66204982005-05-31 18:46:47 -070056 compare_diff_raw current expected'
57
58cat >expected <<\EOF
59EOF
60test_expect_success \
61 'limit to file0/ should emit nothing.' \
Junio C Hamano5be60072007-07-02 22:52:14 -070062 'git diff-index --cached $tree -- file0/ >current &&
Junio C Hamano66204982005-05-31 18:46:47 -070063 compare_diff_raw current expected'
64
65test_done