t / t4007-rename-3.shon commit sha1-file.c: mark more strings for translation (259328b)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5
   6test_description='Rename interaction with pathspec.
   7
   8'
   9. ./test-lib.sh
  10. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
  11
  12test_expect_success 'prepare reference tree' '
  13        mkdir path0 path1 &&
  14        cp "$TEST_DIRECTORY"/diff-lib/COPYING path0/COPYING &&
  15        git update-index --add path0/COPYING &&
  16        tree=$(git write-tree) &&
  17        echo $tree
  18'
  19
  20blob=$(git hash-object "$TEST_DIRECTORY/diff-lib/COPYING")
  21test_expect_success 'prepare work tree' '
  22        cp path0/COPYING path1/COPYING &&
  23        git update-index --add --remove path0/COPYING path1/COPYING
  24'
  25
  26# In the tree, there is only path0/COPYING.  In the cache, path0 and
  27# path1 both have COPYING and the latter is a copy of path0/COPYING.
  28# Comparing the full tree with cache should tell us so.
  29
  30cat >expected <<EOF
  31:100644 100644 $blob $blob C100 path0/COPYING   path1/COPYING
  32EOF
  33
  34test_expect_success 'copy detection' '
  35        git diff-index -C --find-copies-harder $tree >current &&
  36        compare_diff_raw current expected
  37'
  38
  39test_expect_success 'copy detection, cached' '
  40        git diff-index -C --find-copies-harder --cached $tree >current &&
  41        compare_diff_raw current expected
  42'
  43
  44# In the tree, there is only path0/COPYING.  In the cache, path0 and
  45# path1 both have COPYING and the latter is a copy of path0/COPYING.
  46# However when we say we care only about path1, we should just see
  47# path1/COPYING suddenly appearing from nowhere, not detected as
  48# a copy from path0/COPYING.
  49
  50cat >expected <<EOF
  51:000000 100644 $ZERO_OID $blob A        path1/COPYING
  52EOF
  53
  54test_expect_success 'copy, limited to a subtree' '
  55        git diff-index -C --find-copies-harder $tree path1 >current &&
  56        compare_diff_raw current expected
  57'
  58
  59test_expect_success 'tweak work tree' '
  60        rm -f path0/COPYING &&
  61        git update-index --remove path0/COPYING
  62'
  63# In the tree, there is only path0/COPYING.  In the cache, path0 does
  64# not have COPYING anymore and path1 has COPYING which is a copy of
  65# path0/COPYING.  Showing the full tree with cache should tell us about
  66# the rename.
  67
  68cat >expected <<EOF
  69:100644 100644 $blob $blob R100 path0/COPYING   path1/COPYING
  70EOF
  71
  72test_expect_success 'rename detection' '
  73        git diff-index -C --find-copies-harder $tree >current &&
  74        compare_diff_raw current expected
  75'
  76
  77# In the tree, there is only path0/COPYING.  In the cache, path0 does
  78# not have COPYING anymore and path1 has COPYING which is a copy of
  79# path0/COPYING.  When we say we care only about path1, we should just
  80# see path1/COPYING appearing from nowhere.
  81
  82cat >expected <<EOF
  83:000000 100644 $ZERO_OID $blob A        path1/COPYING
  84EOF
  85
  86test_expect_success 'rename, limited to a subtree' '
  87        git diff-index -C --find-copies-harder $tree path1 >current &&
  88        compare_diff_raw current expected
  89'
  90
  91test_done