Fossil SCM

Begin making infrastructure changes to support doing a diff between two independently edited check-outs.

drh 2024-12-13 21:37 trunk
Commit b10cb2b536a92f49ea4da9bbcc74423c6cb0c0808f33ab062731c92234344cd3
1 file changed +30 -13
+30 -13
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -960,10 +960,33 @@
960960
fossil_free(zFullName);
961961
blob_reset(&content);
962962
}
963963
db_finalize(&q);
964964
}
965
+
966
+/*
967
+** Fetch the content for pFile into pContent. pContent is assumed to be
968
+** uninitialized.
969
+**
970
+** This routine accepts non-standard ManifestFile records where the
971
+** ManifestFile.zUuid is an absolute pathname rather than an artifact
972
+** hash. When zUuid is a pathname, the content of the file at that pathname
973
+** is read directly from disk.
974
+*/
975
+static void diff_fetch_manifest_entry(
976
+ ManifestFile *pFile,
977
+ Blob *pContent
978
+){
979
+ if( pFile==0){
980
+ blob_zero(pContent);
981
+ }else if( file_is_absolute_path(pFile->zUuid) ){
982
+ blob_read_from_file(pContent, pFile->zUuid, ExtFILE);
983
+ }else{
984
+ int rid = uuid_to_rid(pFile->zUuid, 0);
985
+ content_get(rid, pContent);
986
+ }
987
+}
965988
966989
/*
967990
** Show the difference between two files identified by ManifestFile
968991
** entries.
969992
**
@@ -971,18 +994,22 @@
971994
** command zDiffCmd to do the diffing.
972995
**
973996
** When using an external diff program, zBinGlob contains the GLOB patterns
974997
** for file names to treat as binary. If fIncludeBinary is zero, these files
975998
** will be skipped in addition to files that may contain binary content.
999
+**
1000
+** This routine accepts non-standard ManifestFile records where the
1001
+** ManifestFile.zUuid is an absolute pathname rather than an artifact
1002
+** hash. When zUuid is a pathname, the content of the file at that pathname
1003
+** is read directly from disk.
9761004
*/
9771005
static void diff_manifest_entry(
9781006
struct ManifestFile *pFrom,
9791007
struct ManifestFile *pTo,
9801008
DiffConfig *pCfg
9811009
){
9821010
Blob f1, f2;
983
- int rid;
9841011
const char *zName;
9851012
if( pFrom ){
9861013
zName = pFrom->zName;
9871014
}else if( pTo ){
9881015
zName = pTo->zName;
@@ -989,22 +1016,12 @@
9891016
}else{
9901017
zName = DIFF_NO_NAME;
9911018
}
9921019
if( pCfg->diffFlags & DIFF_BRIEF ) return;
9931020
diff_print_index(zName, pCfg, 0);
994
- if( pFrom ){
995
- rid = uuid_to_rid(pFrom->zUuid, 0);
996
- content_get(rid, &f1);
997
- }else{
998
- blob_zero(&f1);
999
- }
1000
- if( pTo ){
1001
- rid = uuid_to_rid(pTo->zUuid, 0);
1002
- content_get(rid, &f2);
1003
- }else{
1004
- blob_zero(&f2);
1005
- }
1021
+ diff_fetch_manifest_entry(pFrom, &f1);
1022
+ diff_fetch_manifest_entry(pTo, &f2);
10061023
diff_file_mem(&f1, &f2, zName, pCfg);
10071024
blob_reset(&f1);
10081025
blob_reset(&f2);
10091026
}
10101027
10111028
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -960,10 +960,33 @@
960 fossil_free(zFullName);
961 blob_reset(&content);
962 }
963 db_finalize(&q);
964 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
965
966 /*
967 ** Show the difference between two files identified by ManifestFile
968 ** entries.
969 **
@@ -971,18 +994,22 @@
971 ** command zDiffCmd to do the diffing.
972 **
973 ** When using an external diff program, zBinGlob contains the GLOB patterns
974 ** for file names to treat as binary. If fIncludeBinary is zero, these files
975 ** will be skipped in addition to files that may contain binary content.
 
 
 
 
 
976 */
977 static void diff_manifest_entry(
978 struct ManifestFile *pFrom,
979 struct ManifestFile *pTo,
980 DiffConfig *pCfg
981 ){
982 Blob f1, f2;
983 int rid;
984 const char *zName;
985 if( pFrom ){
986 zName = pFrom->zName;
987 }else if( pTo ){
988 zName = pTo->zName;
@@ -989,22 +1016,12 @@
989 }else{
990 zName = DIFF_NO_NAME;
991 }
992 if( pCfg->diffFlags & DIFF_BRIEF ) return;
993 diff_print_index(zName, pCfg, 0);
994 if( pFrom ){
995 rid = uuid_to_rid(pFrom->zUuid, 0);
996 content_get(rid, &f1);
997 }else{
998 blob_zero(&f1);
999 }
1000 if( pTo ){
1001 rid = uuid_to_rid(pTo->zUuid, 0);
1002 content_get(rid, &f2);
1003 }else{
1004 blob_zero(&f2);
1005 }
1006 diff_file_mem(&f1, &f2, zName, pCfg);
1007 blob_reset(&f1);
1008 blob_reset(&f2);
1009 }
1010
1011
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -960,10 +960,33 @@
960 fossil_free(zFullName);
961 blob_reset(&content);
962 }
963 db_finalize(&q);
964 }
965
966 /*
967 ** Fetch the content for pFile into pContent. pContent is assumed to be
968 ** uninitialized.
969 **
970 ** This routine accepts non-standard ManifestFile records where the
971 ** ManifestFile.zUuid is an absolute pathname rather than an artifact
972 ** hash. When zUuid is a pathname, the content of the file at that pathname
973 ** is read directly from disk.
974 */
975 static void diff_fetch_manifest_entry(
976 ManifestFile *pFile,
977 Blob *pContent
978 ){
979 if( pFile==0){
980 blob_zero(pContent);
981 }else if( file_is_absolute_path(pFile->zUuid) ){
982 blob_read_from_file(pContent, pFile->zUuid, ExtFILE);
983 }else{
984 int rid = uuid_to_rid(pFile->zUuid, 0);
985 content_get(rid, pContent);
986 }
987 }
988
989 /*
990 ** Show the difference between two files identified by ManifestFile
991 ** entries.
992 **
@@ -971,18 +994,22 @@
994 ** command zDiffCmd to do the diffing.
995 **
996 ** When using an external diff program, zBinGlob contains the GLOB patterns
997 ** for file names to treat as binary. If fIncludeBinary is zero, these files
998 ** will be skipped in addition to files that may contain binary content.
999 **
1000 ** This routine accepts non-standard ManifestFile records where the
1001 ** ManifestFile.zUuid is an absolute pathname rather than an artifact
1002 ** hash. When zUuid is a pathname, the content of the file at that pathname
1003 ** is read directly from disk.
1004 */
1005 static void diff_manifest_entry(
1006 struct ManifestFile *pFrom,
1007 struct ManifestFile *pTo,
1008 DiffConfig *pCfg
1009 ){
1010 Blob f1, f2;
 
1011 const char *zName;
1012 if( pFrom ){
1013 zName = pFrom->zName;
1014 }else if( pTo ){
1015 zName = pTo->zName;
@@ -989,22 +1016,12 @@
1016 }else{
1017 zName = DIFF_NO_NAME;
1018 }
1019 if( pCfg->diffFlags & DIFF_BRIEF ) return;
1020 diff_print_index(zName, pCfg, 0);
1021 diff_fetch_manifest_entry(pFrom, &f1);
1022 diff_fetch_manifest_entry(pTo, &f2);
 
 
 
 
 
 
 
 
 
 
1023 diff_file_mem(&f1, &f2, zName, pCfg);
1024 blob_reset(&f1);
1025 blob_reset(&f2);
1026 }
1027
1028

Keyboard Shortcuts

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