@@ -8,22 +8,22 @@ test_description='Test git stash'
8
8
. ./test-lib.sh
9
9
10
10
test_expect_success ' stash some dirty working directory' '
11
- echo 1 > file &&
11
+ echo 1 >file &&
12
12
git add file &&
13
13
echo unrelated >other-file &&
14
14
git add other-file &&
15
15
test_tick &&
16
16
git commit -m initial &&
17
- echo 2 > file &&
17
+ echo 2 >file &&
18
18
git add file &&
19
- echo 3 > file &&
19
+ echo 3 >file &&
20
20
test_tick &&
21
21
git stash &&
22
22
git diff-files --quiet &&
23
23
git diff-index --cached --quiet HEAD
24
24
'
25
25
26
- cat > expect << EOF
26
+ cat > expect << EOF
27
27
diff --git a/file b/file
28
28
index 0cfbf08..00750ed 100644
29
29
--- a/file
35
35
36
36
test_expect_success ' parents of stash' '
37
37
test $(git rev-parse stash^) = $(git rev-parse HEAD) &&
38
- git diff stash^2..stash > output &&
38
+ git diff stash^2..stash >output &&
39
39
test_cmp expect output
40
40
'
41
41
@@ -74,7 +74,7 @@ test_expect_success 'apply stashed changes' '
74
74
75
75
test_expect_success ' apply stashed changes (including index)' '
76
76
git reset --hard HEAD^ &&
77
- echo 6 > other-file &&
77
+ echo 6 >other-file &&
78
78
git add other-file &&
79
79
test_tick &&
80
80
git commit -m other-file &&
@@ -99,12 +99,12 @@ test_expect_success 'stash drop complains of extra options' '
99
99
100
100
test_expect_success ' drop top stash' '
101
101
git reset --hard &&
102
- git stash list > stashlist1 &&
103
- echo 7 > file &&
102
+ git stash list >expected &&
103
+ echo 7 >file &&
104
104
git stash &&
105
105
git stash drop &&
106
- git stash list > stashlist2 &&
107
- test_cmp stashlist1 stashlist2 &&
106
+ git stash list >actual &&
107
+ test_cmp expected actual &&
108
108
git stash apply &&
109
109
test 3 = $(cat file) &&
110
110
test 1 = $(git show :file) &&
@@ -113,9 +113,9 @@ test_expect_success 'drop top stash' '
113
113
114
114
test_expect_success ' drop middle stash' '
115
115
git reset --hard &&
116
- echo 8 > file &&
116
+ echo 8 >file &&
117
117
git stash &&
118
- echo 9 > file &&
118
+ echo 9 >file &&
119
119
git stash &&
120
120
git stash drop stash@{1} &&
121
121
test 2 = $(git stash list | wc -l) &&
@@ -160,7 +160,7 @@ test_expect_success 'stash pop' '
160
160
test 0 = $(git stash list | wc -l)
161
161
'
162
162
163
- cat > expect << EOF
163
+ cat > expect << EOF
164
164
diff --git a/file2 b/file2
165
165
new file mode 100644
166
166
index 0000000..1fe912c
@@ -170,7 +170,7 @@ index 0000000..1fe912c
170
170
+bar2
171
171
EOF
172
172
173
- cat > expect1 << EOF
173
+ cat > expect1 << EOF
174
174
diff --git a/file b/file
175
175
index 257cc56..5716ca5 100644
176
176
--- a/file
@@ -180,7 +180,7 @@ index 257cc56..5716ca5 100644
180
180
+bar
181
181
EOF
182
182
183
- cat > expect2 << EOF
183
+ cat > expect2 << EOF
184
184
diff --git a/file b/file
185
185
index 7601807..5716ca5 100644
186
186
--- a/file
@@ -198,79 +198,79 @@ index 0000000..1fe912c
198
198
EOF
199
199
200
200
test_expect_success ' stash branch' '
201
- echo foo > file &&
201
+ echo foo >file &&
202
202
git commit file -m first &&
203
- echo bar > file &&
204
- echo bar2 > file2 &&
203
+ echo bar >file &&
204
+ echo bar2 >file2 &&
205
205
git add file2 &&
206
206
git stash &&
207
- echo baz > file &&
207
+ echo baz >file &&
208
208
git commit file -m second &&
209
209
git stash branch stashbranch &&
210
210
test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
211
211
test $(git rev-parse HEAD) = $(git rev-parse master^) &&
212
- git diff --cached > output &&
212
+ git diff --cached >output &&
213
213
test_cmp expect output &&
214
- git diff > output &&
214
+ git diff >output &&
215
215
test_cmp expect1 output &&
216
216
git add file &&
217
217
git commit -m alternate\ second &&
218
- git diff master..stashbranch > output &&
218
+ git diff master..stashbranch >output &&
219
219
test_cmp output expect2 &&
220
220
test 0 = $(git stash list | wc -l)
221
221
'
222
222
223
223
test_expect_success ' apply -q is quiet' '
224
- echo foo > file &&
224
+ echo foo >file &&
225
225
git stash &&
226
- git stash apply -q > output.out 2>&1 &&
226
+ git stash apply -q >output.out 2>&1 &&
227
227
test_must_be_empty output.out
228
228
'
229
229
230
230
test_expect_success ' save -q is quiet' '
231
- git stash save --quiet > output.out 2>&1 &&
231
+ git stash save --quiet >output.out 2>&1 &&
232
232
test_must_be_empty output.out
233
233
'
234
234
235
235
test_expect_success ' pop -q is quiet' '
236
- git stash pop -q > output.out 2>&1 &&
236
+ git stash pop -q >output.out 2>&1 &&
237
237
test_must_be_empty output.out
238
238
'
239
239
240
240
test_expect_success ' pop -q --index works and is quiet' '
241
- echo foo > file &&
241
+ echo foo >file &&
242
242
git add file &&
243
243
git stash save --quiet &&
244
- git stash pop -q --index > output.out 2>&1 &&
244
+ git stash pop -q --index >output.out 2>&1 &&
245
245
test foo = "$(git show :file)" &&
246
246
test_must_be_empty output.out
247
247
'
248
248
249
249
test_expect_success ' drop -q is quiet' '
250
250
git stash &&
251
- git stash drop -q > output.out 2>&1 &&
251
+ git stash drop -q >output.out 2>&1 &&
252
252
test_must_be_empty output.out
253
253
'
254
254
255
255
test_expect_success ' stash -k' '
256
- echo bar3 > file &&
257
- echo bar4 > file2 &&
256
+ echo bar3 >file &&
257
+ echo bar4 >file2 &&
258
258
git add file2 &&
259
259
git stash -k &&
260
260
test bar,bar4 = $(cat file),$(cat file2)
261
261
'
262
262
263
263
test_expect_success ' stash --no-keep-index' '
264
- echo bar33 > file &&
265
- echo bar44 > file2 &&
264
+ echo bar33 >file &&
265
+ echo bar44 >file2 &&
266
266
git add file2 &&
267
267
git stash --no-keep-index &&
268
268
test bar,bar2 = $(cat file),$(cat file2)
269
269
'
270
270
271
271
test_expect_success ' stash --invalid-option' '
272
- echo bar5 > file &&
273
- echo bar6 > file2 &&
272
+ echo bar5 >file &&
273
+ echo bar6 >file2 &&
274
274
git add file2 &&
275
275
test_must_fail git stash --invalid-option &&
276
276
test_must_fail git stash save --invalid-option &&
@@ -486,26 +486,28 @@ test_expect_success 'stash branch - no stashes on stack, stash-like argument' '
486
486
git stash clear &&
487
487
test_when_finished "git reset --hard HEAD" &&
488
488
git reset --hard &&
489
- echo foo >> file &&
489
+ echo foo >>file &&
490
490
STASH_ID=$(git stash create) &&
491
491
git reset --hard &&
492
492
git stash branch stash-branch ${STASH_ID} &&
493
- test_when_finished "git reset --hard HEAD && git checkout master && git branch -D stash-branch" &&
493
+ test_when_finished "git reset --hard HEAD && git checkout master &&
494
+ git branch -D stash-branch" &&
494
495
test $(git ls-files --modified | wc -l) -eq 1
495
496
'
496
497
497
498
test_expect_success ' stash branch - stashes on stack, stash-like argument' '
498
499
git stash clear &&
499
500
test_when_finished "git reset --hard HEAD" &&
500
501
git reset --hard &&
501
- echo foo >> file &&
502
+ echo foo >>file &&
502
503
git stash &&
503
504
test_when_finished "git stash drop" &&
504
- echo bar >> file &&
505
+ echo bar >>file &&
505
506
STASH_ID=$(git stash create) &&
506
507
git reset --hard &&
507
508
git stash branch stash-branch ${STASH_ID} &&
508
- test_when_finished "git reset --hard HEAD && git checkout master && git branch -D stash-branch" &&
509
+ test_when_finished "git reset --hard HEAD && git checkout master &&
510
+ git branch -D stash-branch" &&
509
511
test $(git ls-files --modified | wc -l) -eq 1
510
512
'
511
513
@@ -518,10 +520,10 @@ test_expect_success 'stash show format defaults to --stat' '
518
520
git stash clear &&
519
521
test_when_finished "git reset --hard HEAD" &&
520
522
git reset --hard &&
521
- echo foo >> file &&
523
+ echo foo >>file &&
522
524
git stash &&
523
525
test_when_finished "git stash drop" &&
524
- echo bar >> file &&
526
+ echo bar >>file &&
525
527
STASH_ID=$(git stash create) &&
526
528
git reset --hard &&
527
529
cat >expected <<-EOF &&
@@ -536,10 +538,10 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
536
538
git stash clear &&
537
539
test_when_finished "git reset --hard HEAD" &&
538
540
git reset --hard &&
539
- echo foo >> file &&
541
+ echo foo >>file &&
540
542
git stash &&
541
543
test_when_finished "git stash drop" &&
542
- echo bar >> file &&
544
+ echo bar >>file &&
543
545
STASH_ID=$(git stash create) &&
544
546
git reset --hard &&
545
547
echo "1 0 file" >expected &&
@@ -551,10 +553,10 @@ test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
551
553
git stash clear &&
552
554
test_when_finished "git reset --hard HEAD" &&
553
555
git reset --hard &&
554
- echo foo >> file &&
556
+ echo foo >>file &&
555
557
git stash &&
556
558
test_when_finished "git stash drop" &&
557
- echo bar >> file &&
559
+ echo bar >>file &&
558
560
STASH_ID=$(git stash create) &&
559
561
git reset --hard &&
560
562
cat >expected <<-EOF &&
@@ -574,7 +576,7 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' '
574
576
git stash clear &&
575
577
test_when_finished "git reset --hard HEAD" &&
576
578
git reset --hard &&
577
- echo foo >> file &&
579
+ echo foo >>file &&
578
580
STASH_ID=$(git stash create) &&
579
581
git reset --hard &&
580
582
echo "1 0 file" >expected &&
@@ -586,7 +588,7 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
586
588
git stash clear &&
587
589
test_when_finished "git reset --hard HEAD" &&
588
590
git reset --hard &&
589
- echo foo >> file &&
591
+ echo foo >>file &&
590
592
STASH_ID=$(git stash create) &&
591
593
git reset --hard &&
592
594
cat >expected <<-EOF &&
@@ -606,9 +608,9 @@ test_expect_success 'stash drop - fail early if specified stash is not a stash r
606
608
git stash clear &&
607
609
test_when_finished "git reset --hard HEAD && git stash clear" &&
608
610
git reset --hard &&
609
- echo foo > file &&
611
+ echo foo >file &&
610
612
git stash &&
611
- echo bar > file &&
613
+ echo bar >file &&
612
614
git stash &&
613
615
test_must_fail git stash drop $(git rev-parse stash@{0}) &&
614
616
git stash pop &&
@@ -620,9 +622,9 @@ test_expect_success 'stash pop - fail early if specified stash is not a stash re
620
622
git stash clear &&
621
623
test_when_finished "git reset --hard HEAD && git stash clear" &&
622
624
git reset --hard &&
623
- echo foo > file &&
625
+ echo foo >file &&
624
626
git stash &&
625
- echo bar > file &&
627
+ echo bar >file &&
626
628
git stash &&
627
629
test_must_fail git stash pop $(git rev-parse stash@{0}) &&
628
630
git stash pop &&
@@ -632,8 +634,8 @@ test_expect_success 'stash pop - fail early if specified stash is not a stash re
632
634
633
635
test_expect_success ' ref with non-existent reflog' '
634
636
git stash clear &&
635
- echo bar5 > file &&
636
- echo bar6 > file2 &&
637
+ echo bar5 >file &&
638
+ echo bar6 >file2 &&
637
639
git add file2 &&
638
640
git stash &&
639
641
test_must_fail git rev-parse --quiet --verify does-not-exist &&
@@ -653,8 +655,8 @@ test_expect_success 'ref with non-existent reflog' '
653
655
test_expect_success ' invalid ref of the form stash@{n}, n >= N' '
654
656
git stash clear &&
655
657
test_must_fail git stash drop stash@{0} &&
656
- echo bar5 > file &&
657
- echo bar6 > file2 &&
658
+ echo bar5 >file &&
659
+ echo bar6 >file2 &&
658
660
git add file2 &&
659
661
git stash &&
660
662
test_must_fail git stash drop stash@{1} &&
@@ -724,7 +726,7 @@ test_expect_success 'stash apply shows status same as git status (relative to cu
724
726
test_i18ncmp expect actual
725
727
'
726
728
727
- cat > expect << EOF
729
+ cat > expect << EOF
728
730
diff --git a/HEAD b/HEAD
729
731
new file mode 100644
730
732
index 0000000..fe0cbee
@@ -737,14 +739,14 @@ EOF
737
739
test_expect_success ' stash where working directory contains "HEAD" file' '
738
740
git stash clear &&
739
741
git reset --hard &&
740
- echo file-not-a-ref > HEAD &&
742
+ echo file-not-a-ref >HEAD &&
741
743
git add HEAD &&
742
744
test_tick &&
743
745
git stash &&
744
746
git diff-files --quiet &&
745
747
git diff-index --cached --quiet HEAD &&
746
748
test "$(git rev-parse stash^)" = "$(git rev-parse HEAD)" &&
747
- git diff stash^..stash > output &&
749
+ git diff stash^..stash >output &&
748
750
test_cmp expect output
749
751
'
750
752
0 commit comments