Fossil SCM
Simplify branch changes. The historical_version_of_file() function appears to return ^>0 upon success. Also, remove superfluous slash from '.fossil-settings' path construction in print_setting().
Commit
20972e8042763226ad6b6a0a02656566ae1324c4
Parent
6a4c3c5ee207558…
1 file changed
+20
-12
M
src/db.c
+20
-12
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1913,49 +1913,57 @@ | ||
| 1913 | 1913 | } |
| 1914 | 1914 | cacheEntry = cacheEntry->next; |
| 1915 | 1915 | } |
| 1916 | 1916 | /* Attempt to read value from file in checkout if there wasn't a cache hit. */ |
| 1917 | 1917 | if( cacheEntry==0 ){ |
| 1918 | - Blob setting; | |
| 1919 | 1918 | Blob versionedPathname; |
| 1920 | - char *zVersionedPathname; | |
| 1919 | + Blob setting; | |
| 1921 | 1920 | blob_zero(&versionedPathname); |
| 1921 | + blob_zero(&setting); | |
| 1922 | 1922 | blob_appendf(&versionedPathname, "%s.fossil-settings/%s", |
| 1923 | 1923 | g.zLocalRoot, zName); |
| 1924 | - zVersionedPathname = blob_str(&versionedPathname); | |
| 1925 | - blob_zero(&setting); | |
| 1926 | 1924 | if( !g.localOpen ){ |
| 1927 | - if( historical_version_of_file(g.zOpenRevision, zVersionedPathname, | |
| 1928 | - &setting, 0, 0, 0, -1)!=-1 ){ | |
| 1925 | + Blob noWarnFile; | |
| 1926 | + if( historical_version_of_file(g.zOpenRevision, | |
| 1927 | + blob_str(&versionedPathname), | |
| 1928 | + &setting, 0, 0, 0, -1)>0 ){ | |
| 1929 | 1929 | found = 1; |
| 1930 | 1930 | } |
| 1931 | - noWarn = 1; | |
| 1932 | - }else if( file_size(zVersionedPathname)>=0 ){ | |
| 1931 | + /* See if there's a no-warn flag */ | |
| 1932 | + blob_append(&versionedPathname, ".no-warn", -1); | |
| 1933 | + blob_zero(&noWarnFile); | |
| 1934 | + if( historical_version_of_file(g.zOpenRevision, | |
| 1935 | + blob_str(&versionedPathname), | |
| 1936 | + &noWarnFile, 0, 0, 0, -1)>0 ){ | |
| 1937 | + noWarn = 1; | |
| 1938 | + } | |
| 1939 | + blob_reset(&noWarnFile); | |
| 1940 | + }else if( file_size(blob_str(&versionedPathname))>=0 ){ | |
| 1933 | 1941 | /* File exists, and contains the value for this setting. Load from |
| 1934 | 1942 | ** the file. */ |
| 1935 | - if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){ | |
| 1943 | + if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){ | |
| 1936 | 1944 | found = 1; |
| 1937 | 1945 | } |
| 1938 | 1946 | /* See if there's a no-warn flag */ |
| 1939 | 1947 | blob_append(&versionedPathname, ".no-warn", -1); |
| 1940 | 1948 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1941 | 1949 | noWarn = 1; |
| 1942 | 1950 | } |
| 1943 | 1951 | } |
| 1952 | + blob_reset(&versionedPathname); | |
| 1944 | 1953 | if( found ){ |
| 1945 | 1954 | blob_trim(&setting); /* Avoid non-obvious problems with line endings |
| 1946 | 1955 | ** on boolean properties */ |
| 1947 | 1956 | zVersionedSetting = strdup(blob_str(&setting)); |
| 1948 | 1957 | } |
| 1949 | - blob_reset(&versionedPathname); | |
| 1958 | + blob_reset(&setting); | |
| 1950 | 1959 | /* Store result in cache, which can be the value or 0 if not found */ |
| 1951 | 1960 | cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry)); |
| 1952 | 1961 | cacheEntry->next = cache; |
| 1953 | 1962 | cacheEntry->zName = zName; |
| 1954 | 1963 | cacheEntry->zValue = fossil_strdup(zVersionedSetting); |
| 1955 | 1964 | cache = cacheEntry; |
| 1956 | - blob_reset(&setting); | |
| 1957 | 1965 | } |
| 1958 | 1966 | /* Display a warning? */ |
| 1959 | 1967 | if( zVersionedSetting!=0 && zNonVersionedSetting!=0 |
| 1960 | 1968 | && zNonVersionedSetting[0]!='\0' && !noWarn |
| 1961 | 1969 | ){ |
| @@ -2307,11 +2315,11 @@ | ||
| 2307 | 2315 | } |
| 2308 | 2316 | if( pSetting->versionable && g.localOpen ){ |
| 2309 | 2317 | /* Check to see if this is overridden by a versionable settings file */ |
| 2310 | 2318 | Blob versionedPathname; |
| 2311 | 2319 | blob_zero(&versionedPathname); |
| 2312 | - blob_appendf(&versionedPathname, "%s/.fossil-settings/%s", | |
| 2320 | + blob_appendf(&versionedPathname, "%s.fossil-settings/%s", | |
| 2313 | 2321 | g.zLocalRoot, pSetting->name); |
| 2314 | 2322 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 2315 | 2323 | fossil_print(" (overridden by contents of file .fossil-settings/%s)\n", |
| 2316 | 2324 | pSetting->name); |
| 2317 | 2325 | } |
| 2318 | 2326 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1913,49 +1913,57 @@ | |
| 1913 | } |
| 1914 | cacheEntry = cacheEntry->next; |
| 1915 | } |
| 1916 | /* Attempt to read value from file in checkout if there wasn't a cache hit. */ |
| 1917 | if( cacheEntry==0 ){ |
| 1918 | Blob setting; |
| 1919 | Blob versionedPathname; |
| 1920 | char *zVersionedPathname; |
| 1921 | blob_zero(&versionedPathname); |
| 1922 | blob_appendf(&versionedPathname, "%s.fossil-settings/%s", |
| 1923 | g.zLocalRoot, zName); |
| 1924 | zVersionedPathname = blob_str(&versionedPathname); |
| 1925 | blob_zero(&setting); |
| 1926 | if( !g.localOpen ){ |
| 1927 | if( historical_version_of_file(g.zOpenRevision, zVersionedPathname, |
| 1928 | &setting, 0, 0, 0, -1)!=-1 ){ |
| 1929 | found = 1; |
| 1930 | } |
| 1931 | noWarn = 1; |
| 1932 | }else if( file_size(zVersionedPathname)>=0 ){ |
| 1933 | /* File exists, and contains the value for this setting. Load from |
| 1934 | ** the file. */ |
| 1935 | if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){ |
| 1936 | found = 1; |
| 1937 | } |
| 1938 | /* See if there's a no-warn flag */ |
| 1939 | blob_append(&versionedPathname, ".no-warn", -1); |
| 1940 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1941 | noWarn = 1; |
| 1942 | } |
| 1943 | } |
| 1944 | if( found ){ |
| 1945 | blob_trim(&setting); /* Avoid non-obvious problems with line endings |
| 1946 | ** on boolean properties */ |
| 1947 | zVersionedSetting = strdup(blob_str(&setting)); |
| 1948 | } |
| 1949 | blob_reset(&versionedPathname); |
| 1950 | /* Store result in cache, which can be the value or 0 if not found */ |
| 1951 | cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry)); |
| 1952 | cacheEntry->next = cache; |
| 1953 | cacheEntry->zName = zName; |
| 1954 | cacheEntry->zValue = fossil_strdup(zVersionedSetting); |
| 1955 | cache = cacheEntry; |
| 1956 | blob_reset(&setting); |
| 1957 | } |
| 1958 | /* Display a warning? */ |
| 1959 | if( zVersionedSetting!=0 && zNonVersionedSetting!=0 |
| 1960 | && zNonVersionedSetting[0]!='\0' && !noWarn |
| 1961 | ){ |
| @@ -2307,11 +2315,11 @@ | |
| 2307 | } |
| 2308 | if( pSetting->versionable && g.localOpen ){ |
| 2309 | /* Check to see if this is overridden by a versionable settings file */ |
| 2310 | Blob versionedPathname; |
| 2311 | blob_zero(&versionedPathname); |
| 2312 | blob_appendf(&versionedPathname, "%s/.fossil-settings/%s", |
| 2313 | g.zLocalRoot, pSetting->name); |
| 2314 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 2315 | fossil_print(" (overridden by contents of file .fossil-settings/%s)\n", |
| 2316 | pSetting->name); |
| 2317 | } |
| 2318 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -1913,49 +1913,57 @@ | |
| 1913 | } |
| 1914 | cacheEntry = cacheEntry->next; |
| 1915 | } |
| 1916 | /* Attempt to read value from file in checkout if there wasn't a cache hit. */ |
| 1917 | if( cacheEntry==0 ){ |
| 1918 | Blob versionedPathname; |
| 1919 | Blob setting; |
| 1920 | blob_zero(&versionedPathname); |
| 1921 | blob_zero(&setting); |
| 1922 | blob_appendf(&versionedPathname, "%s.fossil-settings/%s", |
| 1923 | g.zLocalRoot, zName); |
| 1924 | if( !g.localOpen ){ |
| 1925 | Blob noWarnFile; |
| 1926 | if( historical_version_of_file(g.zOpenRevision, |
| 1927 | blob_str(&versionedPathname), |
| 1928 | &setting, 0, 0, 0, -1)>0 ){ |
| 1929 | found = 1; |
| 1930 | } |
| 1931 | /* See if there's a no-warn flag */ |
| 1932 | blob_append(&versionedPathname, ".no-warn", -1); |
| 1933 | blob_zero(&noWarnFile); |
| 1934 | if( historical_version_of_file(g.zOpenRevision, |
| 1935 | blob_str(&versionedPathname), |
| 1936 | &noWarnFile, 0, 0, 0, -1)>0 ){ |
| 1937 | noWarn = 1; |
| 1938 | } |
| 1939 | blob_reset(&noWarnFile); |
| 1940 | }else if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1941 | /* File exists, and contains the value for this setting. Load from |
| 1942 | ** the file. */ |
| 1943 | if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){ |
| 1944 | found = 1; |
| 1945 | } |
| 1946 | /* See if there's a no-warn flag */ |
| 1947 | blob_append(&versionedPathname, ".no-warn", -1); |
| 1948 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 1949 | noWarn = 1; |
| 1950 | } |
| 1951 | } |
| 1952 | blob_reset(&versionedPathname); |
| 1953 | if( found ){ |
| 1954 | blob_trim(&setting); /* Avoid non-obvious problems with line endings |
| 1955 | ** on boolean properties */ |
| 1956 | zVersionedSetting = strdup(blob_str(&setting)); |
| 1957 | } |
| 1958 | blob_reset(&setting); |
| 1959 | /* Store result in cache, which can be the value or 0 if not found */ |
| 1960 | cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry)); |
| 1961 | cacheEntry->next = cache; |
| 1962 | cacheEntry->zName = zName; |
| 1963 | cacheEntry->zValue = fossil_strdup(zVersionedSetting); |
| 1964 | cache = cacheEntry; |
| 1965 | } |
| 1966 | /* Display a warning? */ |
| 1967 | if( zVersionedSetting!=0 && zNonVersionedSetting!=0 |
| 1968 | && zNonVersionedSetting[0]!='\0' && !noWarn |
| 1969 | ){ |
| @@ -2307,11 +2315,11 @@ | |
| 2315 | } |
| 2316 | if( pSetting->versionable && g.localOpen ){ |
| 2317 | /* Check to see if this is overridden by a versionable settings file */ |
| 2318 | Blob versionedPathname; |
| 2319 | blob_zero(&versionedPathname); |
| 2320 | blob_appendf(&versionedPathname, "%s.fossil-settings/%s", |
| 2321 | g.zLocalRoot, pSetting->name); |
| 2322 | if( file_size(blob_str(&versionedPathname))>=0 ){ |
| 2323 | fossil_print(" (overridden by contents of file .fossil-settings/%s)\n", |
| 2324 | pSetting->name); |
| 2325 | } |
| 2326 |