OSDN Git Service

cat-file: do not die on --textconv without textconv filters
authorMichael J Gruber <git@drmicha.warpmail.net>
Fri, 10 May 2013 15:10:13 +0000 (17:10 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 May 2013 17:27:16 +0000 (10:27 -0700)
When a command is supposed to use textconv filters (by default or with
"--textconv") and none are configured then the blob is output without
conversion; the only exception to this rule is "cat-file --textconv".

Make it behave like the rest of textconv aware commands.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/cat-file.c
t/t8007-cat-file-textconv.sh

index 40f87b4..fbaa121 100644 (file)
@@ -115,6 +115,14 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
        case 'e':
                return !has_sha1_file(sha1);
 
+       case 'c':
+               if (!obj_context.path[0])
+                       die("git cat-file --textconv %s: <object> must be <sha1:path>",
+                           obj_name);
+
+               if (textconv_object(obj_context.path, obj_context.mode, sha1, 1, &buf, &size))
+                       break;
+
        case 'p':
                type = sha1_object_info(sha1, NULL);
                if (type < 0)
@@ -141,16 +149,6 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
                /* otherwise just spit out the data */
                break;
 
-       case 'c':
-               if (!obj_context.path[0])
-                       die("git cat-file --textconv %s: <object> must be <sha1:path>",
-                           obj_name);
-
-               if (!textconv_object(obj_context.path, obj_context.mode, sha1, 1, &buf, &size))
-                       die("git cat-file --textconv: unable to run textconv on %s",
-                           obj_name);
-               break;
-
        case 0:
                if (type_from_string(exp_type) == OBJ_BLOB) {
                        unsigned char blob_sha1[20];
index 78a0085..83c6636 100755 (executable)
@@ -22,11 +22,11 @@ test_expect_success 'setup ' '
 '
 
 cat >expected <<EOF
-fatal: git cat-file --textconv: unable to run textconv on :one.bin
+bin: test version 2
 EOF
 
 test_expect_success 'no filter specified' '
-       git cat-file --textconv :one.bin 2>result
+       git cat-file --textconv :one.bin >result &&
        test_cmp expected result
 '
 
@@ -36,10 +36,6 @@ test_expect_success 'setup textconv filters' '
        git config diff.test.cachetextconv false
 '
 
-cat >expected <<EOF
-bin: test version 2
-EOF
-
 test_expect_success 'cat-file without --textconv' '
        git cat-file blob :one.bin >result &&
        test_cmp expected result
@@ -73,25 +69,19 @@ test_expect_success 'cat-file --textconv on previous commit' '
 '
 
 test_expect_success SYMLINKS 'cat-file without --textconv (symlink)' '
+       printf "%s" "one.bin" >expected &&
        git cat-file blob :symlink.bin >result &&
-       printf "%s" "one.bin" >expected
        test_cmp expected result
 '
 
 
 test_expect_success SYMLINKS 'cat-file --textconv on index (symlink)' '
-       ! git cat-file --textconv :symlink.bin 2>result &&
-       cat >expected <<\EOF &&
-fatal: git cat-file --textconv: unable to run textconv on :symlink.bin
-EOF
+       git cat-file --textconv :symlink.bin >result &&
        test_cmp expected result
 '
 
 test_expect_success SYMLINKS 'cat-file --textconv on HEAD (symlink)' '
-       ! git cat-file --textconv HEAD:symlink.bin 2>result &&
-       cat >expected <<EOF &&
-fatal: git cat-file --textconv: unable to run textconv on HEAD:symlink.bin
-EOF
+       git cat-file --textconv HEAD:symlink.bin >result &&
        test_cmp expected result
 '