Fossil SCM
Add the -H option to the 'ls' command for displaying check-in hashes (similar to the current -h option for file hashes).
Commit
1f8d7b7a5e5308adf033cb248706a698372c229cffdab1ddf2da4cc3df7ad586
Parent
5ef8ac82c302073…
1 file changed
+30
-14
+30
-14
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -718,11 +718,12 @@ | ||
| 718 | 718 | */ |
| 719 | 719 | static void ls_cmd_rev( |
| 720 | 720 | const char *zRev, /* Revision string given */ |
| 721 | 721 | int verboseFlag, /* Verbose flag given */ |
| 722 | 722 | int showAge, /* Age flag given */ |
| 723 | - int showHash, /* Show hash flag given */ | |
| 723 | + int showFileHash, /* Show file hash flag given */ | |
| 724 | + int showCkinHash, /* Show check-in hash flag given */ | |
| 724 | 725 | int timeOrder, /* Order by time flag given */ |
| 725 | 726 | int treeFmt /* Show output in the tree format */ |
| 726 | 727 | ){ |
| 727 | 728 | Stmt q; |
| 728 | 729 | char *zOrderBy = "pathname COLLATE nocase"; |
| @@ -762,16 +763,21 @@ | ||
| 762 | 763 | if( timeOrder ){ |
| 763 | 764 | zOrderBy = "mtime DESC"; |
| 764 | 765 | } |
| 765 | 766 | |
| 766 | 767 | compute_fileage(rid,0); |
| 767 | - db_prepare(&q, | |
| 768 | + db_prepare(&q, | |
| 768 | 769 | "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n" |
| 769 | - " blob.size, fileage.uuid\n" | |
| 770 | - " FROM fileage, blob\n" | |
| 771 | - " WHERE blob.rid=fileage.fid %s\n" | |
| 772 | - " ORDER BY %s;", blob_sql_text(&where), zOrderBy /*safe-for-%s*/ | |
| 770 | + " bfh.size, fileage.uuid %s\n" | |
| 771 | + " FROM fileage, blob bfh %s\n" | |
| 772 | + " WHERE bfh.rid=fileage.fid %s %s\n" | |
| 773 | + " ORDER BY %s;", | |
| 774 | + showCkinHash ? ", bch.uuid" : "", | |
| 775 | + showCkinHash ? ", blob bch" : "", | |
| 776 | + showCkinHash ? "\n AND bch.rid=fileage.mid" : "", | |
| 777 | + blob_sql_text(&where), | |
| 778 | + zOrderBy /*safe-for-%s*/ | |
| 773 | 779 | ); |
| 774 | 780 | blob_reset(&where); |
| 775 | 781 | if( treeFmt ) blob_init(&out, 0, 0); |
| 776 | 782 | |
| 777 | 783 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -779,13 +785,16 @@ | ||
| 779 | 785 | const char *zFile = db_column_text(&q,1); |
| 780 | 786 | int size = db_column_int(&q,2); |
| 781 | 787 | if( treeFmt ){ |
| 782 | 788 | blob_appendf(&out, "%s\n", zFile); |
| 783 | 789 | }else if( verboseFlag ){ |
| 784 | - if( showHash ){ | |
| 785 | - const char *zUuid = db_column_text(&q,3); | |
| 786 | - fossil_print("%s %7d [%S] %s\n", zTime, size, zUuid, zFile); | |
| 790 | + if( showFileHash ){ | |
| 791 | + const char *zUuidF = db_column_text(&q,3); | |
| 792 | + fossil_print("%s %7d [%S] %s\n", zTime, size, zUuidF, zFile); | |
| 793 | + }else if( showCkinHash ){ | |
| 794 | + const char *zUuidC = db_column_text(&q,4); | |
| 795 | + fossil_print("%s %7d [%S] %s\n", zTime, size, zUuidC, zFile); | |
| 787 | 796 | }else{ |
| 788 | 797 | fossil_print("%s %7d %s\n", zTime, size, zFile); |
| 789 | 798 | } |
| 790 | 799 | }else if( showAge ){ |
| 791 | 800 | fossil_print("%s %s\n", zTime, zFile); |
| @@ -818,19 +827,21 @@ | ||
| 818 | 827 | ** side effect of making -t sort by commit time, not modification time. |
| 819 | 828 | ** |
| 820 | 829 | ** The -v option provides extra information about each file. Without -r, |
| 821 | 830 | ** -v displays the change status, in the manner of the changes command. |
| 822 | 831 | ** With -r, -v shows the commit time and size of the checked-in files; in |
| 823 | -** this combination, it additionally shows file hashes with -h. | |
| 832 | +** this combination, it additionally shows file hashes with -h, or check-in | |
| 833 | +** hashes with -H (when both are given, file hashes take precedence). | |
| 824 | 834 | ** |
| 825 | 835 | ** The -t option changes the sort order. Without -t, files are sorted by |
| 826 | 836 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 827 | 837 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 828 | 838 | ** |
| 829 | 839 | ** Options: |
| 830 | 840 | ** --age Show when each file was committed |
| 831 | 841 | ** -h With -v and -r, show file hashes |
| 842 | +** -H With -v and -r, show check-in hashes | |
| 832 | 843 | ** --hash With -v, verify file status using hashing |
| 833 | 844 | ** rather than relying on file sizes and mtimes |
| 834 | 845 | ** -r VERSION The specific check-in to list |
| 835 | 846 | ** -R|--repository REPO Extract info from repository REPO |
| 836 | 847 | ** -t Sort output in time order |
| @@ -848,11 +859,12 @@ | ||
| 848 | 859 | int timeOrder; |
| 849 | 860 | char *zOrderBy = "pathname"; |
| 850 | 861 | Blob where; |
| 851 | 862 | int i; |
| 852 | 863 | int useHash = 0; |
| 853 | - int showHash = 0; | |
| 864 | + int showFHash = 0; /* Show file hash */ | |
| 865 | + int showCHash = 0; /* Show check-in hash */ | |
| 854 | 866 | const char *zName; |
| 855 | 867 | const char *zRev; |
| 856 | 868 | |
| 857 | 869 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 858 | 870 | if( !verboseFlag ){ |
| @@ -861,21 +873,25 @@ | ||
| 861 | 873 | showAge = find_option("age",0,0)!=0; |
| 862 | 874 | zRev = find_option("r","r",1); |
| 863 | 875 | timeOrder = find_option("t","t",0)!=0; |
| 864 | 876 | if( verboseFlag ){ |
| 865 | 877 | useHash = find_option("hash",0,0)!=0; |
| 866 | - showHash = find_option("h","h",0)!=0; | |
| 878 | + showFHash = find_option("h","h",0)!=0; | |
| 879 | + showCHash = find_option("H","H",0)!=0; | |
| 880 | + if( showFHash ){ | |
| 881 | + showCHash = 0; /* file hashes take precedence */ | |
| 882 | + } | |
| 867 | 883 | } |
| 868 | 884 | treeFmt = find_option("tree",0,0)!=0; |
| 869 | 885 | if( treeFmt ){ |
| 870 | 886 | if( zRev==0 ) zRev = "current"; |
| 871 | 887 | } |
| 872 | 888 | |
| 873 | 889 | if( zRev!=0 ){ |
| 874 | 890 | db_find_and_open_repository(0, 0); |
| 875 | 891 | verify_all_options(); |
| 876 | - ls_cmd_rev(zRev,verboseFlag,showAge,showHash,timeOrder,treeFmt); | |
| 892 | + ls_cmd_rev(zRev,verboseFlag,showAge,showFHash,showCHash,timeOrder,treeFmt); | |
| 877 | 893 | return; |
| 878 | 894 | }else if( find_option("R",0,1)!=0 ){ |
| 879 | 895 | fossil_fatal("the -r is required in addition to -R"); |
| 880 | 896 | } |
| 881 | 897 | |
| @@ -994,11 +1010,11 @@ | ||
| 994 | 1010 | |
| 995 | 1011 | zRev = find_option("r","r",1); |
| 996 | 1012 | if( zRev==0 ) zRev = "current"; |
| 997 | 1013 | db_find_and_open_repository(0, 0); |
| 998 | 1014 | verify_all_options(); |
| 999 | - ls_cmd_rev(zRev,0,0,0,0,1); | |
| 1015 | + ls_cmd_rev(zRev,0,0,0,0,0,1); | |
| 1000 | 1016 | } |
| 1001 | 1017 | |
| 1002 | 1018 | /* |
| 1003 | 1019 | ** COMMAND: extras |
| 1004 | 1020 | ** |
| 1005 | 1021 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -718,11 +718,12 @@ | |
| 718 | */ |
| 719 | static void ls_cmd_rev( |
| 720 | const char *zRev, /* Revision string given */ |
| 721 | int verboseFlag, /* Verbose flag given */ |
| 722 | int showAge, /* Age flag given */ |
| 723 | int showHash, /* Show hash flag given */ |
| 724 | int timeOrder, /* Order by time flag given */ |
| 725 | int treeFmt /* Show output in the tree format */ |
| 726 | ){ |
| 727 | Stmt q; |
| 728 | char *zOrderBy = "pathname COLLATE nocase"; |
| @@ -762,16 +763,21 @@ | |
| 762 | if( timeOrder ){ |
| 763 | zOrderBy = "mtime DESC"; |
| 764 | } |
| 765 | |
| 766 | compute_fileage(rid,0); |
| 767 | db_prepare(&q, |
| 768 | "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n" |
| 769 | " blob.size, fileage.uuid\n" |
| 770 | " FROM fileage, blob\n" |
| 771 | " WHERE blob.rid=fileage.fid %s\n" |
| 772 | " ORDER BY %s;", blob_sql_text(&where), zOrderBy /*safe-for-%s*/ |
| 773 | ); |
| 774 | blob_reset(&where); |
| 775 | if( treeFmt ) blob_init(&out, 0, 0); |
| 776 | |
| 777 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -779,13 +785,16 @@ | |
| 779 | const char *zFile = db_column_text(&q,1); |
| 780 | int size = db_column_int(&q,2); |
| 781 | if( treeFmt ){ |
| 782 | blob_appendf(&out, "%s\n", zFile); |
| 783 | }else if( verboseFlag ){ |
| 784 | if( showHash ){ |
| 785 | const char *zUuid = db_column_text(&q,3); |
| 786 | fossil_print("%s %7d [%S] %s\n", zTime, size, zUuid, zFile); |
| 787 | }else{ |
| 788 | fossil_print("%s %7d %s\n", zTime, size, zFile); |
| 789 | } |
| 790 | }else if( showAge ){ |
| 791 | fossil_print("%s %s\n", zTime, zFile); |
| @@ -818,19 +827,21 @@ | |
| 818 | ** side effect of making -t sort by commit time, not modification time. |
| 819 | ** |
| 820 | ** The -v option provides extra information about each file. Without -r, |
| 821 | ** -v displays the change status, in the manner of the changes command. |
| 822 | ** With -r, -v shows the commit time and size of the checked-in files; in |
| 823 | ** this combination, it additionally shows file hashes with -h. |
| 824 | ** |
| 825 | ** The -t option changes the sort order. Without -t, files are sorted by |
| 826 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 827 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 828 | ** |
| 829 | ** Options: |
| 830 | ** --age Show when each file was committed |
| 831 | ** -h With -v and -r, show file hashes |
| 832 | ** --hash With -v, verify file status using hashing |
| 833 | ** rather than relying on file sizes and mtimes |
| 834 | ** -r VERSION The specific check-in to list |
| 835 | ** -R|--repository REPO Extract info from repository REPO |
| 836 | ** -t Sort output in time order |
| @@ -848,11 +859,12 @@ | |
| 848 | int timeOrder; |
| 849 | char *zOrderBy = "pathname"; |
| 850 | Blob where; |
| 851 | int i; |
| 852 | int useHash = 0; |
| 853 | int showHash = 0; |
| 854 | const char *zName; |
| 855 | const char *zRev; |
| 856 | |
| 857 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 858 | if( !verboseFlag ){ |
| @@ -861,21 +873,25 @@ | |
| 861 | showAge = find_option("age",0,0)!=0; |
| 862 | zRev = find_option("r","r",1); |
| 863 | timeOrder = find_option("t","t",0)!=0; |
| 864 | if( verboseFlag ){ |
| 865 | useHash = find_option("hash",0,0)!=0; |
| 866 | showHash = find_option("h","h",0)!=0; |
| 867 | } |
| 868 | treeFmt = find_option("tree",0,0)!=0; |
| 869 | if( treeFmt ){ |
| 870 | if( zRev==0 ) zRev = "current"; |
| 871 | } |
| 872 | |
| 873 | if( zRev!=0 ){ |
| 874 | db_find_and_open_repository(0, 0); |
| 875 | verify_all_options(); |
| 876 | ls_cmd_rev(zRev,verboseFlag,showAge,showHash,timeOrder,treeFmt); |
| 877 | return; |
| 878 | }else if( find_option("R",0,1)!=0 ){ |
| 879 | fossil_fatal("the -r is required in addition to -R"); |
| 880 | } |
| 881 | |
| @@ -994,11 +1010,11 @@ | |
| 994 | |
| 995 | zRev = find_option("r","r",1); |
| 996 | if( zRev==0 ) zRev = "current"; |
| 997 | db_find_and_open_repository(0, 0); |
| 998 | verify_all_options(); |
| 999 | ls_cmd_rev(zRev,0,0,0,0,1); |
| 1000 | } |
| 1001 | |
| 1002 | /* |
| 1003 | ** COMMAND: extras |
| 1004 | ** |
| 1005 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -718,11 +718,12 @@ | |
| 718 | */ |
| 719 | static void ls_cmd_rev( |
| 720 | const char *zRev, /* Revision string given */ |
| 721 | int verboseFlag, /* Verbose flag given */ |
| 722 | int showAge, /* Age flag given */ |
| 723 | int showFileHash, /* Show file hash flag given */ |
| 724 | int showCkinHash, /* Show check-in hash flag given */ |
| 725 | int timeOrder, /* Order by time flag given */ |
| 726 | int treeFmt /* Show output in the tree format */ |
| 727 | ){ |
| 728 | Stmt q; |
| 729 | char *zOrderBy = "pathname COLLATE nocase"; |
| @@ -762,16 +763,21 @@ | |
| 763 | if( timeOrder ){ |
| 764 | zOrderBy = "mtime DESC"; |
| 765 | } |
| 766 | |
| 767 | compute_fileage(rid,0); |
| 768 | db_prepare(&q, |
| 769 | "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n" |
| 770 | " bfh.size, fileage.uuid %s\n" |
| 771 | " FROM fileage, blob bfh %s\n" |
| 772 | " WHERE bfh.rid=fileage.fid %s %s\n" |
| 773 | " ORDER BY %s;", |
| 774 | showCkinHash ? ", bch.uuid" : "", |
| 775 | showCkinHash ? ", blob bch" : "", |
| 776 | showCkinHash ? "\n AND bch.rid=fileage.mid" : "", |
| 777 | blob_sql_text(&where), |
| 778 | zOrderBy /*safe-for-%s*/ |
| 779 | ); |
| 780 | blob_reset(&where); |
| 781 | if( treeFmt ) blob_init(&out, 0, 0); |
| 782 | |
| 783 | while( db_step(&q)==SQLITE_ROW ){ |
| @@ -779,13 +785,16 @@ | |
| 785 | const char *zFile = db_column_text(&q,1); |
| 786 | int size = db_column_int(&q,2); |
| 787 | if( treeFmt ){ |
| 788 | blob_appendf(&out, "%s\n", zFile); |
| 789 | }else if( verboseFlag ){ |
| 790 | if( showFileHash ){ |
| 791 | const char *zUuidF = db_column_text(&q,3); |
| 792 | fossil_print("%s %7d [%S] %s\n", zTime, size, zUuidF, zFile); |
| 793 | }else if( showCkinHash ){ |
| 794 | const char *zUuidC = db_column_text(&q,4); |
| 795 | fossil_print("%s %7d [%S] %s\n", zTime, size, zUuidC, zFile); |
| 796 | }else{ |
| 797 | fossil_print("%s %7d %s\n", zTime, size, zFile); |
| 798 | } |
| 799 | }else if( showAge ){ |
| 800 | fossil_print("%s %s\n", zTime, zFile); |
| @@ -818,19 +827,21 @@ | |
| 827 | ** side effect of making -t sort by commit time, not modification time. |
| 828 | ** |
| 829 | ** The -v option provides extra information about each file. Without -r, |
| 830 | ** -v displays the change status, in the manner of the changes command. |
| 831 | ** With -r, -v shows the commit time and size of the checked-in files; in |
| 832 | ** this combination, it additionally shows file hashes with -h, or check-in |
| 833 | ** hashes with -H (when both are given, file hashes take precedence). |
| 834 | ** |
| 835 | ** The -t option changes the sort order. Without -t, files are sorted by |
| 836 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 837 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 838 | ** |
| 839 | ** Options: |
| 840 | ** --age Show when each file was committed |
| 841 | ** -h With -v and -r, show file hashes |
| 842 | ** -H With -v and -r, show check-in hashes |
| 843 | ** --hash With -v, verify file status using hashing |
| 844 | ** rather than relying on file sizes and mtimes |
| 845 | ** -r VERSION The specific check-in to list |
| 846 | ** -R|--repository REPO Extract info from repository REPO |
| 847 | ** -t Sort output in time order |
| @@ -848,11 +859,12 @@ | |
| 859 | int timeOrder; |
| 860 | char *zOrderBy = "pathname"; |
| 861 | Blob where; |
| 862 | int i; |
| 863 | int useHash = 0; |
| 864 | int showFHash = 0; /* Show file hash */ |
| 865 | int showCHash = 0; /* Show check-in hash */ |
| 866 | const char *zName; |
| 867 | const char *zRev; |
| 868 | |
| 869 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 870 | if( !verboseFlag ){ |
| @@ -861,21 +873,25 @@ | |
| 873 | showAge = find_option("age",0,0)!=0; |
| 874 | zRev = find_option("r","r",1); |
| 875 | timeOrder = find_option("t","t",0)!=0; |
| 876 | if( verboseFlag ){ |
| 877 | useHash = find_option("hash",0,0)!=0; |
| 878 | showFHash = find_option("h","h",0)!=0; |
| 879 | showCHash = find_option("H","H",0)!=0; |
| 880 | if( showFHash ){ |
| 881 | showCHash = 0; /* file hashes take precedence */ |
| 882 | } |
| 883 | } |
| 884 | treeFmt = find_option("tree",0,0)!=0; |
| 885 | if( treeFmt ){ |
| 886 | if( zRev==0 ) zRev = "current"; |
| 887 | } |
| 888 | |
| 889 | if( zRev!=0 ){ |
| 890 | db_find_and_open_repository(0, 0); |
| 891 | verify_all_options(); |
| 892 | ls_cmd_rev(zRev,verboseFlag,showAge,showFHash,showCHash,timeOrder,treeFmt); |
| 893 | return; |
| 894 | }else if( find_option("R",0,1)!=0 ){ |
| 895 | fossil_fatal("the -r is required in addition to -R"); |
| 896 | } |
| 897 | |
| @@ -994,11 +1010,11 @@ | |
| 1010 | |
| 1011 | zRev = find_option("r","r",1); |
| 1012 | if( zRev==0 ) zRev = "current"; |
| 1013 | db_find_and_open_repository(0, 0); |
| 1014 | verify_all_options(); |
| 1015 | ls_cmd_rev(zRev,0,0,0,0,0,1); |
| 1016 | } |
| 1017 | |
| 1018 | /* |
| 1019 | ** COMMAND: extras |
| 1020 | ** |
| 1021 |