Fossil SCM

Add the -H option to the 'ls' command for displaying check-in hashes (similar to the current -h option for file hashes).

danield 2025-12-19 17:14 trunk
Commit 1f8d7b7a5e5308adf033cb248706a698372c229cffdab1ddf2da4cc3df7ad586
1 file changed +30 -14
+30 -14
--- src/checkin.c
+++ src/checkin.c
@@ -718,11 +718,12 @@
718718
*/
719719
static void ls_cmd_rev(
720720
const char *zRev, /* Revision string given */
721721
int verboseFlag, /* Verbose flag given */
722722
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 */
724725
int timeOrder, /* Order by time flag given */
725726
int treeFmt /* Show output in the tree format */
726727
){
727728
Stmt q;
728729
char *zOrderBy = "pathname COLLATE nocase";
@@ -762,16 +763,21 @@
762763
if( timeOrder ){
763764
zOrderBy = "mtime DESC";
764765
}
765766
766767
compute_fileage(rid,0);
767
- db_prepare(&q,
768
+ db_prepare(&q,
768769
"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*/
773779
);
774780
blob_reset(&where);
775781
if( treeFmt ) blob_init(&out, 0, 0);
776782
777783
while( db_step(&q)==SQLITE_ROW ){
@@ -779,13 +785,16 @@
779785
const char *zFile = db_column_text(&q,1);
780786
int size = db_column_int(&q,2);
781787
if( treeFmt ){
782788
blob_appendf(&out, "%s\n", zFile);
783789
}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);
787796
}else{
788797
fossil_print("%s %7d %s\n", zTime, size, zFile);
789798
}
790799
}else if( showAge ){
791800
fossil_print("%s %s\n", zTime, zFile);
@@ -818,19 +827,21 @@
818827
** side effect of making -t sort by commit time, not modification time.
819828
**
820829
** The -v option provides extra information about each file. Without -r,
821830
** -v displays the change status, in the manner of the changes command.
822831
** 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).
824834
**
825835
** The -t option changes the sort order. Without -t, files are sorted by
826836
** path and name (case insensitive sort if -r). If neither --age nor -r
827837
** are used, -t sorts by modification time, otherwise by commit time.
828838
**
829839
** Options:
830840
** --age Show when each file was committed
831841
** -h With -v and -r, show file hashes
842
+** -H With -v and -r, show check-in hashes
832843
** --hash With -v, verify file status using hashing
833844
** rather than relying on file sizes and mtimes
834845
** -r VERSION The specific check-in to list
835846
** -R|--repository REPO Extract info from repository REPO
836847
** -t Sort output in time order
@@ -848,11 +859,12 @@
848859
int timeOrder;
849860
char *zOrderBy = "pathname";
850861
Blob where;
851862
int i;
852863
int useHash = 0;
853
- int showHash = 0;
864
+ int showFHash = 0; /* Show file hash */
865
+ int showCHash = 0; /* Show check-in hash */
854866
const char *zName;
855867
const char *zRev;
856868
857869
verboseFlag = find_option("verbose","v", 0)!=0;
858870
if( !verboseFlag ){
@@ -861,21 +873,25 @@
861873
showAge = find_option("age",0,0)!=0;
862874
zRev = find_option("r","r",1);
863875
timeOrder = find_option("t","t",0)!=0;
864876
if( verboseFlag ){
865877
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
+ }
867883
}
868884
treeFmt = find_option("tree",0,0)!=0;
869885
if( treeFmt ){
870886
if( zRev==0 ) zRev = "current";
871887
}
872888
873889
if( zRev!=0 ){
874890
db_find_and_open_repository(0, 0);
875891
verify_all_options();
876
- ls_cmd_rev(zRev,verboseFlag,showAge,showHash,timeOrder,treeFmt);
892
+ ls_cmd_rev(zRev,verboseFlag,showAge,showFHash,showCHash,timeOrder,treeFmt);
877893
return;
878894
}else if( find_option("R",0,1)!=0 ){
879895
fossil_fatal("the -r is required in addition to -R");
880896
}
881897
@@ -994,11 +1010,11 @@
9941010
9951011
zRev = find_option("r","r",1);
9961012
if( zRev==0 ) zRev = "current";
9971013
db_find_and_open_repository(0, 0);
9981014
verify_all_options();
999
- ls_cmd_rev(zRev,0,0,0,0,1);
1015
+ ls_cmd_rev(zRev,0,0,0,0,0,1);
10001016
}
10011017
10021018
/*
10031019
** COMMAND: extras
10041020
**
10051021
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button