[PATCH] Make ls-* output consistent with diff-* output format.
authorJunio C Hamano <junkio@cox.net>
Thu, 26 May 2005 21:38:19 +0000 (14:38 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 26 May 2005 22:18:55 +0000 (15:18 -0700)
Use SP as the column separator except the ones before path which
uses TAB, to make the output format consistent across ls-* and
diff-* commands.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
ls-files.c
ls-tree.c
t/t0000-basic.sh
t/t1000-read-tree-m-3way.sh
t/t3100-ls-tree-restrict.sh

index 03b2182..c6c32d9 100644 (file)
@@ -262,7 +262,7 @@ static void show_files(void)
                                       tag_cached,
                                       ce->name, line_terminator);
                        else
                                       tag_cached,
                                       ce->name, line_terminator);
                        else
-                               printf("%s%06o %s %d %s%c",
+                               printf("%s%06o %s %d\t%s%c",
                                       ce_stage(ce) ? tag_unmerged :
                                       tag_cached,
                                       ntohl(ce->ce_mode),
                                       ce_stage(ce) ? tag_unmerged :
                                       tag_cached,
                                       ntohl(ce->ce_mode),
index 896f4fd..26cea3f 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -127,7 +127,7 @@ static void list_recursive(void *buffer,
                 * print out the info
                 */
                if (!matches || (matched != NULL && mtype == 0)) {
                 * print out the info
                 */
                if (!matches || (matched != NULL && mtype == 0)) {
-                       printf("%06o\t%s\t%s\t", mode,
+                       printf("%06o %s %s\t", mode,
                               S_ISDIR(mode) ? "tree" : "blob",
                               sha1_to_hex(sha1));
                        print_path_prefix(&this_prefix);
                               S_ISDIR(mode) ? "tree" : "blob",
                               sha1_to_hex(sha1));
                        print_path_prefix(&this_prefix);
index b521f51..4462f57 100755 (executable)
@@ -92,14 +92,14 @@ test_expect_success \
     'git-ls-files --stage >current'
 
 cat >expected <<\EOF
     'git-ls-files --stage >current'
 
 cat >expected <<\EOF
-100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
-120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0 path0sym
-100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0 path2/file2
-120000 d8ce161addc5173867a3c3c730924388daedbc38 0 path2/file2sym
-100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0 path3/file3
-120000 8599103969b43aff7e430efea79ca4636466794f 0 path3/file3sym
-100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0 path3/subp3/file3
-120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym
+100644 f87290f8eb2cbbea7857214459a0739927eab154 0      path0
+120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0      path0sym
+100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0      path2/file2
+120000 d8ce161addc5173867a3c3c730924388daedbc38 0      path2/file2sym
+100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0      path3/file3
+120000 8599103969b43aff7e430efea79ca4636466794f 0      path3/file3sym
+100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0      path3/subp3/file3
+120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0      path3/subp3/file3sym
 EOF
 test_expect_success \
     'validate git-ls-files output for a known tree.' \
 EOF
 test_expect_success \
     'validate git-ls-files output for a known tree.' \
@@ -116,10 +116,10 @@ test_expect_success \
     'showing tree with git-ls-tree' \
     'git-ls-tree $tree >current'
 cat >expected <<\EOF
     'showing tree with git-ls-tree' \
     'git-ls-tree $tree >current'
 cat >expected <<\EOF
-100644 blob    f87290f8eb2cbbea7857214459a0739927eab154        path0
-120000 blob    15a98433ae33114b085f3eb3bb03b832b3180a01        path0sym
-040000 tree    58a09c23e2ca152193f2786e06986b7b6712bdbe        path2
-040000 tree    21ae8269cacbe57ae09138dcc3a2887f904d02b3        path3
+100644 blob f87290f8eb2cbbea7857214459a0739927eab154   path0
+120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01   path0sym
+040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe   path2
+040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3   path3
 EOF
 test_expect_success \
     'git-ls-tree output for a known tree.' \
 EOF
 test_expect_success \
     'git-ls-tree output for a known tree.' \
@@ -129,17 +129,17 @@ test_expect_success \
     'showing tree with git-ls-tree -r' \
     'git-ls-tree -r $tree >current'
 cat >expected <<\EOF
     'showing tree with git-ls-tree -r' \
     'git-ls-tree -r $tree >current'
 cat >expected <<\EOF
-100644 blob    f87290f8eb2cbbea7857214459a0739927eab154        path0
-120000 blob    15a98433ae33114b085f3eb3bb03b832b3180a01        path0sym
-040000 tree    58a09c23e2ca152193f2786e06986b7b6712bdbe        path2
-100644 blob    3feff949ed00a62d9f7af97c15cd8a30595e7ac7        path2/file2
-120000 blob    d8ce161addc5173867a3c3c730924388daedbc38        path2/file2sym
-040000 tree    21ae8269cacbe57ae09138dcc3a2887f904d02b3        path3
-100644 blob    0aa34cae68d0878578ad119c86ca2b5ed5b28376        path3/file3
-120000 blob    8599103969b43aff7e430efea79ca4636466794f        path3/file3sym
-040000 tree    3c5e5399f3a333eddecce7a9b9465b63f65f51e2        path3/subp3
-100644 blob    00fb5908cb97c2564a9783c0c64087333b3b464f        path3/subp3/file3
-120000 blob    6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c        path3/subp3/file3sym
+100644 blob f87290f8eb2cbbea7857214459a0739927eab154   path0
+120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01   path0sym
+040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe   path2
+100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7   path2/file2
+120000 blob d8ce161addc5173867a3c3c730924388daedbc38   path2/file2sym
+040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3   path3
+100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376   path3/file3
+120000 blob 8599103969b43aff7e430efea79ca4636466794f   path3/file3sym
+040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2   path3/subp3
+100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f   path3/subp3/file3
+120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c   path3/subp3/file3sym
 EOF
 test_expect_success \
     'git-ls-tree -r output for a known tree.' \
 EOF
 test_expect_success \
     'git-ls-tree -r output for a known tree.' \
index bd7406f..72bc122 100755 (executable)
@@ -81,60 +81,60 @@ test_expect_success \
     '3-way merge with git-read-tree -m' \
     "git-read-tree -m $tree_O $tree_A $tree_B"
 
     '3-way merge with git-read-tree -m' \
     "git-read-tree -m $tree_O $tree_A $tree_B"
 
-strip_object_id='s/^\([0-7]*\) [0-9a-f]* \([0-3].*\)$/\1 \2/'
-
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 test_expect_success \
     'git-ls-files --stage of the merge result' \
     'git-ls-files --stage >current- &&
 test_expect_success \
     'git-ls-files --stage of the merge result' \
     'git-ls-files --stage >current- &&
-     sed -e "$strip_object_id" <current- >current'
+     sed -e "s/ $_x40 / X /" <current- >current'
 
 cat >expected <<\EOF
 
 cat >expected <<\EOF
-100644 2 AA
-100644 3 AA
-100644 2 AN
-100644 1 DD
-100644 3 DF
-100644 2 DF/DF
-100644 1 DM
-100644 3 DM
-100644 1 DN
-100644 3 DN
-100644 2 LL
-100644 3 LL
-100644 1 MD
-100644 2 MD
-100644 1 MM
-100644 2 MM
-100644 3 MM
-100644 0 MN
-100644 3 NA
-100644 1 ND
-100644 2 ND
-100644 0 NM
-100644 0 NN
-100644 0 SS
-100644 1 TT
-100644 2 TT
-100644 3 TT
-100644 2 Z/AA
-100644 3 Z/AA
-100644 2 Z/AN
-100644 1 Z/DD
-100644 1 Z/DM
-100644 3 Z/DM
-100644 1 Z/DN
-100644 3 Z/DN
-100644 1 Z/MD
-100644 2 Z/MD
-100644 1 Z/MM
-100644 2 Z/MM
-100644 3 Z/MM
-100644 0 Z/MN
-100644 3 Z/NA
-100644 1 Z/ND
-100644 2 Z/ND
-100644 0 Z/NM
-100644 0 Z/NN
+100644 X 2     AA
+100644 X 3     AA
+100644 X 2     AN
+100644 X 1     DD
+100644 X 3     DF
+100644 X 2     DF/DF
+100644 X 1     DM
+100644 X 3     DM
+100644 X 1     DN
+100644 X 3     DN
+100644 X 2     LL
+100644 X 3     LL
+100644 X 1     MD
+100644 X 2     MD
+100644 X 1     MM
+100644 X 2     MM
+100644 X 3     MM
+100644 X 0     MN
+100644 X 3     NA
+100644 X 1     ND
+100644 X 2     ND
+100644 X 0     NM
+100644 X 0     NN
+100644 X 0     SS
+100644 X 1     TT
+100644 X 2     TT
+100644 X 3     TT
+100644 X 2     Z/AA
+100644 X 3     Z/AA
+100644 X 2     Z/AN
+100644 X 1     Z/DD
+100644 X 1     Z/DM
+100644 X 3     Z/DM
+100644 X 1     Z/DN
+100644 X 3     Z/DN
+100644 X 1     Z/MD
+100644 X 2     Z/MD
+100644 X 1     Z/MM
+100644 X 2     Z/MM
+100644 X 3     Z/MM
+100644 X 0     Z/MN
+100644 X 3     Z/NA
+100644 X 1     Z/ND
+100644 X 2     Z/ND
+100644 X 0     Z/NM
+100644 X 0     Z/NN
 EOF
 
 test_expect_success \
 EOF
 
 test_expect_success \
index 095b328..70fa9ac 100644 (file)
@@ -34,7 +34,7 @@ test_expect_success \
 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 test_output () {
 _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 test_output () {
-    sed -e "s/ $_x40   /       X       /" <current >check
+    sed -e "s/ $_x40   / X     /" <current >check
     diff -u expected check
 }
 
     diff -u expected check
 }
 
@@ -42,9 +42,9 @@ test_expect_success \
     'ls-tree plain' \
     'git-ls-tree $tree >current &&
      cat >expected <<\EOF &&
     'ls-tree plain' \
     'git-ls-tree $tree >current &&
      cat >expected <<\EOF &&
-100644 blob    X       path0
-120000 blob    X       path1
-040000 tree    X       path2
+100644 blob X  path0
+120000 blob X  path1
+040000 tree X  path2
 EOF
      test_output'
 
 EOF
      test_output'
 
@@ -52,13 +52,13 @@ test_expect_success \
     'ls-tree recursive' \
     'git-ls-tree -r $tree >current &&
      cat >expected <<\EOF &&
     'ls-tree recursive' \
     'git-ls-tree -r $tree >current &&
      cat >expected <<\EOF &&
-100644 blob    X       path0
-120000 blob    X       path1
-040000 tree    X       path2
-040000 tree    X       path2/baz
-100644 blob    X       path2/baz/b
-120000 blob    X       path2/bazbo
-100644 blob    X       path2/foo
+100644 blob X  path0
+120000 blob X  path1
+040000 tree X  path2
+040000 tree X  path2/baz
+100644 blob X  path2/baz/b
+120000 blob X  path2/bazbo
+100644 blob X  path2/foo
 EOF
      test_output'
 
 EOF
      test_output'
 
@@ -74,8 +74,8 @@ test_expect_success \
     'ls-tree filtered' \
     'git-ls-tree $tree path1 path0 >current &&
      cat >expected <<\EOF &&
     'ls-tree filtered' \
     'git-ls-tree $tree path1 path0 >current &&
      cat >expected <<\EOF &&
-100644 blob    X       path0
-120000 blob    X       path1
+100644 blob X  path0
+120000 blob X  path1
 EOF
      test_output'
 
 EOF
      test_output'
 
@@ -83,11 +83,11 @@ test_expect_success \
     'ls-tree filtered' \
     'git-ls-tree $tree path2 >current &&
      cat >expected <<\EOF &&
     'ls-tree filtered' \
     'git-ls-tree $tree path2 >current &&
      cat >expected <<\EOF &&
-040000 tree    X       path2
-040000 tree    X       path2/baz
-100644 blob    X       path2/baz/b
-120000 blob    X       path2/bazbo
-100644 blob    X       path2/foo
+040000 tree X  path2
+040000 tree X  path2/baz
+100644 blob X  path2/baz/b
+120000 blob X  path2/bazbo
+100644 blob X  path2/foo
 EOF
      test_output'
 
 EOF
      test_output'
 
@@ -95,8 +95,8 @@ test_expect_success \
     'ls-tree filtered' \
     'git-ls-tree $tree path2/baz >current &&
      cat >expected <<\EOF &&
     'ls-tree filtered' \
     'git-ls-tree $tree path2/baz >current &&
      cat >expected <<\EOF &&
-040000 tree    X       path2/baz
-100644 blob    X       path2/baz/b
+040000 tree X  path2/baz
+100644 blob X  path2/baz/b
 EOF
      test_output'
 
 EOF
      test_output'