Fossil SCM

Add the (user whoami) subcommand, which figures out who you are via db_find_and_open_repository(). In response to [forum:a174e200b018abbd | forum thread a174e200b018abbd].

stephan 2025-08-02 17:56 trunk
Commit a06df610c99bdf5c016c765651cf6b7eaf13aa5e265777279724006b45b744fd
1 file changed +5 -1
+5 -1
--- src/user.c
+++ src/user.c
@@ -503,13 +503,17 @@
503503
g.argv[4], uid
504504
);
505505
db_protect_pop();
506506
}
507507
fossil_print("%s\n", db_text(0, "SELECT info FROM user WHERE uid=%d", uid));
508
+ }else if( n==6 && strncmp(g.argv[2], "whoami", 6)==0 ){
509
+ db_find_and_open_repository(0,0);
510
+ user_select();
511
+ fossil_print("%s\n", g.zLogin);
508512
}else{
509513
fossil_fatal("user subcommand should be one of: "
510
- "capabilities contact default list new password");
514
+ "capabilities contact default list new password whoami");
511515
}
512516
}
513517
514518
/*
515519
** Attempt to set the user to zLogin
516520
--- src/user.c
+++ src/user.c
@@ -503,13 +503,17 @@
503 g.argv[4], uid
504 );
505 db_protect_pop();
506 }
507 fossil_print("%s\n", db_text(0, "SELECT info FROM user WHERE uid=%d", uid));
 
 
 
 
508 }else{
509 fossil_fatal("user subcommand should be one of: "
510 "capabilities contact default list new password");
511 }
512 }
513
514 /*
515 ** Attempt to set the user to zLogin
516
--- src/user.c
+++ src/user.c
@@ -503,13 +503,17 @@
503 g.argv[4], uid
504 );
505 db_protect_pop();
506 }
507 fossil_print("%s\n", db_text(0, "SELECT info FROM user WHERE uid=%d", uid));
508 }else if( n==6 && strncmp(g.argv[2], "whoami", 6)==0 ){
509 db_find_and_open_repository(0,0);
510 user_select();
511 fossil_print("%s\n", g.zLogin);
512 }else{
513 fossil_fatal("user subcommand should be one of: "
514 "capabilities contact default list new password whoami");
515 }
516 }
517
518 /*
519 ** Attempt to set the user to zLogin
520

Keyboard Shortcuts

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