Fossil SCM
Add options for drawing the file tree with Unicode symbols or ASCII characters (Windows defaults to the latter, all others to the former).
Commit
635fa090d10a20436e281e040c3a50f6a98ef9c4b474e1db6c4e8b3eb6064b70
Parent
dd72a96111edd29…
1 file changed
+61
-17
+61
-17
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -646,25 +646,40 @@ | ||
| 646 | 646 | */ |
| 647 | 647 | static const char *print_filelist_section( |
| 648 | 648 | const char *zIn, /* List of filenames, separated by \n */ |
| 649 | 649 | const char *zLast, /* Last filename in the list to print */ |
| 650 | 650 | const char *zPrefix, /* Prefix so put before each output line */ |
| 651 | - int nDir /* Ignore this many characters of directory name */ | |
| 651 | + int nDir, /* Ignore this many characters of directory name */ | |
| 652 | + int treeFmt /* 1 = use Unicode symbols, 2 = use ASCII chars */ | |
| 652 | 653 | ){ |
| 654 | + const char *treeEntry = "|-- "; | |
| 655 | + const char *treeLastE = "`-- "; | |
| 656 | + const char *treeContu = "| "; | |
| 657 | + const char *treeBlank = " "; | |
| 658 | + if( treeFmt == 1 ){ | |
| 659 | + treeEntry = "\342\224\234\342\224\200\342\224\200 "; | |
| 660 | + treeLastE = "\342\224\224\342\224\200\342\224\200 "; | |
| 661 | + treeContu = "\342\224\202 "; | |
| 662 | + } | |
| 653 | 663 | while( zIn<=zLast ){ |
| 654 | 664 | int i; |
| 665 | + // const char *treeContu = (treeFmt == 1) ? "\342\224\202 " : "| "; | |
| 666 | + // const char *treeEntry = (treeFmt == 1) ? "\342\224\234\342\224\200\342\224\200 " : "|-- "; | |
| 667 | + // const char *treeLastE = (treeFmt == 1) ? "\342\224\224\342\224\200\342\224\200 " : "`-- "; | |
| 668 | + // const char *treeBlank = " "; | |
| 655 | 669 | for(i=nDir; zIn[i]!='\n' && zIn[i]!='/'; i++){} |
| 656 | 670 | if( zIn[i]=='/' ){ |
| 657 | 671 | char *zSubPrefix; |
| 658 | 672 | const char *zSubLast = last_line(zIn, i+1); |
| 659 | - zSubPrefix = mprintf("%s%s", zPrefix, zSubLast==zLast ? BLANK : CONTU); | |
| 660 | - fossil_print("%s%s%.*s\n", zPrefix, zSubLast==zLast ? LASTE : ENTRY, | |
| 661 | - i-nDir, &zIn[nDir]); | |
| 662 | - zIn = print_filelist_section(zIn, zSubLast, zSubPrefix, i+1); | |
| 673 | + zSubPrefix = mprintf("%s%s", zPrefix, | |
| 674 | + zSubLast==zLast ? treeBlank : treeContu); | |
| 675 | + fossil_print("%s%s%.*s\n", zPrefix, | |
| 676 | + zSubLast==zLast ? treeLastE : treeEntry, i-nDir, &zIn[nDir]); | |
| 677 | + zIn = print_filelist_section(zIn, zSubLast, zSubPrefix, i+1, treeFmt); | |
| 663 | 678 | fossil_free(zSubPrefix); |
| 664 | 679 | }else{ |
| 665 | - fossil_print("%s%s%.*s\n", zPrefix, zIn==zLast ? LASTE : ENTRY, | |
| 680 | + fossil_print("%s%s%.*s\n", zPrefix, zIn==zLast ? treeLastE : treeEntry, | |
| 666 | 681 | i-nDir, &zIn[nDir]); |
| 667 | 682 | zIn = next_line(zIn); |
| 668 | 683 | } |
| 669 | 684 | } |
| 670 | 685 | return zIn; |
| @@ -673,18 +688,18 @@ | ||
| 673 | 688 | /* |
| 674 | 689 | ** Input blob pList is a list of filenames, one filename per line, |
| 675 | 690 | ** in sorted order and with / directory separators. Output this list |
| 676 | 691 | ** as a tree in a manner similar to the "tree" command on Linux. |
| 677 | 692 | */ |
| 678 | -static void print_filelist_as_tree(Blob *pList){ | |
| 693 | +static void print_filelist_as_tree(Blob *pList, int treeFmt){ | |
| 679 | 694 | char *zAll; |
| 680 | 695 | const char *zLast; |
| 681 | 696 | fossil_print("%s\n", g.zLocalRoot); |
| 682 | 697 | zAll = blob_str(pList); |
| 683 | 698 | if( zAll[0] ){ |
| 684 | 699 | zLast = last_line(zAll, 0); |
| 685 | - print_filelist_section(zAll, zLast, "", 0); | |
| 700 | + print_filelist_section(zAll, zLast, "", 0, treeFmt); | |
| 686 | 701 | } |
| 687 | 702 | } |
| 688 | 703 | |
| 689 | 704 | /* |
| 690 | 705 | ** Take care of -r version of ls command |
| @@ -760,11 +775,11 @@ | ||
| 760 | 775 | fossil_print("%s\n", zFile); |
| 761 | 776 | } |
| 762 | 777 | } |
| 763 | 778 | db_finalize(&q); |
| 764 | 779 | if( treeFmt ){ |
| 765 | - print_filelist_as_tree(&out); | |
| 780 | + print_filelist_as_tree(&out, treeFmt); | |
| 766 | 781 | blob_reset(&out); |
| 767 | 782 | } |
| 768 | 783 | } |
| 769 | 784 | |
| 770 | 785 | /* |
| @@ -792,26 +807,30 @@ | ||
| 792 | 807 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 793 | 808 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 794 | 809 | ** |
| 795 | 810 | ** Options: |
| 796 | 811 | ** --age Show when each file was committed |
| 797 | -** -v|--verbose Provide extra information about each file | |
| 798 | -** -t Sort output in time order | |
| 799 | -** --tree Tree format | |
| 812 | +** -a|--ascii-tree Use ASCII characters when drawing the tree | |
| 813 | +** --hash With -v, verify file status using hashing | |
| 814 | +** rather than relying on file sizes and mtimes | |
| 800 | 815 | ** -r VERSION The specific check-in to list |
| 801 | 816 | ** -R|--repository REPO Extract info from repository REPO |
| 802 | -** --hash With -v, verify file status using hashing | |
| 803 | -** rather than relying on file sizes and mtimes | |
| 817 | +** -t Sort output in time order | |
| 818 | +** --tree Tree format | |
| 819 | +** -u|--unicode-tree Use Unicode symbols when drawing the tree | |
| 820 | +** -v|--verbose Provide extra information about each file | |
| 804 | 821 | ** |
| 805 | 822 | ** See also: [[changes]], [[extras]], [[status]], [[tree]] |
| 806 | 823 | */ |
| 807 | 824 | void ls_cmd(void){ |
| 808 | 825 | int vid; |
| 809 | 826 | Stmt q; |
| 810 | 827 | int verboseFlag; |
| 811 | 828 | int showAge; |
| 812 | 829 | int treeFmt; |
| 830 | + int asciiTree; | |
| 831 | + int unicodeTree; | |
| 813 | 832 | int timeOrder; |
| 814 | 833 | char *zOrderBy = "pathname"; |
| 815 | 834 | Blob where; |
| 816 | 835 | int i; |
| 817 | 836 | int useHash = 0; |
| @@ -827,12 +846,19 @@ | ||
| 827 | 846 | timeOrder = find_option("t","t",0)!=0; |
| 828 | 847 | if( verboseFlag ){ |
| 829 | 848 | useHash = find_option("hash",0,0)!=0; |
| 830 | 849 | } |
| 831 | 850 | treeFmt = find_option("tree",0,0)!=0; |
| 851 | + asciiTree = find_option("ascii-tree","a",0)!=0; | |
| 852 | + unicodeTree = find_option("unicode-tree","u",0)!=0; | |
| 832 | 853 | if( treeFmt ){ |
| 833 | 854 | if( zRev==0 ) zRev = "current"; |
| 855 | +#ifdef _WIN32 | |
| 856 | + treeFmt = 2; | |
| 857 | +#endif | |
| 858 | + if( unicodeTree ) treeFmt = 1; | |
| 859 | + if( asciiTree ) treeFmt = 2; | |
| 834 | 860 | } |
| 835 | 861 | |
| 836 | 862 | if( zRev!=0 ){ |
| 837 | 863 | db_find_and_open_repository(0, 0); |
| 838 | 864 | verify_all_options(); |
| @@ -945,23 +971,32 @@ | ||
| 945 | 971 | ** List all files in the current check-out in after the fashion of the |
| 946 | 972 | ** "tree" command. If PATHS is included, only the named files |
| 947 | 973 | ** (or their children if directories) are shown. |
| 948 | 974 | ** |
| 949 | 975 | ** Options: |
| 976 | +** -a|--ascii-tree Use ASCII characters when drawing the tree | |
| 950 | 977 | ** -r VERSION The specific check-in to list |
| 951 | 978 | ** -R|--repository REPO Extract info from repository REPO |
| 979 | +** -u|--unicode-tree Use Unicode symbols when drawing the tree | |
| 952 | 980 | ** |
| 953 | 981 | ** See also: [[ls]] |
| 954 | 982 | */ |
| 955 | 983 | void tree_cmd(void){ |
| 956 | 984 | const char *zRev; |
| 957 | - | |
| 985 | + int treeFmt = 1; | |
| 986 | + int asciiTree = find_option("ascii-tree","a",0)!=0; | |
| 987 | + int unicodeTree = find_option("unicode-tree","u",0)!=0; | |
| 988 | +#ifdef _WIN32 | |
| 989 | + treeFmt = 2; | |
| 990 | +#endif | |
| 991 | + if( unicodeTree ) treeFmt = 1; | |
| 992 | + if( asciiTree ) treeFmt = 2; | |
| 958 | 993 | zRev = find_option("r","r",1); |
| 959 | 994 | if( zRev==0 ) zRev = "current"; |
| 960 | 995 | db_find_and_open_repository(0, 0); |
| 961 | 996 | verify_all_options(); |
| 962 | - ls_cmd_rev(zRev,0,0,0,1); | |
| 997 | + ls_cmd_rev(zRev, 0, 0, 0, treeFmt); | |
| 963 | 998 | } |
| 964 | 999 | |
| 965 | 1000 | /* |
| 966 | 1001 | ** COMMAND: extras |
| 967 | 1002 | ** |
| @@ -981,17 +1016,19 @@ | ||
| 981 | 1016 | ** Pathnames are displayed according to the "relative-paths" setting, |
| 982 | 1017 | ** unless overridden by the --abs-paths or --rel-paths options. |
| 983 | 1018 | ** |
| 984 | 1019 | ** Options: |
| 985 | 1020 | ** --abs-paths Display absolute pathnames |
| 1021 | +** -a|--ascii-tree Use ASCII characters when drawing the tree | |
| 986 | 1022 | ** --case-sensitive BOOL Override case-sensitive setting |
| 987 | 1023 | ** --dotfiles Include files beginning with a dot (".") |
| 988 | 1024 | ** --header Identify the repository if there are extras |
| 989 | 1025 | ** --ignore CSG Ignore files matching patterns from the argument |
| 990 | 1026 | ** --rel-paths Display pathnames relative to the current working |
| 991 | 1027 | ** directory |
| 992 | 1028 | ** --tree Show output in the tree format |
| 1029 | +** -u|--unicode-tree Use Unicode symbols when drawing the tree | |
| 993 | 1030 | ** |
| 994 | 1031 | ** See also: [[changes]], [[clean]], [[status]] |
| 995 | 1032 | */ |
| 996 | 1033 | void extras_cmd(void){ |
| 997 | 1034 | Blob report = BLOB_INITIALIZER; |
| @@ -998,10 +1035,12 @@ | ||
| 998 | 1035 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 999 | 1036 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 1000 | 1037 | unsigned flags = C_EXTRA; |
| 1001 | 1038 | int showHdr = find_option("header",0,0)!=0; |
| 1002 | 1039 | int treeFmt = find_option("tree",0,0)!=0; |
| 1040 | + int asciiTree = find_option("ascii-tree","a",0)!=0; | |
| 1041 | + int unicodeTree = find_option("unicode-tree","u",0)!=0; | |
| 1003 | 1042 | Glob *pIgnore; |
| 1004 | 1043 | |
| 1005 | 1044 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| 1006 | 1045 | db_must_be_within_tree(); |
| 1007 | 1046 | |
| @@ -1011,10 +1050,15 @@ | ||
| 1011 | 1050 | |
| 1012 | 1051 | if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL; |
| 1013 | 1052 | |
| 1014 | 1053 | if( treeFmt ){ |
| 1015 | 1054 | flags &= ~C_RELPATH; |
| 1055 | +#ifdef _WIN32 | |
| 1056 | + treeFmt = 2; | |
| 1057 | +#endif | |
| 1058 | + if( unicodeTree ) treeFmt = 1; | |
| 1059 | + if( asciiTree ) treeFmt = 2; | |
| 1016 | 1060 | } |
| 1017 | 1061 | |
| 1018 | 1062 | /* We should be done with options.. */ |
| 1019 | 1063 | verify_all_options(); |
| 1020 | 1064 | |
| @@ -1031,11 +1075,11 @@ | ||
| 1031 | 1075 | if( showHdr ){ |
| 1032 | 1076 | fossil_print("Extras for %s at %s:\n", db_get("project-name","<unnamed>"), |
| 1033 | 1077 | g.zLocalRoot); |
| 1034 | 1078 | } |
| 1035 | 1079 | if( treeFmt ){ |
| 1036 | - print_filelist_as_tree(&report); | |
| 1080 | + print_filelist_as_tree(&report, treeFmt); | |
| 1037 | 1081 | }else{ |
| 1038 | 1082 | blob_write_to_file(&report, "-"); |
| 1039 | 1083 | } |
| 1040 | 1084 | } |
| 1041 | 1085 | blob_reset(&report); |
| 1042 | 1086 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -646,25 +646,40 @@ | |
| 646 | */ |
| 647 | static const char *print_filelist_section( |
| 648 | const char *zIn, /* List of filenames, separated by \n */ |
| 649 | const char *zLast, /* Last filename in the list to print */ |
| 650 | const char *zPrefix, /* Prefix so put before each output line */ |
| 651 | int nDir /* Ignore this many characters of directory name */ |
| 652 | ){ |
| 653 | while( zIn<=zLast ){ |
| 654 | int i; |
| 655 | for(i=nDir; zIn[i]!='\n' && zIn[i]!='/'; i++){} |
| 656 | if( zIn[i]=='/' ){ |
| 657 | char *zSubPrefix; |
| 658 | const char *zSubLast = last_line(zIn, i+1); |
| 659 | zSubPrefix = mprintf("%s%s", zPrefix, zSubLast==zLast ? BLANK : CONTU); |
| 660 | fossil_print("%s%s%.*s\n", zPrefix, zSubLast==zLast ? LASTE : ENTRY, |
| 661 | i-nDir, &zIn[nDir]); |
| 662 | zIn = print_filelist_section(zIn, zSubLast, zSubPrefix, i+1); |
| 663 | fossil_free(zSubPrefix); |
| 664 | }else{ |
| 665 | fossil_print("%s%s%.*s\n", zPrefix, zIn==zLast ? LASTE : ENTRY, |
| 666 | i-nDir, &zIn[nDir]); |
| 667 | zIn = next_line(zIn); |
| 668 | } |
| 669 | } |
| 670 | return zIn; |
| @@ -673,18 +688,18 @@ | |
| 673 | /* |
| 674 | ** Input blob pList is a list of filenames, one filename per line, |
| 675 | ** in sorted order and with / directory separators. Output this list |
| 676 | ** as a tree in a manner similar to the "tree" command on Linux. |
| 677 | */ |
| 678 | static void print_filelist_as_tree(Blob *pList){ |
| 679 | char *zAll; |
| 680 | const char *zLast; |
| 681 | fossil_print("%s\n", g.zLocalRoot); |
| 682 | zAll = blob_str(pList); |
| 683 | if( zAll[0] ){ |
| 684 | zLast = last_line(zAll, 0); |
| 685 | print_filelist_section(zAll, zLast, "", 0); |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | /* |
| 690 | ** Take care of -r version of ls command |
| @@ -760,11 +775,11 @@ | |
| 760 | fossil_print("%s\n", zFile); |
| 761 | } |
| 762 | } |
| 763 | db_finalize(&q); |
| 764 | if( treeFmt ){ |
| 765 | print_filelist_as_tree(&out); |
| 766 | blob_reset(&out); |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | /* |
| @@ -792,26 +807,30 @@ | |
| 792 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 793 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 794 | ** |
| 795 | ** Options: |
| 796 | ** --age Show when each file was committed |
| 797 | ** -v|--verbose Provide extra information about each file |
| 798 | ** -t Sort output in time order |
| 799 | ** --tree Tree format |
| 800 | ** -r VERSION The specific check-in to list |
| 801 | ** -R|--repository REPO Extract info from repository REPO |
| 802 | ** --hash With -v, verify file status using hashing |
| 803 | ** rather than relying on file sizes and mtimes |
| 804 | ** |
| 805 | ** See also: [[changes]], [[extras]], [[status]], [[tree]] |
| 806 | */ |
| 807 | void ls_cmd(void){ |
| 808 | int vid; |
| 809 | Stmt q; |
| 810 | int verboseFlag; |
| 811 | int showAge; |
| 812 | int treeFmt; |
| 813 | int timeOrder; |
| 814 | char *zOrderBy = "pathname"; |
| 815 | Blob where; |
| 816 | int i; |
| 817 | int useHash = 0; |
| @@ -827,12 +846,19 @@ | |
| 827 | timeOrder = find_option("t","t",0)!=0; |
| 828 | if( verboseFlag ){ |
| 829 | useHash = find_option("hash",0,0)!=0; |
| 830 | } |
| 831 | treeFmt = find_option("tree",0,0)!=0; |
| 832 | if( treeFmt ){ |
| 833 | if( zRev==0 ) zRev = "current"; |
| 834 | } |
| 835 | |
| 836 | if( zRev!=0 ){ |
| 837 | db_find_and_open_repository(0, 0); |
| 838 | verify_all_options(); |
| @@ -945,23 +971,32 @@ | |
| 945 | ** List all files in the current check-out in after the fashion of the |
| 946 | ** "tree" command. If PATHS is included, only the named files |
| 947 | ** (or their children if directories) are shown. |
| 948 | ** |
| 949 | ** Options: |
| 950 | ** -r VERSION The specific check-in to list |
| 951 | ** -R|--repository REPO Extract info from repository REPO |
| 952 | ** |
| 953 | ** See also: [[ls]] |
| 954 | */ |
| 955 | void tree_cmd(void){ |
| 956 | const char *zRev; |
| 957 | |
| 958 | zRev = find_option("r","r",1); |
| 959 | if( zRev==0 ) zRev = "current"; |
| 960 | db_find_and_open_repository(0, 0); |
| 961 | verify_all_options(); |
| 962 | ls_cmd_rev(zRev,0,0,0,1); |
| 963 | } |
| 964 | |
| 965 | /* |
| 966 | ** COMMAND: extras |
| 967 | ** |
| @@ -981,17 +1016,19 @@ | |
| 981 | ** Pathnames are displayed according to the "relative-paths" setting, |
| 982 | ** unless overridden by the --abs-paths or --rel-paths options. |
| 983 | ** |
| 984 | ** Options: |
| 985 | ** --abs-paths Display absolute pathnames |
| 986 | ** --case-sensitive BOOL Override case-sensitive setting |
| 987 | ** --dotfiles Include files beginning with a dot (".") |
| 988 | ** --header Identify the repository if there are extras |
| 989 | ** --ignore CSG Ignore files matching patterns from the argument |
| 990 | ** --rel-paths Display pathnames relative to the current working |
| 991 | ** directory |
| 992 | ** --tree Show output in the tree format |
| 993 | ** |
| 994 | ** See also: [[changes]], [[clean]], [[status]] |
| 995 | */ |
| 996 | void extras_cmd(void){ |
| 997 | Blob report = BLOB_INITIALIZER; |
| @@ -998,10 +1035,12 @@ | |
| 998 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 999 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 1000 | unsigned flags = C_EXTRA; |
| 1001 | int showHdr = find_option("header",0,0)!=0; |
| 1002 | int treeFmt = find_option("tree",0,0)!=0; |
| 1003 | Glob *pIgnore; |
| 1004 | |
| 1005 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| 1006 | db_must_be_within_tree(); |
| 1007 | |
| @@ -1011,10 +1050,15 @@ | |
| 1011 | |
| 1012 | if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL; |
| 1013 | |
| 1014 | if( treeFmt ){ |
| 1015 | flags &= ~C_RELPATH; |
| 1016 | } |
| 1017 | |
| 1018 | /* We should be done with options.. */ |
| 1019 | verify_all_options(); |
| 1020 | |
| @@ -1031,11 +1075,11 @@ | |
| 1031 | if( showHdr ){ |
| 1032 | fossil_print("Extras for %s at %s:\n", db_get("project-name","<unnamed>"), |
| 1033 | g.zLocalRoot); |
| 1034 | } |
| 1035 | if( treeFmt ){ |
| 1036 | print_filelist_as_tree(&report); |
| 1037 | }else{ |
| 1038 | blob_write_to_file(&report, "-"); |
| 1039 | } |
| 1040 | } |
| 1041 | blob_reset(&report); |
| 1042 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -646,25 +646,40 @@ | |
| 646 | */ |
| 647 | static const char *print_filelist_section( |
| 648 | const char *zIn, /* List of filenames, separated by \n */ |
| 649 | const char *zLast, /* Last filename in the list to print */ |
| 650 | const char *zPrefix, /* Prefix so put before each output line */ |
| 651 | int nDir, /* Ignore this many characters of directory name */ |
| 652 | int treeFmt /* 1 = use Unicode symbols, 2 = use ASCII chars */ |
| 653 | ){ |
| 654 | const char *treeEntry = "|-- "; |
| 655 | const char *treeLastE = "`-- "; |
| 656 | const char *treeContu = "| "; |
| 657 | const char *treeBlank = " "; |
| 658 | if( treeFmt == 1 ){ |
| 659 | treeEntry = "\342\224\234\342\224\200\342\224\200 "; |
| 660 | treeLastE = "\342\224\224\342\224\200\342\224\200 "; |
| 661 | treeContu = "\342\224\202 "; |
| 662 | } |
| 663 | while( zIn<=zLast ){ |
| 664 | int i; |
| 665 | // const char *treeContu = (treeFmt == 1) ? "\342\224\202 " : "| "; |
| 666 | // const char *treeEntry = (treeFmt == 1) ? "\342\224\234\342\224\200\342\224\200 " : "|-- "; |
| 667 | // const char *treeLastE = (treeFmt == 1) ? "\342\224\224\342\224\200\342\224\200 " : "`-- "; |
| 668 | // const char *treeBlank = " "; |
| 669 | for(i=nDir; zIn[i]!='\n' && zIn[i]!='/'; i++){} |
| 670 | if( zIn[i]=='/' ){ |
| 671 | char *zSubPrefix; |
| 672 | const char *zSubLast = last_line(zIn, i+1); |
| 673 | zSubPrefix = mprintf("%s%s", zPrefix, |
| 674 | zSubLast==zLast ? treeBlank : treeContu); |
| 675 | fossil_print("%s%s%.*s\n", zPrefix, |
| 676 | zSubLast==zLast ? treeLastE : treeEntry, i-nDir, &zIn[nDir]); |
| 677 | zIn = print_filelist_section(zIn, zSubLast, zSubPrefix, i+1, treeFmt); |
| 678 | fossil_free(zSubPrefix); |
| 679 | }else{ |
| 680 | fossil_print("%s%s%.*s\n", zPrefix, zIn==zLast ? treeLastE : treeEntry, |
| 681 | i-nDir, &zIn[nDir]); |
| 682 | zIn = next_line(zIn); |
| 683 | } |
| 684 | } |
| 685 | return zIn; |
| @@ -673,18 +688,18 @@ | |
| 688 | /* |
| 689 | ** Input blob pList is a list of filenames, one filename per line, |
| 690 | ** in sorted order and with / directory separators. Output this list |
| 691 | ** as a tree in a manner similar to the "tree" command on Linux. |
| 692 | */ |
| 693 | static void print_filelist_as_tree(Blob *pList, int treeFmt){ |
| 694 | char *zAll; |
| 695 | const char *zLast; |
| 696 | fossil_print("%s\n", g.zLocalRoot); |
| 697 | zAll = blob_str(pList); |
| 698 | if( zAll[0] ){ |
| 699 | zLast = last_line(zAll, 0); |
| 700 | print_filelist_section(zAll, zLast, "", 0, treeFmt); |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | /* |
| 705 | ** Take care of -r version of ls command |
| @@ -760,11 +775,11 @@ | |
| 775 | fossil_print("%s\n", zFile); |
| 776 | } |
| 777 | } |
| 778 | db_finalize(&q); |
| 779 | if( treeFmt ){ |
| 780 | print_filelist_as_tree(&out, treeFmt); |
| 781 | blob_reset(&out); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | /* |
| @@ -792,26 +807,30 @@ | |
| 807 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 808 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 809 | ** |
| 810 | ** Options: |
| 811 | ** --age Show when each file was committed |
| 812 | ** -a|--ascii-tree Use ASCII characters when drawing the tree |
| 813 | ** --hash With -v, verify file status using hashing |
| 814 | ** rather than relying on file sizes and mtimes |
| 815 | ** -r VERSION The specific check-in to list |
| 816 | ** -R|--repository REPO Extract info from repository REPO |
| 817 | ** -t Sort output in time order |
| 818 | ** --tree Tree format |
| 819 | ** -u|--unicode-tree Use Unicode symbols when drawing the tree |
| 820 | ** -v|--verbose Provide extra information about each file |
| 821 | ** |
| 822 | ** See also: [[changes]], [[extras]], [[status]], [[tree]] |
| 823 | */ |
| 824 | void ls_cmd(void){ |
| 825 | int vid; |
| 826 | Stmt q; |
| 827 | int verboseFlag; |
| 828 | int showAge; |
| 829 | int treeFmt; |
| 830 | int asciiTree; |
| 831 | int unicodeTree; |
| 832 | int timeOrder; |
| 833 | char *zOrderBy = "pathname"; |
| 834 | Blob where; |
| 835 | int i; |
| 836 | int useHash = 0; |
| @@ -827,12 +846,19 @@ | |
| 846 | timeOrder = find_option("t","t",0)!=0; |
| 847 | if( verboseFlag ){ |
| 848 | useHash = find_option("hash",0,0)!=0; |
| 849 | } |
| 850 | treeFmt = find_option("tree",0,0)!=0; |
| 851 | asciiTree = find_option("ascii-tree","a",0)!=0; |
| 852 | unicodeTree = find_option("unicode-tree","u",0)!=0; |
| 853 | if( treeFmt ){ |
| 854 | if( zRev==0 ) zRev = "current"; |
| 855 | #ifdef _WIN32 |
| 856 | treeFmt = 2; |
| 857 | #endif |
| 858 | if( unicodeTree ) treeFmt = 1; |
| 859 | if( asciiTree ) treeFmt = 2; |
| 860 | } |
| 861 | |
| 862 | if( zRev!=0 ){ |
| 863 | db_find_and_open_repository(0, 0); |
| 864 | verify_all_options(); |
| @@ -945,23 +971,32 @@ | |
| 971 | ** List all files in the current check-out in after the fashion of the |
| 972 | ** "tree" command. If PATHS is included, only the named files |
| 973 | ** (or their children if directories) are shown. |
| 974 | ** |
| 975 | ** Options: |
| 976 | ** -a|--ascii-tree Use ASCII characters when drawing the tree |
| 977 | ** -r VERSION The specific check-in to list |
| 978 | ** -R|--repository REPO Extract info from repository REPO |
| 979 | ** -u|--unicode-tree Use Unicode symbols when drawing the tree |
| 980 | ** |
| 981 | ** See also: [[ls]] |
| 982 | */ |
| 983 | void tree_cmd(void){ |
| 984 | const char *zRev; |
| 985 | int treeFmt = 1; |
| 986 | int asciiTree = find_option("ascii-tree","a",0)!=0; |
| 987 | int unicodeTree = find_option("unicode-tree","u",0)!=0; |
| 988 | #ifdef _WIN32 |
| 989 | treeFmt = 2; |
| 990 | #endif |
| 991 | if( unicodeTree ) treeFmt = 1; |
| 992 | if( asciiTree ) treeFmt = 2; |
| 993 | zRev = find_option("r","r",1); |
| 994 | if( zRev==0 ) zRev = "current"; |
| 995 | db_find_and_open_repository(0, 0); |
| 996 | verify_all_options(); |
| 997 | ls_cmd_rev(zRev, 0, 0, 0, treeFmt); |
| 998 | } |
| 999 | |
| 1000 | /* |
| 1001 | ** COMMAND: extras |
| 1002 | ** |
| @@ -981,17 +1016,19 @@ | |
| 1016 | ** Pathnames are displayed according to the "relative-paths" setting, |
| 1017 | ** unless overridden by the --abs-paths or --rel-paths options. |
| 1018 | ** |
| 1019 | ** Options: |
| 1020 | ** --abs-paths Display absolute pathnames |
| 1021 | ** -a|--ascii-tree Use ASCII characters when drawing the tree |
| 1022 | ** --case-sensitive BOOL Override case-sensitive setting |
| 1023 | ** --dotfiles Include files beginning with a dot (".") |
| 1024 | ** --header Identify the repository if there are extras |
| 1025 | ** --ignore CSG Ignore files matching patterns from the argument |
| 1026 | ** --rel-paths Display pathnames relative to the current working |
| 1027 | ** directory |
| 1028 | ** --tree Show output in the tree format |
| 1029 | ** -u|--unicode-tree Use Unicode symbols when drawing the tree |
| 1030 | ** |
| 1031 | ** See also: [[changes]], [[clean]], [[status]] |
| 1032 | */ |
| 1033 | void extras_cmd(void){ |
| 1034 | Blob report = BLOB_INITIALIZER; |
| @@ -998,10 +1035,12 @@ | |
| 1035 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 1036 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 1037 | unsigned flags = C_EXTRA; |
| 1038 | int showHdr = find_option("header",0,0)!=0; |
| 1039 | int treeFmt = find_option("tree",0,0)!=0; |
| 1040 | int asciiTree = find_option("ascii-tree","a",0)!=0; |
| 1041 | int unicodeTree = find_option("unicode-tree","u",0)!=0; |
| 1042 | Glob *pIgnore; |
| 1043 | |
| 1044 | if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP; |
| 1045 | db_must_be_within_tree(); |
| 1046 | |
| @@ -1011,10 +1050,15 @@ | |
| 1050 | |
| 1051 | if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL; |
| 1052 | |
| 1053 | if( treeFmt ){ |
| 1054 | flags &= ~C_RELPATH; |
| 1055 | #ifdef _WIN32 |
| 1056 | treeFmt = 2; |
| 1057 | #endif |
| 1058 | if( unicodeTree ) treeFmt = 1; |
| 1059 | if( asciiTree ) treeFmt = 2; |
| 1060 | } |
| 1061 | |
| 1062 | /* We should be done with options.. */ |
| 1063 | verify_all_options(); |
| 1064 | |
| @@ -1031,11 +1075,11 @@ | |
| 1075 | if( showHdr ){ |
| 1076 | fossil_print("Extras for %s at %s:\n", db_get("project-name","<unnamed>"), |
| 1077 | g.zLocalRoot); |
| 1078 | } |
| 1079 | if( treeFmt ){ |
| 1080 | print_filelist_as_tree(&report, treeFmt); |
| 1081 | }else{ |
| 1082 | blob_write_to_file(&report, "-"); |
| 1083 | } |
| 1084 | } |
| 1085 | blob_reset(&report); |
| 1086 |