]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper: merge test-sha1 into test-tool
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 24 Mar 2018 07:44:32 +0000 (08:44 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Mar 2018 15:45:47 +0000 (08:45 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/howto/recover-corrupted-object-harder.txt
Makefile
t/helper/test-sha1.c
t/helper/test-sha1.sh
t/helper/test-tool.c
t/helper/test-tool.h
t/lib-pack.sh
t/t0013-sha1dc.sh

index 9c4cd0915fe3f3e14879184f3a474e559130bdef..8994e2559eac0c5746ca898b0bad1946a7b83298 100644 (file)
@@ -80,7 +80,7 @@ valid pack like:
     # now add our object data
     cat object >>tmp.pack
     # and then append the pack trailer
-    /path/to/git.git/test-sha1 -b <tmp.pack >trailer
+    /path/to/git.git/t/helper/test-tool sha1 -b <tmp.pack >trailer
     cat trailer >>tmp.pack
 ------------
 
index 416a8e39c1d636f0597f3c3a3cc642714ef13aa1..3c0d0474af54cb22a6405d6dfd5ae6fbc9a7b581 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -653,6 +653,7 @@ X =
 PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 
 TEST_BUILTINS_OBJS += test-chmtime.o
+TEST_BUILTINS_OBJS += test-sha1.o
 
 TEST_PROGRAMS_NEED_X += test-ctype
 TEST_PROGRAMS_NEED_X += test-config
@@ -684,7 +685,6 @@ TEST_PROGRAMS_NEED_X += test-regex
 TEST_PROGRAMS_NEED_X += test-revision-walking
 TEST_PROGRAMS_NEED_X += test-run-command
 TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
-TEST_PROGRAMS_NEED_X += test-sha1
 TEST_PROGRAMS_NEED_X += test-sha1-array
 TEST_PROGRAMS_NEED_X += test-sigchain
 TEST_PROGRAMS_NEED_X += test-strcmp-offset
@@ -2502,7 +2502,7 @@ t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
 t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
 
-check-sha1:: t/helper/test-sha1$X
+check-sha1:: t/helper/test-tool$X
        t/helper/test-sha1.sh
 
 SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))
index a1c13f54eca0db7d11a5df134d565171d70b8cce..1ba0675c75f0d2dab281d054b577272cd45c39f9 100644 (file)
@@ -1,6 +1,7 @@
+#include "test-tool.h"
 #include "cache.h"
 
-int cmd_main(int ac, const char **av)
+int cmd__sha1(int ac, const char **av)
 {
        git_SHA_CTX ctx;
        unsigned char sha1[20];
index 750b95a0a1c39b4d761b7f2f861f6df4c85ecb65..84594885c703887c3b09aceb51583b9895ac3b45 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 dd if=/dev/zero bs=1048576 count=100 2>/dev/null |
-/usr/bin/time t/helper/test-sha1 >/dev/null
+/usr/bin/time t/helper/test-tool sha1 >/dev/null
 
 while read expect cnt pfx
 do
@@ -11,7 +11,7 @@ do
                        test -z "$pfx" || echo "$pfx"
                        dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
                        perl -pe 'y/\000/g/'
-               } | ./t/helper/test-sha1 $cnt
+               } | ./t/helper/test-tool sha1 $cnt
        )
        if test "$expect" = "$actual"
        then
index 0b1abe1ea24b9cde1f94b3bf0696b109a4a4c24d..11795130a695b87674480a1b8e13782c83729b16 100644 (file)
@@ -8,6 +8,7 @@ struct test_cmd {
 
 static struct test_cmd cmds[] = {
        { "chmtime", cmd__chmtime },
+       { "sha1", cmd__sha1 },
 };
 
 int cmd_main(int argc, const char **argv)
index 3a35e70e79e45448a393e3fb5d2fd44e97d935a2..a05b8bd14c4f1a79b787e597d12325a11e99654d 100644 (file)
@@ -2,5 +2,6 @@
 #define __TEST_TOOL_H__
 
 int cmd__chmtime(int argc, const char **argv);
+int cmd__sha1(int argc, const char **argv);
 
 #endif
index 75098465716512a3373e64d51a5cdf848e9f1101..501078249dc7d5d5b27dd6b75a22086767a0eddf 100644 (file)
@@ -85,7 +85,7 @@ pack_obj () {
 
 # Compute and append pack trailer to "$1"
 pack_trailer () {
-       test-sha1 -b <"$1" >trailer.tmp &&
+       test-tool sha1 -b <"$1" >trailer.tmp &&
        cat trailer.tmp >>"$1" &&
        rm -f trailer.tmp
 }
index 6d655cb161b2ed39eda97bb4acb54d1cf74a826d..419f31a8f7d4cb20041f054d25ddb25c7d43e3fb 100755 (executable)
@@ -11,7 +11,7 @@ then
 fi
 
 test_expect_success 'test-sha1 detects shattered pdf' '
-       test_must_fail test-sha1 <"$TEST_DATA/shattered-1.pdf" 2>err &&
+       test_must_fail test-tool sha1 <"$TEST_DATA/shattered-1.pdf" 2>err &&
        test_i18ngrep collision err &&
        grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err
 '