Fossil SCM
More robust detection of top of a checkout in the dir_has_ckout_db() function.
Commit
36f916c504c525c72f48585e844aa6bfda22a401f3297d21611cb1fd0fecd041
Parent
c7bfa9636adf32d…
1 file changed
+4
+4
| --- src/file.c | ||
| +++ src/file.c | ||
| @@ -2973,19 +2973,23 @@ | ||
| 2973 | 2973 | ** Returns 1 if the given directory contains a file named .fslckout, 2 |
| 2974 | 2974 | ** if it contains a file named _FOSSIL_, else returns 0. |
| 2975 | 2975 | */ |
| 2976 | 2976 | int dir_has_ckout_db(const char *zDir){ |
| 2977 | 2977 | int rc = 0; |
| 2978 | + i64 sz; | |
| 2978 | 2979 | char * zCkoutDb = mprintf("%//.fslckout", zDir); |
| 2979 | 2980 | if(file_isfile(zCkoutDb, ExtFILE)){ |
| 2980 | 2981 | rc = 1; |
| 2981 | 2982 | }else{ |
| 2982 | 2983 | fossil_free(zCkoutDb); |
| 2983 | 2984 | zCkoutDb = mprintf("%//_FOSSIL_", zDir); |
| 2984 | 2985 | if(file_isfile(zCkoutDb, ExtFILE)){ |
| 2985 | 2986 | rc = 2; |
| 2986 | 2987 | } |
| 2988 | + } | |
| 2989 | + if( rc && ((sz = file_size(zCkoutDb, ExtFILE))<1024 || (sz%512)!=0) ){ | |
| 2990 | + rc = 0; | |
| 2987 | 2991 | } |
| 2988 | 2992 | fossil_free(zCkoutDb); |
| 2989 | 2993 | return rc; |
| 2990 | 2994 | } |
| 2991 | 2995 | |
| 2992 | 2996 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -2973,19 +2973,23 @@ | |
| 2973 | ** Returns 1 if the given directory contains a file named .fslckout, 2 |
| 2974 | ** if it contains a file named _FOSSIL_, else returns 0. |
| 2975 | */ |
| 2976 | int dir_has_ckout_db(const char *zDir){ |
| 2977 | int rc = 0; |
| 2978 | char * zCkoutDb = mprintf("%//.fslckout", zDir); |
| 2979 | if(file_isfile(zCkoutDb, ExtFILE)){ |
| 2980 | rc = 1; |
| 2981 | }else{ |
| 2982 | fossil_free(zCkoutDb); |
| 2983 | zCkoutDb = mprintf("%//_FOSSIL_", zDir); |
| 2984 | if(file_isfile(zCkoutDb, ExtFILE)){ |
| 2985 | rc = 2; |
| 2986 | } |
| 2987 | } |
| 2988 | fossil_free(zCkoutDb); |
| 2989 | return rc; |
| 2990 | } |
| 2991 | |
| 2992 |
| --- src/file.c | |
| +++ src/file.c | |
| @@ -2973,19 +2973,23 @@ | |
| 2973 | ** Returns 1 if the given directory contains a file named .fslckout, 2 |
| 2974 | ** if it contains a file named _FOSSIL_, else returns 0. |
| 2975 | */ |
| 2976 | int dir_has_ckout_db(const char *zDir){ |
| 2977 | int rc = 0; |
| 2978 | i64 sz; |
| 2979 | char * zCkoutDb = mprintf("%//.fslckout", zDir); |
| 2980 | if(file_isfile(zCkoutDb, ExtFILE)){ |
| 2981 | rc = 1; |
| 2982 | }else{ |
| 2983 | fossil_free(zCkoutDb); |
| 2984 | zCkoutDb = mprintf("%//_FOSSIL_", zDir); |
| 2985 | if(file_isfile(zCkoutDb, ExtFILE)){ |
| 2986 | rc = 2; |
| 2987 | } |
| 2988 | } |
| 2989 | if( rc && ((sz = file_size(zCkoutDb, ExtFILE))<1024 || (sz%512)!=0) ){ |
| 2990 | rc = 0; |
| 2991 | } |
| 2992 | fossil_free(zCkoutDb); |
| 2993 | return rc; |
| 2994 | } |
| 2995 | |
| 2996 |