Fossil SCM
Further simplification of the DiffConfig object by splitting out the lines of context and column width values from the diffFlags vector into separate columns. There should be no user-visible changes in behavior.
Commit
ca6fa4b2f3d12aedfa3fea4ecc1641a148f67d89af999fd1c845b991c079cc0c
Parent
590e01dbddd07fa…
2 files changed
+31
-33
+8
-18
+31
-33
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -26,33 +26,31 @@ | ||
| 26 | 26 | #if INTERFACE |
| 27 | 27 | /* |
| 28 | 28 | ** Flag parameters to the text_diff() routine used to control the formatting |
| 29 | 29 | ** of the diff output. |
| 30 | 30 | */ |
| 31 | -#define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */ | |
| 32 | -#define DIFF_WIDTH_MASK ((u64)0x00ff0000) /* side-by-side column width */ | |
| 33 | -#define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */ | |
| 34 | -#define DIFF_IGNORE_ALLWS ((u64)0x03000000) /* Ignore all whitespace */ | |
| 35 | -#define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */ | |
| 36 | -#define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */ | |
| 37 | -#define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */ | |
| 38 | -#define DIFF_HTML ((u64)0x20000000) /* Render for HTML */ | |
| 39 | -#define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ | |
| 40 | -#define DIFF_NUMSTAT ((u64)0x80000000) /* Show line count of changes */ | |
| 41 | -#define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */ | |
| 42 | -#define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */ | |
| 43 | -#define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */ | |
| 44 | -#define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */ | |
| 45 | -#define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */ | |
| 46 | -#define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better but slower side-by-side */ | |
| 47 | -#define DIFF_WEBPAGE (((u64)0x00040)<<32) /* Complete webpage */ | |
| 48 | -#define DIFF_BROWSER (((u64)0x00080)<<32) /* The --browser option */ | |
| 49 | -#define DIFF_JSON (((u64)0x00100)<<32) /* JSON output */ | |
| 50 | -#define DIFF_DEBUG (((u64)0x00200)<<32) /* Debugging diff output */ | |
| 51 | -#define DIFF_RAW (((u64)0x00400)<<32) /* Raw triples - for debugging */ | |
| 52 | -#define DIFF_TCL (((u64)0x00800)<<32) /* For the --tk option */ | |
| 53 | -#define DIFF_INCBINARY (((u64)0x01000)<<32) /* The --diff-binary option */ | |
| 31 | +#define DIFF_IGNORE_EOLWS 0x00000001 /* Ignore end-of-line whitespace */ | |
| 32 | +#define DIFF_IGNORE_ALLWS 0x00000003 /* Ignore all whitespace */ | |
| 33 | +#define DIFF_SIDEBYSIDE 0x00000004 /* Generate a side-by-side diff */ | |
| 34 | +#define DIFF_VERBOSE 0x00000008 /* Missing shown as empty files */ | |
| 35 | +#define DIFF_BRIEF 0x00000010 /* Show filenames only */ | |
| 36 | +#define DIFF_HTML 0x00000020 /* Render for HTML */ | |
| 37 | +#define DIFF_LINENO 0x00000040 /* Show line numbers */ | |
| 38 | +#define DIFF_NUMSTAT 0x00000080 /* Show line count of changes */ | |
| 39 | +#define DIFF_NOOPT 0x00000100 /* Suppress optimizations (debug) */ | |
| 40 | +#define DIFF_INVERT 0x00000200 /* Invert the diff (debug) */ | |
| 41 | +#define DIFF_CONTEXT_EX 0x00000400 /* Use context even if zero */ | |
| 42 | +#define DIFF_NOTTOOBIG 0x00000800 /* Only display if not too big */ | |
| 43 | +#define DIFF_STRIP_EOLCR 0x00001000 /* Strip trailing CR */ | |
| 44 | +#define DIFF_SLOW_SBS 0x00002000 /* Better but slower side-by-side */ | |
| 45 | +#define DIFF_WEBPAGE 0x00004000 /* Complete webpage */ | |
| 46 | +#define DIFF_BROWSER 0x00008000 /* The --browser option */ | |
| 47 | +#define DIFF_JSON 0x00010000 /* JSON output */ | |
| 48 | +#define DIFF_DEBUG 0x00020000 /* Debugging diff output */ | |
| 49 | +#define DIFF_RAW 0x00040000 /* Raw triples - for debugging */ | |
| 50 | +#define DIFF_TCL 0x00080000 /* For the --tk option */ | |
| 51 | +#define DIFF_INCBINARY 0x00100000 /* The --diff-binary option */ | |
| 54 | 52 | |
| 55 | 53 | /* |
| 56 | 54 | ** These error messages are shared in multiple locations. They are defined |
| 57 | 55 | ** here for consistency. |
| 58 | 56 | */ |
| @@ -92,10 +90,12 @@ | ||
| 92 | 90 | ** |
| 93 | 91 | ** * Width of output columns for text side-by-side diffop |
| 94 | 92 | */ |
| 95 | 93 | struct DiffConfig { |
| 96 | 94 | u64 diffFlags; /* Diff flags */ |
| 95 | + int nContext; /* Number of lines of context */ | |
| 96 | + int wColumn; /* Column width in -y mode */ | |
| 97 | 97 | u32 nFile; /* Number of files diffed so far */ |
| 98 | 98 | const char *zDiffCmd; /* External diff command to use instead of builtin */ |
| 99 | 99 | const char *zBinGlob; /* GLOB pattern for binary files */ |
| 100 | 100 | ReCompiled *pRe; /* Show only changes matching this pattern */ |
| 101 | 101 | }; |
| @@ -2547,12 +2547,12 @@ | ||
| 2547 | 2547 | /* |
| 2548 | 2548 | ** Extract the number of lines of context from diffFlags. Supply an |
| 2549 | 2549 | ** appropriate default if no context width is specified. |
| 2550 | 2550 | */ |
| 2551 | 2551 | int diff_context_lines(DiffConfig *pCfg){ |
| 2552 | - int n = pCfg->diffFlags & DIFF_CONTEXT_MASK; | |
| 2553 | - if( n==0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5; | |
| 2552 | + int n = pCfg->nContext; | |
| 2553 | + if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5; | |
| 2554 | 2554 | return n; |
| 2555 | 2555 | } |
| 2556 | 2556 | |
| 2557 | 2557 | /* |
| 2558 | 2558 | ** Extract the width of columns for side-by-side diff. Supply an |
| @@ -2563,11 +2563,11 @@ | ||
| 2563 | 2563 | ** diff-col = lineno + lmargin + text-width + rmargin |
| 2564 | 2564 | ** |
| 2565 | 2565 | ** text-width = (term-width - diff-marker - 1)/2 - lineno - lmargin - rmargin |
| 2566 | 2566 | */ |
| 2567 | 2567 | int diff_width(DiffConfig *pCfg){ |
| 2568 | - int w = (pCfg->diffFlags & DIFF_WIDTH_MASK)/(DIFF_CONTEXT_MASK+1); | |
| 2568 | + int w = pCfg->wColumn; | |
| 2569 | 2569 | if( w==0 ){ |
| 2570 | 2570 | static struct { |
| 2571 | 2571 | unsigned int lineno, lmargin, text, rmargin, marker; |
| 2572 | 2572 | } sbsW = { 5, 2, 0, 0, 3 }; |
| 2573 | 2573 | const unsigned int wMin = 24, wMax = 132; |
| @@ -2749,20 +2749,20 @@ | ||
| 2749 | 2749 | ** |
| 2750 | 2750 | ** Process diff-related command-line options and return an appropriate |
| 2751 | 2751 | ** "diffFlags" integer. |
| 2752 | 2752 | ** |
| 2753 | 2753 | ** --brief Show filenames only DIFF_BRIEF |
| 2754 | -** -c|--context N N lines of context. DIFF_CONTEXT_MASK | |
| 2754 | +** -c|--context N N lines of context. nContext | |
| 2755 | 2755 | ** --html Format for HTML DIFF_HTML |
| 2756 | 2756 | ** --invert Invert the diff DIFF_INVERT |
| 2757 | 2757 | ** -n|--linenum Show line numbers DIFF_LINENO |
| 2758 | 2758 | ** --noopt Disable optimization DIFF_NOOPT |
| 2759 | 2759 | ** --numstat Show change counts DIFF_NUMSTAT |
| 2760 | 2760 | ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR |
| 2761 | 2761 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 2762 | 2762 | ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS |
| 2763 | -** -W|--width N N character lines. DIFF_WIDTH_MASK | |
| 2763 | +** -W|--width N N character lines. wColumn | |
| 2764 | 2764 | ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE |
| 2765 | 2765 | ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS |
| 2766 | 2766 | */ |
| 2767 | 2767 | void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){ |
| 2768 | 2768 | u64 diffFlags = 0; |
| @@ -2807,17 +2807,15 @@ | ||
| 2807 | 2807 | ** debugging and analysis: */ |
| 2808 | 2808 | if( find_option("debug",0,0)!=0 ) diffFlags |= DIFF_DEBUG; |
| 2809 | 2809 | if( find_option("raw",0,0)!=0 ) diffFlags |= DIFF_RAW; |
| 2810 | 2810 | } |
| 2811 | 2811 | if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){ |
| 2812 | - if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK; | |
| 2813 | - diffFlags |= f + DIFF_CONTEXT_EX; | |
| 2812 | + pCfg->nContext = f; | |
| 2813 | + diffFlags |= DIFF_CONTEXT_EX; | |
| 2814 | 2814 | } |
| 2815 | 2815 | if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){ |
| 2816 | - f *= DIFF_CONTEXT_MASK+1; | |
| 2817 | - if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK; | |
| 2818 | - diffFlags |= f; | |
| 2816 | + pCfg->wColumn = f; | |
| 2819 | 2817 | } |
| 2820 | 2818 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 2821 | 2819 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 2822 | 2820 | if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT; |
| 2823 | 2821 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 2824 | 2822 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -26,33 +26,31 @@ | |
| 26 | #if INTERFACE |
| 27 | /* |
| 28 | ** Flag parameters to the text_diff() routine used to control the formatting |
| 29 | ** of the diff output. |
| 30 | */ |
| 31 | #define DIFF_CONTEXT_MASK ((u64)0x0000ffff) /* Lines of context. Default if 0 */ |
| 32 | #define DIFF_WIDTH_MASK ((u64)0x00ff0000) /* side-by-side column width */ |
| 33 | #define DIFF_IGNORE_EOLWS ((u64)0x01000000) /* Ignore end-of-line whitespace */ |
| 34 | #define DIFF_IGNORE_ALLWS ((u64)0x03000000) /* Ignore all whitespace */ |
| 35 | #define DIFF_SIDEBYSIDE ((u64)0x04000000) /* Generate a side-by-side diff */ |
| 36 | #define DIFF_VERBOSE ((u64)0x08000000) /* Missing shown as empty files */ |
| 37 | #define DIFF_BRIEF ((u64)0x10000000) /* Show filenames only */ |
| 38 | #define DIFF_HTML ((u64)0x20000000) /* Render for HTML */ |
| 39 | #define DIFF_LINENO ((u64)0x40000000) /* Show line numbers */ |
| 40 | #define DIFF_NUMSTAT ((u64)0x80000000) /* Show line count of changes */ |
| 41 | #define DIFF_NOOPT (((u64)0x01)<<32) /* Suppress optimizations (debug) */ |
| 42 | #define DIFF_INVERT (((u64)0x02)<<32) /* Invert the diff (debug) */ |
| 43 | #define DIFF_CONTEXT_EX (((u64)0x04)<<32) /* Use context even if zero */ |
| 44 | #define DIFF_NOTTOOBIG (((u64)0x08)<<32) /* Only display if not too big */ |
| 45 | #define DIFF_STRIP_EOLCR (((u64)0x10)<<32) /* Strip trailing CR */ |
| 46 | #define DIFF_SLOW_SBS (((u64)0x20)<<32) /* Better but slower side-by-side */ |
| 47 | #define DIFF_WEBPAGE (((u64)0x00040)<<32) /* Complete webpage */ |
| 48 | #define DIFF_BROWSER (((u64)0x00080)<<32) /* The --browser option */ |
| 49 | #define DIFF_JSON (((u64)0x00100)<<32) /* JSON output */ |
| 50 | #define DIFF_DEBUG (((u64)0x00200)<<32) /* Debugging diff output */ |
| 51 | #define DIFF_RAW (((u64)0x00400)<<32) /* Raw triples - for debugging */ |
| 52 | #define DIFF_TCL (((u64)0x00800)<<32) /* For the --tk option */ |
| 53 | #define DIFF_INCBINARY (((u64)0x01000)<<32) /* The --diff-binary option */ |
| 54 | |
| 55 | /* |
| 56 | ** These error messages are shared in multiple locations. They are defined |
| 57 | ** here for consistency. |
| 58 | */ |
| @@ -92,10 +90,12 @@ | |
| 92 | ** |
| 93 | ** * Width of output columns for text side-by-side diffop |
| 94 | */ |
| 95 | struct DiffConfig { |
| 96 | u64 diffFlags; /* Diff flags */ |
| 97 | u32 nFile; /* Number of files diffed so far */ |
| 98 | const char *zDiffCmd; /* External diff command to use instead of builtin */ |
| 99 | const char *zBinGlob; /* GLOB pattern for binary files */ |
| 100 | ReCompiled *pRe; /* Show only changes matching this pattern */ |
| 101 | }; |
| @@ -2547,12 +2547,12 @@ | |
| 2547 | /* |
| 2548 | ** Extract the number of lines of context from diffFlags. Supply an |
| 2549 | ** appropriate default if no context width is specified. |
| 2550 | */ |
| 2551 | int diff_context_lines(DiffConfig *pCfg){ |
| 2552 | int n = pCfg->diffFlags & DIFF_CONTEXT_MASK; |
| 2553 | if( n==0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5; |
| 2554 | return n; |
| 2555 | } |
| 2556 | |
| 2557 | /* |
| 2558 | ** Extract the width of columns for side-by-side diff. Supply an |
| @@ -2563,11 +2563,11 @@ | |
| 2563 | ** diff-col = lineno + lmargin + text-width + rmargin |
| 2564 | ** |
| 2565 | ** text-width = (term-width - diff-marker - 1)/2 - lineno - lmargin - rmargin |
| 2566 | */ |
| 2567 | int diff_width(DiffConfig *pCfg){ |
| 2568 | int w = (pCfg->diffFlags & DIFF_WIDTH_MASK)/(DIFF_CONTEXT_MASK+1); |
| 2569 | if( w==0 ){ |
| 2570 | static struct { |
| 2571 | unsigned int lineno, lmargin, text, rmargin, marker; |
| 2572 | } sbsW = { 5, 2, 0, 0, 3 }; |
| 2573 | const unsigned int wMin = 24, wMax = 132; |
| @@ -2749,20 +2749,20 @@ | |
| 2749 | ** |
| 2750 | ** Process diff-related command-line options and return an appropriate |
| 2751 | ** "diffFlags" integer. |
| 2752 | ** |
| 2753 | ** --brief Show filenames only DIFF_BRIEF |
| 2754 | ** -c|--context N N lines of context. DIFF_CONTEXT_MASK |
| 2755 | ** --html Format for HTML DIFF_HTML |
| 2756 | ** --invert Invert the diff DIFF_INVERT |
| 2757 | ** -n|--linenum Show line numbers DIFF_LINENO |
| 2758 | ** --noopt Disable optimization DIFF_NOOPT |
| 2759 | ** --numstat Show change counts DIFF_NUMSTAT |
| 2760 | ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR |
| 2761 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 2762 | ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS |
| 2763 | ** -W|--width N N character lines. DIFF_WIDTH_MASK |
| 2764 | ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE |
| 2765 | ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS |
| 2766 | */ |
| 2767 | void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){ |
| 2768 | u64 diffFlags = 0; |
| @@ -2807,17 +2807,15 @@ | |
| 2807 | ** debugging and analysis: */ |
| 2808 | if( find_option("debug",0,0)!=0 ) diffFlags |= DIFF_DEBUG; |
| 2809 | if( find_option("raw",0,0)!=0 ) diffFlags |= DIFF_RAW; |
| 2810 | } |
| 2811 | if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){ |
| 2812 | if( f > DIFF_CONTEXT_MASK ) f = DIFF_CONTEXT_MASK; |
| 2813 | diffFlags |= f + DIFF_CONTEXT_EX; |
| 2814 | } |
| 2815 | if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){ |
| 2816 | f *= DIFF_CONTEXT_MASK+1; |
| 2817 | if( f > DIFF_WIDTH_MASK ) f = DIFF_CONTEXT_MASK; |
| 2818 | diffFlags |= f; |
| 2819 | } |
| 2820 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 2821 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 2822 | if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT; |
| 2823 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 2824 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -26,33 +26,31 @@ | |
| 26 | #if INTERFACE |
| 27 | /* |
| 28 | ** Flag parameters to the text_diff() routine used to control the formatting |
| 29 | ** of the diff output. |
| 30 | */ |
| 31 | #define DIFF_IGNORE_EOLWS 0x00000001 /* Ignore end-of-line whitespace */ |
| 32 | #define DIFF_IGNORE_ALLWS 0x00000003 /* Ignore all whitespace */ |
| 33 | #define DIFF_SIDEBYSIDE 0x00000004 /* Generate a side-by-side diff */ |
| 34 | #define DIFF_VERBOSE 0x00000008 /* Missing shown as empty files */ |
| 35 | #define DIFF_BRIEF 0x00000010 /* Show filenames only */ |
| 36 | #define DIFF_HTML 0x00000020 /* Render for HTML */ |
| 37 | #define DIFF_LINENO 0x00000040 /* Show line numbers */ |
| 38 | #define DIFF_NUMSTAT 0x00000080 /* Show line count of changes */ |
| 39 | #define DIFF_NOOPT 0x00000100 /* Suppress optimizations (debug) */ |
| 40 | #define DIFF_INVERT 0x00000200 /* Invert the diff (debug) */ |
| 41 | #define DIFF_CONTEXT_EX 0x00000400 /* Use context even if zero */ |
| 42 | #define DIFF_NOTTOOBIG 0x00000800 /* Only display if not too big */ |
| 43 | #define DIFF_STRIP_EOLCR 0x00001000 /* Strip trailing CR */ |
| 44 | #define DIFF_SLOW_SBS 0x00002000 /* Better but slower side-by-side */ |
| 45 | #define DIFF_WEBPAGE 0x00004000 /* Complete webpage */ |
| 46 | #define DIFF_BROWSER 0x00008000 /* The --browser option */ |
| 47 | #define DIFF_JSON 0x00010000 /* JSON output */ |
| 48 | #define DIFF_DEBUG 0x00020000 /* Debugging diff output */ |
| 49 | #define DIFF_RAW 0x00040000 /* Raw triples - for debugging */ |
| 50 | #define DIFF_TCL 0x00080000 /* For the --tk option */ |
| 51 | #define DIFF_INCBINARY 0x00100000 /* The --diff-binary option */ |
| 52 | |
| 53 | /* |
| 54 | ** These error messages are shared in multiple locations. They are defined |
| 55 | ** here for consistency. |
| 56 | */ |
| @@ -92,10 +90,12 @@ | |
| 90 | ** |
| 91 | ** * Width of output columns for text side-by-side diffop |
| 92 | */ |
| 93 | struct DiffConfig { |
| 94 | u64 diffFlags; /* Diff flags */ |
| 95 | int nContext; /* Number of lines of context */ |
| 96 | int wColumn; /* Column width in -y mode */ |
| 97 | u32 nFile; /* Number of files diffed so far */ |
| 98 | const char *zDiffCmd; /* External diff command to use instead of builtin */ |
| 99 | const char *zBinGlob; /* GLOB pattern for binary files */ |
| 100 | ReCompiled *pRe; /* Show only changes matching this pattern */ |
| 101 | }; |
| @@ -2547,12 +2547,12 @@ | |
| 2547 | /* |
| 2548 | ** Extract the number of lines of context from diffFlags. Supply an |
| 2549 | ** appropriate default if no context width is specified. |
| 2550 | */ |
| 2551 | int diff_context_lines(DiffConfig *pCfg){ |
| 2552 | int n = pCfg->nContext; |
| 2553 | if( n<=0 && (pCfg->diffFlags & DIFF_CONTEXT_EX)==0 ) n = 5; |
| 2554 | return n; |
| 2555 | } |
| 2556 | |
| 2557 | /* |
| 2558 | ** Extract the width of columns for side-by-side diff. Supply an |
| @@ -2563,11 +2563,11 @@ | |
| 2563 | ** diff-col = lineno + lmargin + text-width + rmargin |
| 2564 | ** |
| 2565 | ** text-width = (term-width - diff-marker - 1)/2 - lineno - lmargin - rmargin |
| 2566 | */ |
| 2567 | int diff_width(DiffConfig *pCfg){ |
| 2568 | int w = pCfg->wColumn; |
| 2569 | if( w==0 ){ |
| 2570 | static struct { |
| 2571 | unsigned int lineno, lmargin, text, rmargin, marker; |
| 2572 | } sbsW = { 5, 2, 0, 0, 3 }; |
| 2573 | const unsigned int wMin = 24, wMax = 132; |
| @@ -2749,20 +2749,20 @@ | |
| 2749 | ** |
| 2750 | ** Process diff-related command-line options and return an appropriate |
| 2751 | ** "diffFlags" integer. |
| 2752 | ** |
| 2753 | ** --brief Show filenames only DIFF_BRIEF |
| 2754 | ** -c|--context N N lines of context. nContext |
| 2755 | ** --html Format for HTML DIFF_HTML |
| 2756 | ** --invert Invert the diff DIFF_INVERT |
| 2757 | ** -n|--linenum Show line numbers DIFF_LINENO |
| 2758 | ** --noopt Disable optimization DIFF_NOOPT |
| 2759 | ** --numstat Show change counts DIFF_NUMSTAT |
| 2760 | ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR |
| 2761 | ** --unified Unified diff. ~DIFF_SIDEBYSIDE |
| 2762 | ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS |
| 2763 | ** -W|--width N N character lines. wColumn |
| 2764 | ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE |
| 2765 | ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS |
| 2766 | */ |
| 2767 | void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){ |
| 2768 | u64 diffFlags = 0; |
| @@ -2807,17 +2807,15 @@ | |
| 2807 | ** debugging and analysis: */ |
| 2808 | if( find_option("debug",0,0)!=0 ) diffFlags |= DIFF_DEBUG; |
| 2809 | if( find_option("raw",0,0)!=0 ) diffFlags |= DIFF_RAW; |
| 2810 | } |
| 2811 | if( (z = find_option("context","c",1))!=0 && (f = atoi(z))>=0 ){ |
| 2812 | pCfg->nContext = f; |
| 2813 | diffFlags |= DIFF_CONTEXT_EX; |
| 2814 | } |
| 2815 | if( (z = find_option("width","W",1))!=0 && (f = atoi(z))>0 ){ |
| 2816 | pCfg->wColumn = f; |
| 2817 | } |
| 2818 | if( find_option("linenum","n",0)!=0 ) diffFlags |= DIFF_LINENO; |
| 2819 | if( find_option("noopt",0,0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 2820 | if( find_option("numstat",0,0)!=0 ) diffFlags |= DIFF_NUMSTAT; |
| 2821 | if( find_option("invert",0,0)!=0 ) diffFlags |= DIFF_INVERT; |
| 2822 |
+8
-18
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -450,31 +450,21 @@ | ||
| 450 | 450 | */ |
| 451 | 451 | DiffConfig *construct_diff_flags(int diffType, DiffConfig *pCfg){ |
| 452 | 452 | u64 diffFlags = 0; /* Zero means do not show any diff */ |
| 453 | 453 | if( diffType>0 ){ |
| 454 | 454 | int x; |
| 455 | - if( diffType==2 ){ | |
| 456 | - diffFlags = DIFF_SIDEBYSIDE; | |
| 457 | - | |
| 458 | - /* "dw" query parameter determines width of each column */ | |
| 459 | - x = atoi(PD("dw","80"))*(DIFF_CONTEXT_MASK+1); | |
| 460 | - if( x<0 || x>DIFF_WIDTH_MASK ) x = DIFF_WIDTH_MASK; | |
| 461 | - diffFlags += x; | |
| 462 | - } | |
| 463 | - | |
| 464 | - if( P("w") ){ | |
| 465 | - diffFlags |= DIFF_IGNORE_ALLWS; | |
| 466 | - } | |
| 467 | - /* "dc" query parameter determines lines of context */ | |
| 468 | - x = atoi(PD("dc","7")); | |
| 469 | - if( x<0 || x>DIFF_CONTEXT_MASK ) x = DIFF_CONTEXT_MASK; | |
| 470 | - diffFlags += x; | |
| 471 | - | |
| 472 | - /* The "noopt" parameter disables diff optimization */ | |
| 455 | + if( diffType==2 ) diffFlags = DIFF_SIDEBYSIDE; | |
| 456 | + if( P("w") ) diffFlags |= DIFF_IGNORE_ALLWS; | |
| 473 | 457 | if( PD("noopt",0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 474 | 458 | diffFlags |= DIFF_STRIP_EOLCR; |
| 475 | 459 | diff_config_init(pCfg, diffFlags); |
| 460 | + | |
| 461 | + /* "dc" query parameter determines lines of context */ | |
| 462 | + x = atoi(PD("dc","7")); | |
| 463 | + if( x>0 ) pCfg->nContext = x; | |
| 464 | + | |
| 465 | + /* The "noopt" parameter disables diff optimization */ | |
| 476 | 466 | return pCfg; |
| 477 | 467 | }else{ |
| 478 | 468 | diff_config_init(pCfg, 0); |
| 479 | 469 | return 0; |
| 480 | 470 | } |
| 481 | 471 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -450,31 +450,21 @@ | |
| 450 | */ |
| 451 | DiffConfig *construct_diff_flags(int diffType, DiffConfig *pCfg){ |
| 452 | u64 diffFlags = 0; /* Zero means do not show any diff */ |
| 453 | if( diffType>0 ){ |
| 454 | int x; |
| 455 | if( diffType==2 ){ |
| 456 | diffFlags = DIFF_SIDEBYSIDE; |
| 457 | |
| 458 | /* "dw" query parameter determines width of each column */ |
| 459 | x = atoi(PD("dw","80"))*(DIFF_CONTEXT_MASK+1); |
| 460 | if( x<0 || x>DIFF_WIDTH_MASK ) x = DIFF_WIDTH_MASK; |
| 461 | diffFlags += x; |
| 462 | } |
| 463 | |
| 464 | if( P("w") ){ |
| 465 | diffFlags |= DIFF_IGNORE_ALLWS; |
| 466 | } |
| 467 | /* "dc" query parameter determines lines of context */ |
| 468 | x = atoi(PD("dc","7")); |
| 469 | if( x<0 || x>DIFF_CONTEXT_MASK ) x = DIFF_CONTEXT_MASK; |
| 470 | diffFlags += x; |
| 471 | |
| 472 | /* The "noopt" parameter disables diff optimization */ |
| 473 | if( PD("noopt",0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 474 | diffFlags |= DIFF_STRIP_EOLCR; |
| 475 | diff_config_init(pCfg, diffFlags); |
| 476 | return pCfg; |
| 477 | }else{ |
| 478 | diff_config_init(pCfg, 0); |
| 479 | return 0; |
| 480 | } |
| 481 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -450,31 +450,21 @@ | |
| 450 | */ |
| 451 | DiffConfig *construct_diff_flags(int diffType, DiffConfig *pCfg){ |
| 452 | u64 diffFlags = 0; /* Zero means do not show any diff */ |
| 453 | if( diffType>0 ){ |
| 454 | int x; |
| 455 | if( diffType==2 ) diffFlags = DIFF_SIDEBYSIDE; |
| 456 | if( P("w") ) diffFlags |= DIFF_IGNORE_ALLWS; |
| 457 | if( PD("noopt",0)!=0 ) diffFlags |= DIFF_NOOPT; |
| 458 | diffFlags |= DIFF_STRIP_EOLCR; |
| 459 | diff_config_init(pCfg, diffFlags); |
| 460 | |
| 461 | /* "dc" query parameter determines lines of context */ |
| 462 | x = atoi(PD("dc","7")); |
| 463 | if( x>0 ) pCfg->nContext = x; |
| 464 | |
| 465 | /* The "noopt" parameter disables diff optimization */ |
| 466 | return pCfg; |
| 467 | }else{ |
| 468 | diff_config_init(pCfg, 0); |
| 469 | return 0; |
| 470 | } |
| 471 |