Fossil SCM
Add the -h option to the "ls" command to display file hashes for a specific check-in when in verbose mode.
Commit
4c0ff6ed62b1e3696eaf6d43b071314757ffbbba86f9fa71a4c755d1b3aabc5f
Parent
b12e52aaf7b5096…
2 files changed
+5
-3
+11
-5
+5
-3
| --- src/browse.c | ||
| +++ src/browse.c | ||
| @@ -1038,11 +1038,12 @@ | ||
| 1038 | 1038 | @ CREATE TABLE IF NOT EXISTS temp.fileage( |
| 1039 | 1039 | @ fnid INTEGER PRIMARY KEY, |
| 1040 | 1040 | @ fid INTEGER, |
| 1041 | 1041 | @ mid INTEGER, |
| 1042 | 1042 | @ mtime DATETIME, |
| 1043 | -@ pathname TEXT | |
| 1043 | +@ pathname TEXT, | |
| 1044 | +@ uuid TEXT | |
| 1044 | 1045 | @ ); |
| 1045 | 1046 | @ CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin; |
| 1046 | 1047 | ; |
| 1047 | 1048 | |
| 1048 | 1049 | static const char zComputeFileAgeRun[] = |
| @@ -1050,12 +1051,13 @@ | ||
| 1050 | 1051 | @ ckin(x) AS (VALUES(:ckin) |
| 1051 | 1052 | @ UNION |
| 1052 | 1053 | @ SELECT plink.pid |
| 1053 | 1054 | @ FROM ckin, plink |
| 1054 | 1055 | @ WHERE plink.cid=ckin.x) |
| 1055 | -@ INSERT OR IGNORE INTO fileage(fnid, fid, mid, mtime, pathname) | |
| 1056 | -@ SELECT filename.fnid, mlink.fid, mlink.mid, event.mtime, filename.name | |
| 1056 | +@ INSERT OR IGNORE INTO fileage(fnid, fid, mid, mtime, pathname, uuid) | |
| 1057 | +@ SELECT filename.fnid, mlink.fid, mlink.mid, event.mtime, filename.name, | |
| 1058 | +@ foci.uuid | |
| 1057 | 1059 | @ FROM foci, filename, blob, mlink, event |
| 1058 | 1060 | @ WHERE foci.checkinID=:ckin |
| 1059 | 1061 | @ AND foci.filename GLOB :glob |
| 1060 | 1062 | @ AND filename.name=foci.filename |
| 1061 | 1063 | @ AND blob.uuid=foci.uuid |
| 1062 | 1064 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -1038,11 +1038,12 @@ | |
| 1038 | @ CREATE TABLE IF NOT EXISTS temp.fileage( |
| 1039 | @ fnid INTEGER PRIMARY KEY, |
| 1040 | @ fid INTEGER, |
| 1041 | @ mid INTEGER, |
| 1042 | @ mtime DATETIME, |
| 1043 | @ pathname TEXT |
| 1044 | @ ); |
| 1045 | @ CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin; |
| 1046 | ; |
| 1047 | |
| 1048 | static const char zComputeFileAgeRun[] = |
| @@ -1050,12 +1051,13 @@ | |
| 1050 | @ ckin(x) AS (VALUES(:ckin) |
| 1051 | @ UNION |
| 1052 | @ SELECT plink.pid |
| 1053 | @ FROM ckin, plink |
| 1054 | @ WHERE plink.cid=ckin.x) |
| 1055 | @ INSERT OR IGNORE INTO fileage(fnid, fid, mid, mtime, pathname) |
| 1056 | @ SELECT filename.fnid, mlink.fid, mlink.mid, event.mtime, filename.name |
| 1057 | @ FROM foci, filename, blob, mlink, event |
| 1058 | @ WHERE foci.checkinID=:ckin |
| 1059 | @ AND foci.filename GLOB :glob |
| 1060 | @ AND filename.name=foci.filename |
| 1061 | @ AND blob.uuid=foci.uuid |
| 1062 |
| --- src/browse.c | |
| +++ src/browse.c | |
| @@ -1038,11 +1038,12 @@ | |
| 1038 | @ CREATE TABLE IF NOT EXISTS temp.fileage( |
| 1039 | @ fnid INTEGER PRIMARY KEY, |
| 1040 | @ fid INTEGER, |
| 1041 | @ mid INTEGER, |
| 1042 | @ mtime DATETIME, |
| 1043 | @ pathname TEXT, |
| 1044 | @ uuid TEXT |
| 1045 | @ ); |
| 1046 | @ CREATE VIRTUAL TABLE IF NOT EXISTS temp.foci USING files_of_checkin; |
| 1047 | ; |
| 1048 | |
| 1049 | static const char zComputeFileAgeRun[] = |
| @@ -1050,12 +1051,13 @@ | |
| 1051 | @ ckin(x) AS (VALUES(:ckin) |
| 1052 | @ UNION |
| 1053 | @ SELECT plink.pid |
| 1054 | @ FROM ckin, plink |
| 1055 | @ WHERE plink.cid=ckin.x) |
| 1056 | @ INSERT OR IGNORE INTO fileage(fnid, fid, mid, mtime, pathname, uuid) |
| 1057 | @ SELECT filename.fnid, mlink.fid, mlink.mid, event.mtime, filename.name, |
| 1058 | @ foci.uuid |
| 1059 | @ FROM foci, filename, blob, mlink, event |
| 1060 | @ WHERE foci.checkinID=:ckin |
| 1061 | @ AND foci.filename GLOB :glob |
| 1062 | @ AND filename.name=foci.filename |
| 1063 | @ AND blob.uuid=foci.uuid |
| 1064 |
+11
-5
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -718,10 +718,11 @@ | ||
| 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 | 724 | int timeOrder, /* Order by time flag given */ |
| 724 | 725 | int treeFmt /* Show output in the tree format */ |
| 725 | 726 | ){ |
| 726 | 727 | Stmt q; |
| 727 | 728 | char *zOrderBy = "pathname COLLATE nocase"; |
| @@ -763,11 +764,11 @@ | ||
| 763 | 764 | } |
| 764 | 765 | |
| 765 | 766 | compute_fileage(rid,0); |
| 766 | 767 | db_prepare(&q, |
| 767 | 768 | "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n" |
| 768 | - " blob.size\n" | |
| 769 | + " blob.size, fileage.uuid\n" | |
| 769 | 770 | " FROM fileage, blob\n" |
| 770 | 771 | " WHERE blob.rid=fileage.fid %s\n" |
| 771 | 772 | " ORDER BY %s;", blob_sql_text(&where), zOrderBy /*safe-for-%s*/ |
| 772 | 773 | ); |
| 773 | 774 | blob_reset(&where); |
| @@ -778,11 +779,12 @@ | ||
| 778 | 779 | const char *zFile = db_column_text(&q,1); |
| 779 | 780 | int size = db_column_int(&q,2); |
| 780 | 781 | if( treeFmt ){ |
| 781 | 782 | blob_appendf(&out, "%s\n", zFile); |
| 782 | 783 | }else if( verboseFlag ){ |
| 783 | - fossil_print("%s %7d %s\n", zTime, size, zFile); | |
| 784 | + const char *zUuid = mprintf("[%S] ", db_column_text(&q,3)); | |
| 785 | + fossil_print("%s %7d %s%s\n", zTime, size, showHash ? zUuid :"", zFile); | |
| 784 | 786 | }else if( showAge ){ |
| 785 | 787 | fossil_print("%s %s\n", zTime, zFile); |
| 786 | 788 | }else{ |
| 787 | 789 | fossil_print("%s\n", zFile); |
| 788 | 790 | } |
| @@ -811,18 +813,20 @@ | ||
| 811 | 813 | ** The --age option displays file commit times. Like -r, --age has the |
| 812 | 814 | ** side effect of making -t sort by commit time, not modification time. |
| 813 | 815 | ** |
| 814 | 816 | ** The -v option provides extra information about each file. Without -r, |
| 815 | 817 | ** -v displays the change status, in the manner of the changes command. |
| 816 | -** With -r, -v shows the commit time and size of the checked-in files. | |
| 818 | +** With -r, -v shows the commit time and size of the checked-in files; in | |
| 819 | +** this combination, it additionally shows file hashes with -h. | |
| 817 | 820 | ** |
| 818 | 821 | ** The -t option changes the sort order. Without -t, files are sorted by |
| 819 | 822 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 820 | 823 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 821 | 824 | ** |
| 822 | 825 | ** Options: |
| 823 | 826 | ** --age Show when each file was committed |
| 827 | +** -h With -v and -r, show file hashes | |
| 824 | 828 | ** --hash With -v, verify file status using hashing |
| 825 | 829 | ** rather than relying on file sizes and mtimes |
| 826 | 830 | ** -r VERSION The specific check-in to list |
| 827 | 831 | ** -R|--repository REPO Extract info from repository REPO |
| 828 | 832 | ** -t Sort output in time order |
| @@ -840,10 +844,11 @@ | ||
| 840 | 844 | int timeOrder; |
| 841 | 845 | char *zOrderBy = "pathname"; |
| 842 | 846 | Blob where; |
| 843 | 847 | int i; |
| 844 | 848 | int useHash = 0; |
| 849 | + int showHash = 0; | |
| 845 | 850 | const char *zName; |
| 846 | 851 | const char *zRev; |
| 847 | 852 | |
| 848 | 853 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 849 | 854 | if( !verboseFlag ){ |
| @@ -852,20 +857,21 @@ | ||
| 852 | 857 | showAge = find_option("age",0,0)!=0; |
| 853 | 858 | zRev = find_option("r","r",1); |
| 854 | 859 | timeOrder = find_option("t","t",0)!=0; |
| 855 | 860 | if( verboseFlag ){ |
| 856 | 861 | useHash = find_option("hash",0,0)!=0; |
| 862 | + showHash = find_option("h","h",0)!=0; | |
| 857 | 863 | } |
| 858 | 864 | treeFmt = find_option("tree",0,0)!=0; |
| 859 | 865 | if( treeFmt ){ |
| 860 | 866 | if( zRev==0 ) zRev = "current"; |
| 861 | 867 | } |
| 862 | 868 | |
| 863 | 869 | if( zRev!=0 ){ |
| 864 | 870 | db_find_and_open_repository(0, 0); |
| 865 | 871 | verify_all_options(); |
| 866 | - ls_cmd_rev(zRev,verboseFlag,showAge,timeOrder,treeFmt); | |
| 872 | + ls_cmd_rev(zRev,verboseFlag,showAge,showHash,timeOrder,treeFmt); | |
| 867 | 873 | return; |
| 868 | 874 | }else if( find_option("R",0,1)!=0 ){ |
| 869 | 875 | fossil_fatal("the -r is required in addition to -R"); |
| 870 | 876 | } |
| 871 | 877 | |
| @@ -984,11 +990,11 @@ | ||
| 984 | 990 | |
| 985 | 991 | zRev = find_option("r","r",1); |
| 986 | 992 | if( zRev==0 ) zRev = "current"; |
| 987 | 993 | db_find_and_open_repository(0, 0); |
| 988 | 994 | verify_all_options(); |
| 989 | - ls_cmd_rev(zRev,0,0,0,1); | |
| 995 | + ls_cmd_rev(zRev,0,0,0,0,1); | |
| 990 | 996 | } |
| 991 | 997 | |
| 992 | 998 | /* |
| 993 | 999 | ** COMMAND: extras |
| 994 | 1000 | ** |
| 995 | 1001 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -718,10 +718,11 @@ | |
| 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 timeOrder, /* Order by time flag given */ |
| 724 | int treeFmt /* Show output in the tree format */ |
| 725 | ){ |
| 726 | Stmt q; |
| 727 | char *zOrderBy = "pathname COLLATE nocase"; |
| @@ -763,11 +764,11 @@ | |
| 763 | } |
| 764 | |
| 765 | compute_fileage(rid,0); |
| 766 | db_prepare(&q, |
| 767 | "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n" |
| 768 | " blob.size\n" |
| 769 | " FROM fileage, blob\n" |
| 770 | " WHERE blob.rid=fileage.fid %s\n" |
| 771 | " ORDER BY %s;", blob_sql_text(&where), zOrderBy /*safe-for-%s*/ |
| 772 | ); |
| 773 | blob_reset(&where); |
| @@ -778,11 +779,12 @@ | |
| 778 | const char *zFile = db_column_text(&q,1); |
| 779 | int size = db_column_int(&q,2); |
| 780 | if( treeFmt ){ |
| 781 | blob_appendf(&out, "%s\n", zFile); |
| 782 | }else if( verboseFlag ){ |
| 783 | fossil_print("%s %7d %s\n", zTime, size, zFile); |
| 784 | }else if( showAge ){ |
| 785 | fossil_print("%s %s\n", zTime, zFile); |
| 786 | }else{ |
| 787 | fossil_print("%s\n", zFile); |
| 788 | } |
| @@ -811,18 +813,20 @@ | |
| 811 | ** The --age option displays file commit times. Like -r, --age has the |
| 812 | ** side effect of making -t sort by commit time, not modification time. |
| 813 | ** |
| 814 | ** The -v option provides extra information about each file. Without -r, |
| 815 | ** -v displays the change status, in the manner of the changes command. |
| 816 | ** With -r, -v shows the commit time and size of the checked-in files. |
| 817 | ** |
| 818 | ** The -t option changes the sort order. Without -t, files are sorted by |
| 819 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 820 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 821 | ** |
| 822 | ** Options: |
| 823 | ** --age Show when each file was committed |
| 824 | ** --hash With -v, verify file status using hashing |
| 825 | ** rather than relying on file sizes and mtimes |
| 826 | ** -r VERSION The specific check-in to list |
| 827 | ** -R|--repository REPO Extract info from repository REPO |
| 828 | ** -t Sort output in time order |
| @@ -840,10 +844,11 @@ | |
| 840 | int timeOrder; |
| 841 | char *zOrderBy = "pathname"; |
| 842 | Blob where; |
| 843 | int i; |
| 844 | int useHash = 0; |
| 845 | const char *zName; |
| 846 | const char *zRev; |
| 847 | |
| 848 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 849 | if( !verboseFlag ){ |
| @@ -852,20 +857,21 @@ | |
| 852 | showAge = find_option("age",0,0)!=0; |
| 853 | zRev = find_option("r","r",1); |
| 854 | timeOrder = find_option("t","t",0)!=0; |
| 855 | if( verboseFlag ){ |
| 856 | useHash = find_option("hash",0,0)!=0; |
| 857 | } |
| 858 | treeFmt = find_option("tree",0,0)!=0; |
| 859 | if( treeFmt ){ |
| 860 | if( zRev==0 ) zRev = "current"; |
| 861 | } |
| 862 | |
| 863 | if( zRev!=0 ){ |
| 864 | db_find_and_open_repository(0, 0); |
| 865 | verify_all_options(); |
| 866 | ls_cmd_rev(zRev,verboseFlag,showAge,timeOrder,treeFmt); |
| 867 | return; |
| 868 | }else if( find_option("R",0,1)!=0 ){ |
| 869 | fossil_fatal("the -r is required in addition to -R"); |
| 870 | } |
| 871 | |
| @@ -984,11 +990,11 @@ | |
| 984 | |
| 985 | zRev = find_option("r","r",1); |
| 986 | if( zRev==0 ) zRev = "current"; |
| 987 | db_find_and_open_repository(0, 0); |
| 988 | verify_all_options(); |
| 989 | ls_cmd_rev(zRev,0,0,0,1); |
| 990 | } |
| 991 | |
| 992 | /* |
| 993 | ** COMMAND: extras |
| 994 | ** |
| 995 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -718,10 +718,11 @@ | |
| 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"; |
| @@ -763,11 +764,11 @@ | |
| 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); |
| @@ -778,11 +779,12 @@ | |
| 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 | const char *zUuid = mprintf("[%S] ", db_column_text(&q,3)); |
| 785 | fossil_print("%s %7d %s%s\n", zTime, size, showHash ? zUuid :"", zFile); |
| 786 | }else if( showAge ){ |
| 787 | fossil_print("%s %s\n", zTime, zFile); |
| 788 | }else{ |
| 789 | fossil_print("%s\n", zFile); |
| 790 | } |
| @@ -811,18 +813,20 @@ | |
| 813 | ** The --age option displays file commit times. Like -r, --age has the |
| 814 | ** side effect of making -t sort by commit time, not modification time. |
| 815 | ** |
| 816 | ** The -v option provides extra information about each file. Without -r, |
| 817 | ** -v displays the change status, in the manner of the changes command. |
| 818 | ** With -r, -v shows the commit time and size of the checked-in files; in |
| 819 | ** this combination, it additionally shows file hashes with -h. |
| 820 | ** |
| 821 | ** The -t option changes the sort order. Without -t, files are sorted by |
| 822 | ** path and name (case insensitive sort if -r). If neither --age nor -r |
| 823 | ** are used, -t sorts by modification time, otherwise by commit time. |
| 824 | ** |
| 825 | ** Options: |
| 826 | ** --age Show when each file was committed |
| 827 | ** -h With -v and -r, show file hashes |
| 828 | ** --hash With -v, verify file status using hashing |
| 829 | ** rather than relying on file sizes and mtimes |
| 830 | ** -r VERSION The specific check-in to list |
| 831 | ** -R|--repository REPO Extract info from repository REPO |
| 832 | ** -t Sort output in time order |
| @@ -840,10 +844,11 @@ | |
| 844 | int timeOrder; |
| 845 | char *zOrderBy = "pathname"; |
| 846 | Blob where; |
| 847 | int i; |
| 848 | int useHash = 0; |
| 849 | int showHash = 0; |
| 850 | const char *zName; |
| 851 | const char *zRev; |
| 852 | |
| 853 | verboseFlag = find_option("verbose","v", 0)!=0; |
| 854 | if( !verboseFlag ){ |
| @@ -852,20 +857,21 @@ | |
| 857 | showAge = find_option("age",0,0)!=0; |
| 858 | zRev = find_option("r","r",1); |
| 859 | timeOrder = find_option("t","t",0)!=0; |
| 860 | if( verboseFlag ){ |
| 861 | useHash = find_option("hash",0,0)!=0; |
| 862 | showHash = find_option("h","h",0)!=0; |
| 863 | } |
| 864 | treeFmt = find_option("tree",0,0)!=0; |
| 865 | if( treeFmt ){ |
| 866 | if( zRev==0 ) zRev = "current"; |
| 867 | } |
| 868 | |
| 869 | if( zRev!=0 ){ |
| 870 | db_find_and_open_repository(0, 0); |
| 871 | verify_all_options(); |
| 872 | ls_cmd_rev(zRev,verboseFlag,showAge,showHash,timeOrder,treeFmt); |
| 873 | return; |
| 874 | }else if( find_option("R",0,1)!=0 ){ |
| 875 | fossil_fatal("the -r is required in addition to -R"); |
| 876 | } |
| 877 | |
| @@ -984,11 +990,11 @@ | |
| 990 | |
| 991 | zRev = find_option("r","r",1); |
| 992 | if( zRev==0 ) zRev = "current"; |
| 993 | db_find_and_open_repository(0, 0); |
| 994 | verify_all_options(); |
| 995 | ls_cmd_rev(zRev,0,0,0,0,1); |
| 996 | } |
| 997 | |
| 998 | /* |
| 999 | ** COMMAND: extras |
| 1000 | ** |
| 1001 |