Merge branch 'ps/test-chmtime-get'
authorJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:29:00 +0000 (13:29 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Apr 2018 04:29:00 +0000 (13:29 +0900)
Test cleanup.

* ps/test-chmtime-get:
t/helper: 'test-chmtime (--get|-g)' to print only the mtime

1  2 
t/helper/test-chmtime.c
t/t2022-checkout-paths.sh
t/t3404-rebase-interactive.sh
t/t3510-cherry-pick-sequence.sh
t/t4200-rerere.sh
t/t5000-tar-tree.sh
t/t6022-merge-rename.sh
t/t6501-freshen-objects.sh
t/t7508-status.sh
t/t7701-repack-unpack-unreachable.sh
index 1790ceab510d53182225d3a28bbd4b4ef51abcdd,611e9520a88b63f57a6d18755b64d0dc72ce9348..aa22af48c2a6f48a81a6306a1850f5b5256fa319
   *
   * Examples:
   *
-  * To just print the mtime use --verbose and set the file mtime offset to 0:
+  * To print the mtime and the file name use --verbose and set
+  * the file mtime offset to 0:
   *
 - *    test-chmtime -v +0 file
 + *    test-tool chmtime -v +0 file
   *
 - *    test-chmtime --get file
+  * To print only the mtime use --get:
+  *
++ *    test-tool chmtime --get file
+  *
   * To set the mtime to current time:
   *
 - *    test-chmtime =+0 file
 + *    test-tool chmtime =+0 file
   *
 - *    test-chmtime --get +1 file
+  * To set the file mtime offset to +1 and print the new value:
+  *
++ *    test-tool chmtime --get +1 file
+  *
   */
 +#include "test-tool.h"
  #include "git-compat-util.h"
  #include <utime.h>
  
@@@ -57,9 -65,10 +66,10 @@@ static int timespec_arg(const char *arg
        return 1;
  }
  
 -int cmd_main(int argc, const char **argv)
 +int cmd__chmtime(int argc, const char **argv)
  {
        static int verbose;
+       static int get;
  
        int i = 1;
        /* no mtime change by default */
index e74d58b9e198a4ea2195d3fc6906e651a0a1d650,2a42083bf85cfba9346f2645b10a4e663519b9df..fc3eb43b890977bf793f6ed70e6d6caed2902407
@@@ -73,8 -73,8 +73,8 @@@ test_expect_success 'do not touch file
        git checkout HEAD -- file1 file2 &&
        echo one >expect &&
        test_cmp expect file1 &&
-       echo "1000000000        file2" >expect &&
-       test-tool chmtime -v +0 file2 >actual &&
+       echo "1000000000" >expect &&
 -      test-chmtime --get file2 >actual &&
++      test-tool chmtime --get file2 >actual &&
        test_cmp expect actual
  '
  
index 756de26c19c90429237456d3fb0bbbfd80ccfda9,6dfe77b18f59db8fa6f7fb7706d12636b901f6c8..59c766540e5361af0eab19e33d1d61ef650bc72d
@@@ -717,7 -705,7 +717,7 @@@ test_expect_success 'avoid unnecessary 
        set_fake_editor &&
        git rebase -i HEAD~4 &&
        test $HEAD = $(git rev-parse HEAD) &&
-       MTIME=$(test-tool chmtime -v +0 file3 | sed 's/[^0-9].*$//') &&
 -      MTIME=$(test-chmtime --get file3) &&
++      MTIME=$(test-tool chmtime --get file3) &&
        test 123456789 = $MTIME
  '
  
index 9f93445f1e496b930f4f7cb53146344315bc1c8e,34f2c7b49b74925c67a8951b37aff7a93ab0e9c4..21b4f194a2466b64023017b9711473f15187c638
@@@ -247,9 -247,9 +247,9 @@@ test_expect_success '--abort after las
  test_expect_success 'cherry-pick does not implicitly stomp an existing operation' '
        pristine_detach initial &&
        test_expect_code 1 git cherry-pick base..anotherpick &&
-       test-tool chmtime -v +0 .git/sequencer >expect &&
 -      test-chmtime --get .git/sequencer >expect &&
++      test-tool chmtime --get .git/sequencer >expect &&
        test_expect_code 128 git cherry-pick unrelatedpick &&
-       test-tool chmtime -v +0 .git/sequencer >actual &&
 -      test-chmtime --get .git/sequencer >actual &&
++      test-tool chmtime --get .git/sequencer >actual &&
        test_cmp expect actual
  '
  
index deafaa3e07546cea3d0bcf3aa3c00e2ba7e41406,e49f9862c7923649a451f8d4d7ac6bbc5762baa0..eaf18c81cbffe012663fae3a537ef8302d6c7b31
@@@ -166,7 -166,7 +166,7 @@@ test_expect_success 'first postimage wi
        git commit -q -a -m "prefer first over second" &&
        test -f $rr/postimage &&
  
-       oldmtimepost=$(test-tool chmtime -v -60 $rr/postimage | cut -f 1) &&
 -      oldmtimepost=$(test-chmtime --get -60 $rr/postimage) &&
++      oldmtimepost=$(test-tool chmtime --get -60 $rr/postimage) &&
  
        git checkout -b third master &&
        git show second^:a1 | sed "s/To die: t/To die! T/" >a1 &&
  '
  
  test_expect_success 'rerere updates postimage timestamp' '
-       newmtimepost=$(test-tool chmtime -v +0 $rr/postimage | cut -f 1) &&
 -      newmtimepost=$(test-chmtime --get $rr/postimage) &&
++      newmtimepost=$(test-tool chmtime --get $rr/postimage) &&
        test $oldmtimepost -lt $newmtimepost
  '
  
@@@ -512,7 -512,7 +512,7 @@@ test_expect_success 'multiple identica
        count_pre_post 2 0 &&
  
        # Pretend that the conflicts were made quite some time ago
-       find .git/rr-cache/ -type f | xargs test-tool chmtime -172800 &&
 -      test-chmtime -172800 $(find .git/rr-cache/ -type f) &&
++      test-tool chmtime -172800 $(find .git/rr-cache/ -type f) &&
  
        # Unresolved entries have not expired yet
        git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc &&
        git rerere &&
  
        # Pretend that the resolutions are old again
-       find .git/rr-cache/ -type f | xargs test-tool chmtime -172800 &&
 -      test-chmtime -172800 $(find .git/rr-cache/ -type f) &&
++      test-tool chmtime -172800 $(find .git/rr-cache/ -type f) &&
  
        # Resolved entries have not expired yet
        git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc &&
index af4d9b88762889fb5d2b390f2251bbb39a52d266,161a700af83344aa8dc3bff382875b775901111e..2a97b27b0a68f94ab7204764ced5fd1457da3d9c
@@@ -192,7 -192,7 +192,7 @@@ test_expect_success 
      'validate file modification time' \
      'mkdir extract &&
       "$TAR" xf b.tar -C extract a/a &&
-      test-tool chmtime -v +0 extract/a/a |cut -f 1 >b.mtime &&
 -     test-chmtime --get extract/a/a >b.mtime &&
++     test-tool chmtime --get extract/a/a >b.mtime &&
       echo "1117231200" >expected.mtime &&
       test_cmp expected.mtime b.mtime'
  
index a1fad6980b936152d599fee8cac82610404a0673,206aea0cc55c9dc6f24919f67a01d421f05b5515..48747e71df82bf20e053ac9475608ae9d9071d51
@@@ -635,10 -635,9 +635,9 @@@ test_expect_success 'setup avoid unnece
  
  test_expect_success 'avoid unnecessary update, normal rename' '
        git checkout -q avoid-unnecessary-update-1^0 &&
-       test-tool chmtime =1000000000 rename &&
-       test-tool chmtime -v +0 rename >expect &&
 -      test-chmtime --get =1000000000 rename >expect &&
++      test-tool chmtime --get =1000000000 rename >expect &&
        git merge merge-branch-1 &&
-       test-tool chmtime -v +0 rename >actual &&
 -      test-chmtime --get rename >actual &&
++      test-tool chmtime --get rename >actual &&
        test_cmp expect actual # "rename" should have stayed intact
  '
  
@@@ -668,10 -667,9 +667,9 @@@ test_expect_success 'setup to test avoi
  
  test_expect_success 'avoid unnecessary update, with D/F conflict' '
        git checkout -q avoid-unnecessary-update-2^0 &&
-       test-tool chmtime =1000000000 df &&
-       test-tool chmtime -v +0 df >expect &&
 -      test-chmtime --get =1000000000 df >expect &&
++      test-tool chmtime --get =1000000000 df >expect &&
        git merge merge-branch-2 &&
-       test-tool chmtime -v +0 df >actual &&
 -      test-chmtime --get df >actual &&
++      test-tool chmtime --get df >actual &&
        test_cmp expect actual # "df" should have stayed intact
  '
  
@@@ -700,10 -698,9 +698,9 @@@ test_expect_success 'setup avoid unnece
  
  test_expect_success 'avoid unnecessary update, dir->(file,nothing)' '
        git checkout -q master^0 &&
-       test-tool chmtime =1000000000 df &&
-       test-tool chmtime -v +0 df >expect &&
 -      test-chmtime --get =1000000000 df >expect &&
++      test-tool chmtime --get =1000000000 df >expect &&
        git merge side &&
-       test-tool chmtime -v +0 df >actual &&
 -      test-chmtime --get df >actual &&
++      test-tool chmtime --get df >actual &&
        test_cmp expect actual # "df" should have stayed intact
  '
  
@@@ -730,10 -727,9 +727,9 @@@ test_expect_success 'setup avoid unnece
  
  test_expect_success 'avoid unnecessary update, modify/delete' '
        git checkout -q master^0 &&
-       test-tool chmtime =1000000000 file &&
-       test-tool chmtime -v +0 file >expect &&
 -      test-chmtime --get =1000000000 file >expect &&
++      test-tool chmtime --get =1000000000 file >expect &&
        test_must_fail git merge side &&
-       test-tool chmtime -v +0 file >actual &&
 -      test-chmtime --get file >actual &&
++      test-tool chmtime --get file >actual &&
        test_cmp expect actual # "file" should have stayed intact
  '
  
@@@ -759,10 -755,9 +755,9 @@@ test_expect_success 'setup avoid unnece
  
  test_expect_success 'avoid unnecessary update, rename/add-dest' '
        git checkout -q master^0 &&
-       test-tool chmtime =1000000000 newfile &&
-       test-tool chmtime -v +0 newfile >expect &&
 -      test-chmtime --get =1000000000 newfile >expect &&
++      test-tool chmtime --get =1000000000 newfile >expect &&
        git merge side &&
-       test-tool chmtime -v +0 newfile >actual &&
 -      test-chmtime --get newfile >actual &&
++      test-tool chmtime --get newfile >actual &&
        test_cmp expect actual # "file" should have stayed intact
  '
  
index 765cced60b1055e1187e1fdc1c1c881814cebbf6,fa12bba9857cced965da0a8104ddfc3dd411e72c..033871ee5f35c1a143aec6d2b30c5116bf3f94f5
@@@ -72,8 -72,7 +72,7 @@@ for repack in '' true; d
        '
  
        test_expect_success "simulate time passing ($title)" '
-               find .git/objects -type f |
-               xargs test-tool chmtime -v -86400
 -              test-chmtime --get -86400 $(find .git/objects -type f)
++              test-tool chmtime --get -86400 $(find .git/objects -type f)
        '
  
        test_expect_success "start writing new commit with old blob ($title)" '
  
        test_expect_success "abandon objects again ($title)" '
                git reset --hard HEAD^ &&
-               find .git/objects -type f |
-               xargs test-tool chmtime -v -86400
 -              test-chmtime --get -86400 $(find .git/objects -type f)
++              test-tool chmtime --get -86400 $(find .git/objects -type f)
        '
  
        test_expect_success "start writing new commit with same tree ($title)" '
index 7afadb175a64c629214b7d6961ac345edb14ed84,2e19d590e5598e2cfbd52e0d99c4298da91fa104..18a40257fbb3226a328fdd520231972c111e6265
@@@ -1672,12 -1672,12 +1672,12 @@@ test_expect_success '"Initial commit" s
  '
  
  test_expect_success '--no-optional-locks prevents index update' '
 -      test-chmtime =1234567890 .git/index &&
 +      test-tool chmtime =1234567890 .git/index &&
        git --no-optional-locks status &&
-       test-tool chmtime -v +0 .git/index >out &&
 -      test-chmtime --get .git/index >out &&
++      test-tool chmtime --get .git/index >out &&
        grep ^1234567890 out &&
        git status &&
-       test-tool chmtime -v +0 .git/index >out &&
 -      test-chmtime --get .git/index >out &&
++      test-tool chmtime --get .git/index >out &&
        ! grep ^1234567890 out
  '
  
index 8a586ab0210bf6a7fcff7729d46bb882d50fe330,47f22555f191996db52d48ff9c583c9650b606a6..48261ba0805cd21e64bdf471f2835a7075782a6c
@@@ -90,7 -90,7 +90,7 @@@ test_expect_success 'unpacked objects r
        tmppack=".git/objects/pack/tmp_pack" &&
        ln "$packfile" "$tmppack" &&
        git repack -A -l -d &&
-       test-tool chmtime -v +0 "$tmppack" "$fsha1path" "$csha1path" "$tsha1path" \
 -      test-chmtime --get "$tmppack" "$fsha1path" "$csha1path" "$tsha1path" \
++      test-tool chmtime --get "$tmppack" "$fsha1path" "$csha1path" "$tsha1path" \
                > mtimes &&
        compare_mtimes < mtimes
  '