Fossil SCM
less abstract, closer to affected (clone, init/new) subcommands
Commit
b0a3bfb03850dd07ab5e94ce6e848e5555fea0e8
Parent
bb15d408a4d68f8…
2 files changed
+7
+6
-6
+7
| --- src/clone.c | ||
| +++ src/clone.c | ||
| @@ -121,10 +121,11 @@ | ||
| 121 | 121 | const char *zDefaultUser; /* Optional name of the default user */ |
| 122 | 122 | const char *zHttpAuth; /* HTTP Authorization user:pass information */ |
| 123 | 123 | int nErr = 0; |
| 124 | 124 | int urlFlags = URL_PROMPT_PW | URL_REMEMBER; |
| 125 | 125 | int syncFlags = SYNC_CLONE; |
| 126 | + struct stat sb; | |
| 126 | 127 | |
| 127 | 128 | /* Also clone private branches */ |
| 128 | 129 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 129 | 130 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| 130 | 131 | if( find_option("verbose",0,0)!=0) syncFlags |= SYNC_VERBOSE; |
| @@ -143,10 +144,16 @@ | ||
| 143 | 144 | if( file_size(g.argv[3])>0 ){ |
| 144 | 145 | fossil_fatal("file already exists: %s", g.argv[3]); |
| 145 | 146 | } |
| 146 | 147 | |
| 147 | 148 | url_parse(g.argv[2], urlFlags); |
| 149 | + | |
| 150 | + if (0 == stat(zDbName, &sb)) { | |
| 151 | + db_err("[%s]: %s", zDbName, "File already exists."); | |
| 152 | + } | |
| 153 | + | |
| 154 | + | |
| 148 | 155 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 149 | 156 | if( g.url.isFile ){ |
| 150 | 157 | file_copy(g.url.name, g.argv[3]); |
| 151 | 158 | db_close(1); |
| 152 | 159 | db_open_repository(g.argv[3]); |
| 153 | 160 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -121,10 +121,11 @@ | |
| 121 | const char *zDefaultUser; /* Optional name of the default user */ |
| 122 | const char *zHttpAuth; /* HTTP Authorization user:pass information */ |
| 123 | int nErr = 0; |
| 124 | int urlFlags = URL_PROMPT_PW | URL_REMEMBER; |
| 125 | int syncFlags = SYNC_CLONE; |
| 126 | |
| 127 | /* Also clone private branches */ |
| 128 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 129 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| 130 | if( find_option("verbose",0,0)!=0) syncFlags |= SYNC_VERBOSE; |
| @@ -143,10 +144,16 @@ | |
| 143 | if( file_size(g.argv[3])>0 ){ |
| 144 | fossil_fatal("file already exists: %s", g.argv[3]); |
| 145 | } |
| 146 | |
| 147 | url_parse(g.argv[2], urlFlags); |
| 148 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 149 | if( g.url.isFile ){ |
| 150 | file_copy(g.url.name, g.argv[3]); |
| 151 | db_close(1); |
| 152 | db_open_repository(g.argv[3]); |
| 153 |
| --- src/clone.c | |
| +++ src/clone.c | |
| @@ -121,10 +121,11 @@ | |
| 121 | const char *zDefaultUser; /* Optional name of the default user */ |
| 122 | const char *zHttpAuth; /* HTTP Authorization user:pass information */ |
| 123 | int nErr = 0; |
| 124 | int urlFlags = URL_PROMPT_PW | URL_REMEMBER; |
| 125 | int syncFlags = SYNC_CLONE; |
| 126 | struct stat sb; |
| 127 | |
| 128 | /* Also clone private branches */ |
| 129 | if( find_option("private",0,0)!=0 ) syncFlags |= SYNC_PRIVATE; |
| 130 | if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER; |
| 131 | if( find_option("verbose",0,0)!=0) syncFlags |= SYNC_VERBOSE; |
| @@ -143,10 +144,16 @@ | |
| 144 | if( file_size(g.argv[3])>0 ){ |
| 145 | fossil_fatal("file already exists: %s", g.argv[3]); |
| 146 | } |
| 147 | |
| 148 | url_parse(g.argv[2], urlFlags); |
| 149 | |
| 150 | if (0 == stat(zDbName, &sb)) { |
| 151 | db_err("[%s]: %s", zDbName, "File already exists."); |
| 152 | } |
| 153 | |
| 154 | |
| 155 | if( zDefaultUser==0 && g.url.user!=0 ) zDefaultUser = g.url.user; |
| 156 | if( g.url.isFile ){ |
| 157 | file_copy(g.url.name, g.argv[3]); |
| 158 | db_close(1); |
| 159 | db_open_repository(g.argv[3]); |
| 160 |
M
src/db.c
+6
-6
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -817,18 +817,12 @@ | ||
| 817 | 817 | ** connection. An error results in process abort. |
| 818 | 818 | */ |
| 819 | 819 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 820 | 820 | int rc; |
| 821 | 821 | sqlite3 *db; |
| 822 | - struct stat sb; | |
| 823 | 822 | |
| 824 | 823 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 825 | - | |
| 826 | - if (0 == stat(zDbName, &sb)) { | |
| 827 | - db_err("[%s]: %s", zDbName, "File already exists."); | |
| 828 | - } | |
| 829 | - | |
| 830 | 824 | rc = sqlite3_open_v2( |
| 831 | 825 | zDbName, &db, |
| 832 | 826 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 833 | 827 | g.zVfsName |
| 834 | 828 | ); |
| @@ -1675,10 +1669,11 @@ | ||
| 1675 | 1669 | char *zPassword; |
| 1676 | 1670 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1677 | 1671 | const char *zDate; /* Date of the initial check-in */ |
| 1678 | 1672 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1679 | 1673 | int makeServerCodes; |
| 1674 | + struct stat sb; | |
| 1680 | 1675 | |
| 1681 | 1676 | zTemplate = find_option("template",0,1); |
| 1682 | 1677 | zDate = find_option("date-override",0,1); |
| 1683 | 1678 | zDefaultUser = find_option("admin-user","A",1); |
| 1684 | 1679 | makeServerCodes = find_option("docker", 0, 0)==0; |
| @@ -1688,10 +1683,15 @@ | ||
| 1688 | 1683 | verify_all_options(); |
| 1689 | 1684 | |
| 1690 | 1685 | if( g.argc!=3 ){ |
| 1691 | 1686 | usage("REPOSITORY-NAME"); |
| 1692 | 1687 | } |
| 1688 | + | |
| 1689 | + if (0 == stat(zDbName, &sb)) { | |
| 1690 | + db_err("[%s]: %s", zDbName, "File already exists."); | |
| 1691 | + } | |
| 1692 | + | |
| 1693 | 1693 | db_create_repository(g.argv[2]); |
| 1694 | 1694 | db_open_repository(g.argv[2]); |
| 1695 | 1695 | db_open_config(0); |
| 1696 | 1696 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1697 | 1697 | db_begin_transaction(); |
| 1698 | 1698 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -817,18 +817,12 @@ | |
| 817 | ** connection. An error results in process abort. |
| 818 | */ |
| 819 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 820 | int rc; |
| 821 | sqlite3 *db; |
| 822 | struct stat sb; |
| 823 | |
| 824 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 825 | |
| 826 | if (0 == stat(zDbName, &sb)) { |
| 827 | db_err("[%s]: %s", zDbName, "File already exists."); |
| 828 | } |
| 829 | |
| 830 | rc = sqlite3_open_v2( |
| 831 | zDbName, &db, |
| 832 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 833 | g.zVfsName |
| 834 | ); |
| @@ -1675,10 +1669,11 @@ | |
| 1675 | char *zPassword; |
| 1676 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1677 | const char *zDate; /* Date of the initial check-in */ |
| 1678 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1679 | int makeServerCodes; |
| 1680 | |
| 1681 | zTemplate = find_option("template",0,1); |
| 1682 | zDate = find_option("date-override",0,1); |
| 1683 | zDefaultUser = find_option("admin-user","A",1); |
| 1684 | makeServerCodes = find_option("docker", 0, 0)==0; |
| @@ -1688,10 +1683,15 @@ | |
| 1688 | verify_all_options(); |
| 1689 | |
| 1690 | if( g.argc!=3 ){ |
| 1691 | usage("REPOSITORY-NAME"); |
| 1692 | } |
| 1693 | db_create_repository(g.argv[2]); |
| 1694 | db_open_repository(g.argv[2]); |
| 1695 | db_open_config(0); |
| 1696 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1697 | db_begin_transaction(); |
| 1698 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -817,18 +817,12 @@ | |
| 817 | ** connection. An error results in process abort. |
| 818 | */ |
| 819 | LOCAL sqlite3 *db_open(const char *zDbName){ |
| 820 | int rc; |
| 821 | sqlite3 *db; |
| 822 | |
| 823 | if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName); |
| 824 | rc = sqlite3_open_v2( |
| 825 | zDbName, &db, |
| 826 | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
| 827 | g.zVfsName |
| 828 | ); |
| @@ -1675,10 +1669,11 @@ | |
| 1669 | char *zPassword; |
| 1670 | const char *zTemplate; /* Repository from which to copy settings */ |
| 1671 | const char *zDate; /* Date of the initial check-in */ |
| 1672 | const char *zDefaultUser; /* Optional name of the default user */ |
| 1673 | int makeServerCodes; |
| 1674 | struct stat sb; |
| 1675 | |
| 1676 | zTemplate = find_option("template",0,1); |
| 1677 | zDate = find_option("date-override",0,1); |
| 1678 | zDefaultUser = find_option("admin-user","A",1); |
| 1679 | makeServerCodes = find_option("docker", 0, 0)==0; |
| @@ -1688,10 +1683,15 @@ | |
| 1683 | verify_all_options(); |
| 1684 | |
| 1685 | if( g.argc!=3 ){ |
| 1686 | usage("REPOSITORY-NAME"); |
| 1687 | } |
| 1688 | |
| 1689 | if (0 == stat(zDbName, &sb)) { |
| 1690 | db_err("[%s]: %s", zDbName, "File already exists."); |
| 1691 | } |
| 1692 | |
| 1693 | db_create_repository(g.argv[2]); |
| 1694 | db_open_repository(g.argv[2]); |
| 1695 | db_open_config(0); |
| 1696 | if( zTemplate ) db_attach(zTemplate, "settingSrc"); |
| 1697 | db_begin_transaction(); |
| 1698 |