Index: auto.def ================================================================== --- auto.def +++ auto.def @@ -5,10 +5,12 @@ options { with-openssl:path|auto|none => {Look for OpenSSL in the given path, or auto or none} with-miniz=0 => {Use miniz from the source tree} with-zlib:path => {Look for zlib in the given path} + with-exec-rel-paths=0 + => {Enable relative paths for external diff/gdiff} with-legacy-mv-rm=0 => {Enable legacy behavior for mv/rm (skip checkout files)} with-th1-docs=0 => {Enable TH1 for embedded documentation pages} with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages} with-tcl:path => {Enable Tcl integration, with Tcl in the specified path} with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism} @@ -91,10 +93,16 @@ if {[opt-bool with-legacy-mv-rm]} { define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_LEGACY_MV_RM define FOSSIL_ENABLE_LEGACY_MV_RM msg-result "Legacy mv/rm support enabled" } + +if {[opt-bool with-exec-rel-paths]} { + define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_EXEC_REL_PATHS + define FOSSIL_ENABLE_EXEC_REL_PATHS + msg-result "Relative paths in external diff/gdiff enabled" +} if {[opt-bool with-th1-docs]} { define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS define FOSSIL_ENABLE_TH1_DOCS msg-result "TH1 embedded documentation support enabled" Index: src/db.c ================================================================== --- src/db.c +++ src/db.c @@ -2380,10 +2380,15 @@ { "dont-push", 0, 0, 0, 0, "off" }, { "dotfiles", 0, 0, 1, 0, "off" }, { "editor", 0, 32, 0, 0, "" }, { "empty-dirs", 0, 40, 1, 0, "" }, { "encoding-glob", 0, 40, 1, 0, "" }, +#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS) + { "exec-rel-paths", 0, 0, 0, 0, "on" }, +#else + { "exec-rel-paths", 0, 0, 0, 0, "off" }, +#endif { "gdiff-command", 0, 40, 0, 0, "gdiff" }, { "gmerge-command", 0, 40, 0, 0, "" }, { "hash-digits", 0, 5, 0, 0, "10" }, { "http-port", 0, 16, 0, 0, "8080" }, { "https-login", 0, 0, 0, 0, "off" }, @@ -2555,10 +2560,13 @@ ** encoding-glob The VALUE is a comma or newline-separated list of GLOB ** (versionable) patterns specifying files that the "commit" command will ** ignore when issuing warnings about text files that may ** use another encoding than ASCII or UTF-8. Set to "*" ** to disable encoding checking. +** +** exec-rel-paths When executing certain external commands (e.g. diff and +** gdiff), use relative paths. ** ** gdiff-command External command to run when performing a graphical ** diff. If undefined, text diff will be used. ** ** gmerge-command A graphical merge conflict resolver command operating Index: src/diffcmd.c ================================================================== --- src/diffcmd.c +++ src/diffcmd.c @@ -32,10 +32,32 @@ /* ** Used when the name for the diff is unknown. */ #define DIFF_NO_NAME "(unknown)" + +/* +** Use the "exec-rel-paths" setting and the --exec-abs-paths and +** --exec-rel-paths command line options to determine whether +** certain external commands are executed using relative paths. +*/ +static int determine_exec_relative_option(int force) +{ + static int relativePaths = -1; + if( force || relativePaths==-1 ){ + int relPathOption = find_option("exec-rel-paths", 0, 0)!=0; + int absPathOption = find_option("exec-abs-paths", 0, 0)!=0; +#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS) + relativePaths = db_get_boolean("exec-rel-paths", 1); +#else + relativePaths = db_get_boolean("exec-rel-paths", 0); +#endif + if( relPathOption ){ relativePaths = 1; } + if( absPathOption ){ relativePaths = 0; } + } + return relativePaths; +} /* ** Print the "Index:" message that patches wants to see at the top of a diff. */ void diff_print_index(const char *zFile, u64 diffFlags){ @@ -384,13 +406,22 @@ int isDeleted = db_column_int(&q, 1); int isChnged = db_column_int(&q,2); int isNew = db_column_int(&q,3); int srcid = db_column_int(&q, 4); int isLink = db_column_int(&q, 5); - char *zToFree = mprintf("%s%s", g.zLocalRoot, zPathname); - const char *zFullName = zToFree; + const char *zFullName; int showDiff = 1; + Blob fname; + + if( determine_exec_relative_option(0) ){ + blob_zero(&fname); + file_relative_name(zPathname, &fname, 1); + }else{ + blob_set(&fname, g.zLocalRoot); + blob_append(&fname, zPathname, -1); + } + zFullName = blob_str(&fname); if( isDeleted ){ fossil_print("DELETED %s\n", zPathname); if( !asNewFile ){ showDiff = 0; zFullName = NULL_DEVICE; } }else if( file_access(zFullName, F_OK) ){ fossil_print("MISSING %s\n", zPathname); @@ -422,11 +453,11 @@ diff_print_index(zPathname, diffFlags); diff_file(&content, isBin, zFullName, zPathname, zDiffCmd, zBinGlob, fIncludeBinary, diffFlags); blob_reset(&content); } - free(zToFree); + blob_reset(&fname); } db_finalize(&q); db_end_transaction(1); /* ROLLBACK */ } @@ -812,10 +843,12 @@ ** --binary PATTERN Treat files that match the glob PATTERN as binary ** --branch BRANCH Show diff of all changes on BRANCH ** --brief Show filenames only ** --context|-c N Use N lines of context ** --diff-binary BOOL Include binary files when using external commands +** --exec-abs-paths Force absolute path names with external commands. +** --exec-rel-paths Force relative path names with external commands. ** --from|-r VERSION select VERSION as source for the diff ** --internal|-i use internal diff logic ** --side-by-side|-y side-by-side diff ** --strip-trailing-cr Strip trailing CR ** --tk Launch a Tcl/Tk GUI for display @@ -876,10 +909,11 @@ if( !isInternDiff ){ zDiffCmd = diff_command_external(isGDiff); } zBinGlob = diff_get_binary_glob(); fIncludeBinary = diff_include_binary_files(); + determine_exec_relative_option(1); verify_all_options(); if( againstUndo ){ if( db_lget_int("undo_available",0)==0 ){ fossil_print("No undo or redo is available\n"); return; Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -1060,10 +1060,13 @@ #if defined(FOSSIL_ENABLE_SSL) fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION)); #endif #if defined(FOSSIL_ENABLE_LEGACY_MV_RM) fossil_print("LEGACY_MV_RM\n"); +#endif +#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS) + fossil_print("EXEC_REL_PATHS\n"); #endif #if defined(FOSSIL_ENABLE_TH1_DOCS) fossil_print("TH1_DOCS\n"); #endif #if defined(FOSSIL_ENABLE_TH1_HOOKS) Index: src/makemake.tcl ================================================================== --- src/makemake.tcl +++ src/makemake.tcl @@ -505,10 +505,14 @@ #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 + +#### Enable relative paths in external diff/gdiff +# +# FOSSIL_ENABLE_EXEC_REL_PATHS = 1 #### Enable legacy treatment of mv/rm (skip checkout files) # # FOSSIL_ENABLE_LEGACY_MV_RM = 1 @@ -710,10 +714,16 @@ # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif + +# With relative paths in external diff/gdiff +ifdef FOSSIL_ENABLE_EXEC_REL_PATHS +TCC += -DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +RCC += -DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +endif # With legacy treatment of mv/rm ifdef FOSSIL_ENABLE_LEGACY_MV_RM TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1 RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1 @@ -1339,10 +1349,15 @@ # Link everything except SQLite dynamically? !ifndef FOSSIL_DYNAMIC_BUILD FOSSIL_DYNAMIC_BUILD = 0 !endif + +# Enable relative paths in external diff/gdiff? +!ifndef FOSSIL_ENABLE_EXEC_REL_PATHS +FOSSIL_ENABLE_EXEC_REL_PATHS = 0 +!endif # Enable the JSON API? !ifndef FOSSIL_ENABLE_JSON FOSSIL_ENABLE_JSON = 0 !endif @@ -1557,10 +1572,15 @@ TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1 RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1 LIBS = $(LIBS) $(SSLLIB) LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR) !endif + +!if $(FOSSIL_ENABLE_EXEC_REL_PATHS)!=0 +TCC = $(TCC) /DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +RCC = $(RCC) /DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +!endif !if $(FOSSIL_ENABLE_LEGACY_MV_RM)!=0 TCC = $(TCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1 RCC = $(RCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1 !endif Index: src/th_main.c ================================================================== --- src/th_main.c +++ src/th_main.c @@ -653,10 +653,11 @@ ** Return true if the fossil binary has the given compile-time feature ** enabled. The set of features includes: ** ** "ssl" = FOSSIL_ENABLE_SSL ** "legacyMvRm" = FOSSIL_ENABLE_LEGACY_MV_RM +** "execRelPaths" = FOSSIL_ENABLE_EXEC_REL_PATHS ** "th1Docs" = FOSSIL_ENABLE_TH1_DOCS ** "th1Hooks" = FOSSIL_ENABLE_TH1_HOOKS ** "tcl" = FOSSIL_ENABLE_TCL ** "useTclStubs" = USE_TCL_STUBS ** "tclStubs" = FOSSIL_ENABLE_TCL_STUBS @@ -664,10 +665,12 @@ ** "json" = FOSSIL_ENABLE_JSON ** "markdown" = FOSSIL_ENABLE_MARKDOWN ** "unicodeCmdLine" = !BROKEN_MINGW_CMDLINE ** "dynamicBuild" = FOSSIL_DYNAMIC_BUILD ** +** Specifying an unknown feature will return a value of false, it will not +** raise a script error. */ static int hasfeatureCmd( Th_Interp *interp, void *p, int argc, @@ -690,10 +693,15 @@ #endif #if defined(FOSSIL_ENABLE_LEGACY_MV_RM) else if( 0 == fossil_strnicmp( zArg, "legacyMvRm\0", 11 ) ){ rc = 1; } +#endif +#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS) + else if( 0 == fossil_strnicmp( zArg, "execRelPaths\0", 13 ) ){ + rc = 1; + } #endif #if defined(FOSSIL_ENABLE_TH1_DOCS) else if( 0 == fossil_strnicmp( zArg, "th1Docs\0", 8 ) ){ rc = 1; } Index: win/Makefile.mingw ================================================================== --- win/Makefile.mingw +++ win/Makefile.mingw @@ -56,10 +56,14 @@ #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 + +#### Enable relative paths in external diff/gdiff +# +# FOSSIL_ENABLE_EXEC_REL_PATHS = 1 #### Enable legacy treatment of mv/rm (skip checkout files) # # FOSSIL_ENABLE_LEGACY_MV_RM = 1 @@ -261,10 +265,16 @@ # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif + +# With relative paths in external diff/gdiff +ifdef FOSSIL_ENABLE_EXEC_REL_PATHS +TCC += -DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +RCC += -DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +endif # With legacy treatment of mv/rm ifdef FOSSIL_ENABLE_LEGACY_MV_RM TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1 RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1 Index: win/Makefile.mingw.mistachkin ================================================================== --- win/Makefile.mingw.mistachkin +++ win/Makefile.mingw.mistachkin @@ -56,10 +56,14 @@ #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 + +#### Enable relative paths in external diff/gdiff +# +# FOSSIL_ENABLE_EXEC_REL_PATHS = 1 #### Enable legacy treatment of mv/rm (skip checkout files) # FOSSIL_ENABLE_LEGACY_MV_RM = 1 @@ -261,10 +265,16 @@ # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif + +# With relative paths in external diff/gdiff +ifdef FOSSIL_ENABLE_EXEC_REL_PATHS +TCC += -DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +RCC += -DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +endif # With legacy treatment of mv/rm ifdef FOSSIL_ENABLE_LEGACY_MV_RM TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1 RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1 Index: win/Makefile.msc ================================================================== --- win/Makefile.msc +++ win/Makefile.msc @@ -46,10 +46,15 @@ # Link everything except SQLite dynamically? !ifndef FOSSIL_DYNAMIC_BUILD FOSSIL_DYNAMIC_BUILD = 0 !endif + +# Enable relative paths in external diff/gdiff? +!ifndef FOSSIL_ENABLE_EXEC_REL_PATHS +FOSSIL_ENABLE_EXEC_REL_PATHS = 0 +!endif # Enable the JSON API? !ifndef FOSSIL_ENABLE_JSON FOSSIL_ENABLE_JSON = 0 !endif @@ -264,10 +269,15 @@ TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1 RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1 LIBS = $(LIBS) $(SSLLIB) LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR) !endif + +!if $(FOSSIL_ENABLE_EXEC_REL_PATHS)!=0 +TCC = $(TCC) /DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +RCC = $(RCC) /DFOSSIL_ENABLE_EXEC_REL_PATHS=1 +!endif !if $(FOSSIL_ENABLE_LEGACY_MV_RM)!=0 TCC = $(TCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1 RCC = $(RCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1 !endif Index: win/fossil.rc ================================================================== --- win/fossil.rc +++ win/fossil.rc @@ -125,10 +125,15 @@ #if defined(FOSSIL_ENABLE_LEGACY_MV_RM) VALUE "LegacyMvRm", "Yes\0" #else VALUE "LegacyMvRm", "No\0" #endif /* defined(FOSSIL_ENABLE_LEGACY_MV_RM) */ +#if defined(FOSSIL_ENABLE_EXEC_REL_PATHS) + VALUE "ExecRelPaths", "Yes\0" +#else + VALUE "ExecRelPaths", "No\0" +#endif /* defined(FOSSIL_ENABLE_EXEC_REL_PATHS) */ #if defined(FOSSIL_ENABLE_TH1_DOCS) VALUE "Th1Docs", "Yes\0" #else VALUE "Th1Docs", "No\0" #endif /* defined(FOSSIL_ENABLE_TH1_DOCS) */ Index: www/th1.md ================================================================== --- www/th1.md +++ www/th1.md @@ -319,10 +319,11 @@ Returns true if the binary has the given compile-time feature enabled. The possible features are: 1. **ssl** -- _Support for the HTTPS transport._ 1. **legacyMvRm** -- _Support for legacy mv/rm command behavior._ + 1. **execRelPaths** -- _Use relative paths with external diff/gdiff._ 1. **th1Docs** -- _Support for TH1 in embedded documentation._ 1. **th1Hooks** -- _Support for TH1 command and web page hooks._ 1. **tcl** -- _Support for Tcl integration._ 1. **useTclStubs** -- _Tcl stubs enabled in the Tcl headers._ 1. **tclStubs** -- _Uses Tcl stubs (i.e. linking with stubs library)._ @@ -329,10 +330,13 @@ 1. **tclPrivateStubs** -- _Uses Tcl private stubs (i.e. header-only)._ 1. **json** -- _Support for the JSON APIs._ 1. **markdown** -- _Support for Markdown documentation format._ 1. **unicodeCmdLine** -- _The command line arguments are Unicode._ 1. **dynamicBuild** -- _Dynamically linked to libraries._ + +Specifying an unknown feature will return a value of false, it will not +raise a script error. TH1 html Command ----------------------------------- * html STRING