297
test_path_is_missing untracked.txt
298
'
299
300
+test_expect_success 'stash show --include-untracked shows untracked files' '
301
+ git reset --hard &&
302
+ git clean -xf &&
303
+ >untracked &&
304
+ >tracked &&
305
+ git add tracked &&
306
+ empty_blob_oid=$(git rev-parse --short :tracked) &&
307
+ git stash -u &&
308
+
309
+ cat >expect <<-EOF &&
310
+ tracked | 0
311
+ untracked | 0
312
+ 2 files changed, 0 insertions(+), 0 deletions(-)
313
+ EOF
314
+ git stash show --include-untracked >actual &&
315
+ test_cmp expect actual &&
316
+ git stash show -u >actual &&
317
+ test_cmp expect actual &&
318
+ git stash show --no-include-untracked --include-untracked >actual &&
319
+ test_cmp expect actual &&
320
+ git stash show --only-untracked --include-untracked >actual &&
321
+ test_cmp expect actual &&
322
+
323
+ cat >expect <<-EOF &&
324
+ diff --git a/tracked b/tracked
325
+ new file mode 100644
326
+ index 0000000..$empty_blob_oid
327
+ diff --git a/untracked b/untracked
328
+ new file mode 100644
329
+ index 0000000..$empty_blob_oid
330
+ EOF
331
+ git stash show -p --include-untracked >actual &&
332
+ test_cmp expect actual &&
333
+ git stash show --include-untracked -p >actual &&
334
+ test_cmp expect actual
335
+'
336
+
337
+test_expect_success 'stash show --only-untracked only shows untracked files' '
338
+ git reset --hard &&
339
+ git clean -xf &&
340
+ >untracked &&
341
+ >tracked &&
342
+ git add tracked &&
343
+ empty_blob_oid=$(git rev-parse --short :tracked) &&
344
+ git stash -u &&
345
+
346
+ cat >expect <<-EOF &&
347
+ untracked | 0
348
+ 1 file changed, 0 insertions(+), 0 deletions(-)
349
+ EOF
350
+ git stash show --only-untracked >actual &&
351
+ test_cmp expect actual &&
352
+ git stash show --no-include-untracked --only-untracked >actual &&
353
+ test_cmp expect actual &&
354
+ git stash show --include-untracked --only-untracked >actual &&
355
+ test_cmp expect actual &&
356
+
357
+ cat >expect <<-EOF &&
358
+ diff --git a/untracked b/untracked
359
+ new file mode 100644
360
+ index 0000000..$empty_blob_oid
361
+ EOF
362
+ git stash show -p --only-untracked >actual &&
363
+ test_cmp expect actual &&
364
+ git stash show --only-untracked -p >actual &&
365
+ test_cmp expect actual
366
+'
367
+
368
+test_expect_success 'stash show --no-include-untracked cancels --{include,show}-untracked' '
369
+ git reset --hard &&
370
+ git clean -xf &&
371
+ >untracked &&
372
+ >tracked &&
373
+ git add tracked &&
374
+ git stash -u &&
375
+
376
+ cat >expect <<-EOF &&
377
+ tracked | 0
378
+ 1 file changed, 0 insertions(+), 0 deletions(-)
379
+ EOF
380
+ git stash show --only-untracked --no-include-untracked >actual &&
381
+ test_cmp expect actual &&
382
+ git stash show --include-untracked --no-include-untracked >actual &&
383
+ test_cmp expect actual
384
+'
385
+
386
+test_expect_success 'stash show --include-untracked errors on duplicate files' '
387
+ git reset --hard &&
388
+ git clean -xf &&
389
+ >tracked &&
390
+ git add tracked &&
391
+ tree=$(git write-tree) &&
392
+ i_commit=$(git commit-tree -p HEAD -m "index on any-branch" "$tree") &&
393
+ test_when_finished "rm -f untracked_index" &&
394
+ u_commit=$(
395
+ GIT_INDEX_FILE="untracked_index" &&
396
+ export GIT_INDEX_FILE &&
397
+ git update-index --add tracked &&
398
+ u_tree=$(git write-tree) &&
399
+ git commit-tree -m "untracked files on any-branch" "$u_tree"
400
+ ) &&
401
+ w_commit=$(git commit-tree -p HEAD -p "$i_commit" -p "$u_commit" -m "WIP on any-branch" "$tree") &&
402
+ test_must_fail git stash show --include-untracked "$w_commit" 2>err &&
403
+ test_i18ngrep "worktree and untracked commit have duplicate entries: tracked" err
404
+'
405
+
406
test_done