Index: src/bisect.c ================================================================== --- src/bisect.c +++ src/bisect.c @@ -477,11 +477,11 @@ for(i=0; i # include #endif #if INTERFACE -#define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */ +#define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags = non-legacy. */ #define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */ #define COMMENT_PRINT_TRIM_CRLF ((u32)0x00000002) /* Trim leading CR/LF. */ #define COMMENT_PRINT_TRIM_SPACE ((u32)0x00000004) /* Trim leading/trailing. */ #define COMMENT_PRINT_WORD_BREAK ((u32)0x00000008) /* Break lines on words. */ #define COMMENT_PRINT_ORIG_BREAK ((u32)0x00000010) /* Break before original. */ #define COMMENT_PRINT_DEFAULT (COMMENT_PRINT_LEGACY) /* Defaults. */ +#define COMMENT_PRINT_UNSET (-1) /* Not initialized. */ #endif /* ** This is the previous value used by most external callers when they ** needed to specify a default maximum line length to be used with the @@ -514,10 +515,38 @@ &lineCnt, &zLine); if( !zLine || !zLine[0] ) break; } return lineCnt; } + +/* +** Return the "COMMENT_PRINT_*" flags specified by the following sources, +** evaluated in the following cascading order: +** +** 1. The global --comfmtflags (alias --comment-format) command-line option. +** 2. The local (per-repository) "comment-format" setting. +** 3. The global (all-repositories) "comment-format" setting. +** 4. The default value COMMENT_PRINT_DEFAULT. +*/ +int get_comment_format(){ + int comFmtFlags; + /* The global command-line option is present, or the value has been cached. */ + if( g.comFmtFlags!=COMMENT_PRINT_UNSET ){ + comFmtFlags = g.comFmtFlags; + return comFmtFlags; + } + /* Load the local (per-repository) or global (all-repositories) value, and use + ** g.comFmtFlags as a cache. */ + comFmtFlags = db_get_int("comment-format", COMMENT_PRINT_UNSET); + if( comFmtFlags!=COMMENT_PRINT_UNSET ){ + g.comFmtFlags = comFmtFlags; + return comFmtFlags; + } + /* Fallback to the default value. */ + comFmtFlags = COMMENT_PRINT_DEFAULT; + return comFmtFlags; +} /* ** ** COMMAND: test-comment-format ** Index: src/configure.c ================================================================== --- src/configure.c +++ src/configure.c @@ -136,10 +136,11 @@ { "allow-symlinks", CONFIGSET_PROJ }, { "dotfiles", CONFIGSET_PROJ }, { "parent-project-code", CONFIGSET_PROJ }, { "parent-project-name", CONFIGSET_PROJ }, { "hash-policy", CONFIGSET_PROJ }, + { "comment-format", CONFIGSET_PROJ }, #ifdef FOSSIL_ENABLE_LEGACY_MV_RM { "mv-rm-files", CONFIGSET_PROJ }, #endif Index: src/db.c ================================================================== --- src/db.c +++ src/db.c @@ -3169,10 +3169,33 @@ /* ** SETTING: clearsign boolean default=off ** When enabled, fossil will attempt to sign all commits ** with gpg. When disabled, commits will be unsigned. */ +/* +** SETTING: comment-format width=16 default=1 +** Set the default options for printing timeline comments to the console. +** +** The global --comfmtflags command-line option (or alias --comment-format) +** overrides this setting. +** +** Possible values are: +** 1 Activate the legacy comment printing format (default). +** +** Or a bitwise combination of the following flags: +** 0 Activate the newer (non-legacy) comment printing format. +** 2 Trim leading and trailing CR and LF characters. +** 4 Trim leading and trailing white space characters. +** 8 Attempt to break lines on word boundaries. +** 16 Break lines before the original comment embedded in other text. +** +** Note: To preserve line breaks, activate the newer (non-legacy) comment +** printing format (i.e. set to "0", or a combination not including "1"). +** +** Note: The options for timeline comments displayed on the web UI can be +** configured through the /setup_timeline web page. +*/ /* ** SETTING: crlf-glob width=40 versionable block-text ** The value is a comma or newline-separated list of GLOB patterns for ** text files in which it is ok to have CR, CR+LF or mixed ** line endings. Set to "*" to disable CR+LF checking. Index: src/descendants.c ================================================================== --- src/descendants.c +++ src/descendants.c @@ -433,11 +433,11 @@ } n++; sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n); fossil_print("%6s ", zLineNo); z = mprintf("%s [%S] %s", zDate, zId, zCom); - comment_print(z, zCom, 7, width, g.comFmtFlags); + comment_print(z, zCom, 7, width, get_comment_format()); fossil_free(z); } fossil_free(zLastBr); db_finalize(&q); } Index: src/dispatch.c ================================================================== --- src/dispatch.c +++ src/dispatch.c @@ -501,10 +501,11 @@ @ Command-line options common to all commands: @ @ --args FILENAME Read additional arguments and options from FILENAME @ --cgitrace Active CGI tracing @ --comfmtflags VALUE Set comment formatting flags to VALUE +@ --comment-format VALUE Alias for --comfmtflags @ --errorlog FILENAME Log errors to FILENAME @ --help Show help on the command rather than running it @ --httptrace Trace outbound HTTP requests @ --localtime Display times using the local timezone @ --no-th-hook Do not run TH1 hooks Index: src/finfo.c ================================================================== --- src/finfo.c +++ src/finfo.c @@ -215,20 +215,20 @@ if( iBrief ){ fossil_print("%s ", zDate); zOut = mprintf( "[%S] %s (user: %s, artifact: [%S], branch: %s)", zCiUuid, zCom, zUser, zFileUuid, zBr); - comment_print(zOut, zCom, 11, iWidth, g.comFmtFlags); + comment_print(zOut, zCom, 11, iWidth, get_comment_format()); fossil_free(zOut); }else{ blob_reset(&line); blob_appendf(&line, "%S ", zCiUuid); blob_appendf(&line, "%.10s ", zDate); blob_appendf(&line, "%8.8s ", zUser); blob_appendf(&line, "%8.8s ", zBr); blob_appendf(&line,"%-39.39s", zCom ); - comment_print(blob_str(&line), zCom, 0, iWidth, g.comFmtFlags); + comment_print(blob_str(&line), zCom, 0, iWidth, get_comment_format()); } } db_finalize(&q); blob_reset(&fname); } Index: src/info.c ================================================================== --- src/info.c +++ src/info.c @@ -117,11 +117,11 @@ fossil_print("tags: %s\n", zTags); } free(zTags); if( zComment ){ fossil_print("comment: "); - comment_print(zComment, 0, 14, -1, g.comFmtFlags); + comment_print(zComment, 0, 14, -1, get_comment_format()); free(zComment); } } /* Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -203,11 +203,12 @@ ** SSL client identity */ int useLocalauth; /* No login required if from 127.0.0.1 */ int noPswd; /* Logged in without password (on 127.0.0.1) */ int userUid; /* Integer user id */ int isHuman; /* True if access by a human, not a spider or bot */ - int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags */ + int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags, should be + ** accessed through get_comment_format(). */ /* Information used to populate the RCVFROM table */ int rcvid; /* The rcvid. 0 if not yet defined. */ char *zIpAddr; /* The remote IP address */ char *zNonce; /* The nonce used for login */ @@ -575,14 +576,17 @@ ** this function executes, all global variables (i.e. in the "g" struct) ** containing option-settable bitwise flag fields must be initialized. */ static void fossil_init_flags_from_options(void){ const char *zValue = find_option("comfmtflags", 0, 1); + if( zValue==0 ){ + zValue = find_option("comment-format", 0, 1); + } if( zValue ){ g.comFmtFlags = atoi(zValue); }else{ - g.comFmtFlags = COMMENT_PRINT_DEFAULT; + g.comFmtFlags = COMMENT_PRINT_UNSET; /* Command-line option not found. */ } } /* ** Check to see if the Fossil binary contains an appended repository Index: src/merge.c ================================================================== --- src/merge.c +++ src/merge.c @@ -47,11 +47,11 @@ indent-1, zLabel, db_column_text(&q, 3), db_column_text(&q, 1), db_column_text(&q, 0), indent, ""); - comment_print(zCom, db_column_text(&q,2), indent, -1, g.comFmtFlags); + comment_print(zCom, db_column_text(&q,2), indent, -1, get_comment_format()); fossil_free(zCom); } db_finalize(&q); } @@ -321,11 +321,11 @@ ); if( db_step(&q)==SQLITE_ROW ){ char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"", db_column_text(&q, 0), db_column_text(&q, 1), db_column_text(&q, 3), db_column_text(&q, 2)); - comment_print(zCom, db_column_text(&q,2), 0, -1, g.comFmtFlags); + comment_print(zCom, db_column_text(&q,2), 0, -1, get_comment_format()); fossil_free(zCom); } db_finalize(&q); }else{ usage("?OPTIONS? ?VERSION?"); Index: src/name.c ================================================================== --- src/name.c +++ src/name.c @@ -612,11 +612,11 @@ default: zType = "Unknown"; break; } fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2), db_column_text(&q, 1)); fossil_print("comment: "); - comment_print(db_column_text(&q,3), 0, 12, -1, g.comFmtFlags); + comment_print(db_column_text(&q,3), 0, 12, -1, get_comment_format()); } db_finalize(&q); /* Check to see if this object is used as a file in a check-in */ db_prepare(&q, @@ -634,11 +634,11 @@ fossil_print(" part of [%S] by %s on %s\n", db_column_text(&q, 1), db_column_text(&q, 3), db_column_text(&q, 2)); fossil_print(" "); - comment_print(db_column_text(&q,4), 0, 12, -1, g.comFmtFlags); + comment_print(db_column_text(&q,4), 0, 12, -1, get_comment_format()); } db_finalize(&q); /* Check to see if this object is used as an attachment */ db_prepare(&q, @@ -669,11 +669,11 @@ db_column_text(&q,7)); } fossil_print(" by user %s on %s\n", db_column_text(&q,2), db_column_text(&q,3)); fossil_print(" "); - comment_print(db_column_text(&q,1), 0, 12, -1, g.comFmtFlags); + comment_print(db_column_text(&q,1), 0, 12, -1, get_comment_format()); } db_finalize(&q); } /* Index: src/stash.c ================================================================== --- src/stash.c +++ src/stash.c @@ -652,11 +652,11 @@ db_column_text(&q, 3) ); zCom = db_column_text(&q, 2); if( zCom && zCom[0] ){ fossil_print(" "); - comment_print(zCom, 0, 7, width, g.comFmtFlags); + comment_print(zCom, 0, 7, width, get_comment_format()); } if( verboseFlag ){ db_bind_int(&q2, "$id", stashid); while( db_step(&q2)==SQLITE_ROW ){ int isAdded = db_column_int(&q2, 0); Index: src/timeline.c ================================================================== --- src/timeline.c +++ src/timeline.c @@ -2407,11 +2407,11 @@ sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*UNPUBLISHED* "); n += strlen(zPrefix+n); } zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom); /* record another X lines */ - nLine += comment_print(zFree, zCom, 9, width, g.comFmtFlags); + nLine += comment_print(zFree, zCom, 9, width, get_comment_format()); fossil_free(zFree); if(verboseFlag){ if( !fchngQueryInit ){ db_prepare(&fchngQuery, Index: src/tkt.c ================================================================== --- src/tkt.c +++ src/tkt.c @@ -1297,11 +1297,11 @@ fossil_print(" Change "); } fossil_print("%h: ",z); if( blob_size(&val)>50 || contains_newline(&val)) { fossil_print("\n "); - comment_print(blob_str(&val),0,4,-1,g.comFmtFlags); + comment_print(blob_str(&val),0,4,-1,get_comment_format()); }else{ fossil_print("%s\n",blob_str(&val)); } blob_reset(&val); } Index: www/env-opts.md ================================================================== --- www/env-opts.md +++ www/env-opts.md @@ -31,11 +31,12 @@ `--chdir DIRECTORY`: Change to the named directory before processing any commands. -`--comfmtflags NUMBER`: Specify flags that control how check-in comments +`--comfmtflags NUMBER` +`--comment-format NUMBER`: Specify flags that control how check-in comments and certain other text outputs are formatted for display. The flags are individual bits in `NUMBER`, which must be specified in base 10: * _0_ — Uses the revised algorithm with no special handling.