Fossil SCM

Fix the "test-ssh-needs-path" command so that it works even if run from outside of an open check-out.

drh 2024-02-07 15:11 trunk
Commit 46e7855a4e19200ecde8772f0e988712467b1d29129776eb18221a3d0660a1c0
1 file changed +5 -2
+5 -2
--- src/http.c
+++ src/http.c
@@ -312,27 +312,30 @@
312312
** change the value.
313313
**
314314
** With no arguments, show all hosts for which ssh-needs-path is true.
315315
*/
316316
void test_ssh_needs_path(void){
317
- db_find_and_open_repository(0,0);
317
+ db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0);
318
+ db_open_config(0,0);
318319
if( g.argc>=3 ){
319320
const char *zHost = g.argv[2];
320321
int a = -1;
321322
int rc;
322323
if( g.argc>=4 ) a = is_truth(g.argv[3]);
323324
rc = ssh_needs_path_argument(zHost, a);
324325
fossil_print("%-20s %s\n", zHost, rc ? "yes" : "no");
325326
}else{
326327
Stmt s;
327
- db_prepare(&s, "SELECT substr(name,18) FROM config"
328
+ db_swap_connections();
329
+ db_prepare(&s, "SELECT substr(name,18) FROM global_config"
328330
" WHERE name GLOB 'use-path-for-ssh:*'");
329331
while( db_step(&s)==SQLITE_ROW ){
330332
const char *zHost = db_column_text(&s,0);
331333
fossil_print("%-20s yes\n", zHost);
332334
}
333335
db_finalize(&s);
336
+ db_swap_connections();
334337
}
335338
}
336339
337340
/* Add an approprate PATH= argument to the SSH command under construction
338341
** in pCmd.
339342
--- src/http.c
+++ src/http.c
@@ -312,27 +312,30 @@
312 ** change the value.
313 **
314 ** With no arguments, show all hosts for which ssh-needs-path is true.
315 */
316 void test_ssh_needs_path(void){
317 db_find_and_open_repository(0,0);
 
318 if( g.argc>=3 ){
319 const char *zHost = g.argv[2];
320 int a = -1;
321 int rc;
322 if( g.argc>=4 ) a = is_truth(g.argv[3]);
323 rc = ssh_needs_path_argument(zHost, a);
324 fossil_print("%-20s %s\n", zHost, rc ? "yes" : "no");
325 }else{
326 Stmt s;
327 db_prepare(&s, "SELECT substr(name,18) FROM config"
 
328 " WHERE name GLOB 'use-path-for-ssh:*'");
329 while( db_step(&s)==SQLITE_ROW ){
330 const char *zHost = db_column_text(&s,0);
331 fossil_print("%-20s yes\n", zHost);
332 }
333 db_finalize(&s);
 
334 }
335 }
336
337 /* Add an approprate PATH= argument to the SSH command under construction
338 ** in pCmd.
339
--- src/http.c
+++ src/http.c
@@ -312,27 +312,30 @@
312 ** change the value.
313 **
314 ** With no arguments, show all hosts for which ssh-needs-path is true.
315 */
316 void test_ssh_needs_path(void){
317 db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0);
318 db_open_config(0,0);
319 if( g.argc>=3 ){
320 const char *zHost = g.argv[2];
321 int a = -1;
322 int rc;
323 if( g.argc>=4 ) a = is_truth(g.argv[3]);
324 rc = ssh_needs_path_argument(zHost, a);
325 fossil_print("%-20s %s\n", zHost, rc ? "yes" : "no");
326 }else{
327 Stmt s;
328 db_swap_connections();
329 db_prepare(&s, "SELECT substr(name,18) FROM global_config"
330 " WHERE name GLOB 'use-path-for-ssh:*'");
331 while( db_step(&s)==SQLITE_ROW ){
332 const char *zHost = db_column_text(&s,0);
333 fossil_print("%-20s yes\n", zHost);
334 }
335 db_finalize(&s);
336 db_swap_connections();
337 }
338 }
339
340 /* Add an approprate PATH= argument to the SSH command under construction
341 ** in pCmd.
342

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button