Fossil SCM
When attempting to determine the Fossil user information, do not smash the global URL information which may contain an alternate URL used for sync operations (e.g. when using 'fossil sync --once'). This fixes the ability to work offline and synchronize with a USB thumbdrive ala sneaker-net.
Commit
b9e36291f72703fa8c0aad2f713f778bf7fde146920f98f9cf9621ef01521fcf
Parent
ff9dbf369816e99…
1 file changed
+4
-2
+4
-2
| --- src/user.c | ||
| +++ src/user.c | ||
| @@ -498,10 +498,11 @@ | ||
| 498 | 498 | ** (8) Check if the user can be extracted from the remote URL. |
| 499 | 499 | ** |
| 500 | 500 | ** The user name is stored in g.zLogin. The uid is in g.userUid. |
| 501 | 501 | */ |
| 502 | 502 | void user_select(void){ |
| 503 | + UrlData url; | |
| 503 | 504 | if( g.userUid ) return; |
| 504 | 505 | if( g.zLogin ){ |
| 505 | 506 | if( attempt_user(g.zLogin)==0 ){ |
| 506 | 507 | fossil_fatal("no such user: %s", g.zLogin); |
| 507 | 508 | }else{ |
| @@ -519,12 +520,13 @@ | ||
| 519 | 520 | |
| 520 | 521 | if( attempt_user(fossil_getenv("LOGNAME")) ) return; |
| 521 | 522 | |
| 522 | 523 | if( attempt_user(fossil_getenv("USERNAME")) ) return; |
| 523 | 524 | |
| 524 | - url_parse(0, 0); | |
| 525 | - if( g.url.user && attempt_user(g.url.user) ) return; | |
| 525 | + memset(&url, 0, sizeof(url)); | |
| 526 | + url_parse_local(0, 0, &url); | |
| 527 | + if( url.user && attempt_user(url.user) ) return; | |
| 526 | 528 | |
| 527 | 529 | fossil_print( |
| 528 | 530 | "Cannot figure out who you are! Consider using the --user\n" |
| 529 | 531 | "command line option, setting your USER environment variable,\n" |
| 530 | 532 | "or setting a default user with \"fossil user default USER\".\n" |
| 531 | 533 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -498,10 +498,11 @@ | |
| 498 | ** (8) Check if the user can be extracted from the remote URL. |
| 499 | ** |
| 500 | ** The user name is stored in g.zLogin. The uid is in g.userUid. |
| 501 | */ |
| 502 | void user_select(void){ |
| 503 | if( g.userUid ) return; |
| 504 | if( g.zLogin ){ |
| 505 | if( attempt_user(g.zLogin)==0 ){ |
| 506 | fossil_fatal("no such user: %s", g.zLogin); |
| 507 | }else{ |
| @@ -519,12 +520,13 @@ | |
| 519 | |
| 520 | if( attempt_user(fossil_getenv("LOGNAME")) ) return; |
| 521 | |
| 522 | if( attempt_user(fossil_getenv("USERNAME")) ) return; |
| 523 | |
| 524 | url_parse(0, 0); |
| 525 | if( g.url.user && attempt_user(g.url.user) ) return; |
| 526 | |
| 527 | fossil_print( |
| 528 | "Cannot figure out who you are! Consider using the --user\n" |
| 529 | "command line option, setting your USER environment variable,\n" |
| 530 | "or setting a default user with \"fossil user default USER\".\n" |
| 531 |
| --- src/user.c | |
| +++ src/user.c | |
| @@ -498,10 +498,11 @@ | |
| 498 | ** (8) Check if the user can be extracted from the remote URL. |
| 499 | ** |
| 500 | ** The user name is stored in g.zLogin. The uid is in g.userUid. |
| 501 | */ |
| 502 | void user_select(void){ |
| 503 | UrlData url; |
| 504 | if( g.userUid ) return; |
| 505 | if( g.zLogin ){ |
| 506 | if( attempt_user(g.zLogin)==0 ){ |
| 507 | fossil_fatal("no such user: %s", g.zLogin); |
| 508 | }else{ |
| @@ -519,12 +520,13 @@ | |
| 520 | |
| 521 | if( attempt_user(fossil_getenv("LOGNAME")) ) return; |
| 522 | |
| 523 | if( attempt_user(fossil_getenv("USERNAME")) ) return; |
| 524 | |
| 525 | memset(&url, 0, sizeof(url)); |
| 526 | url_parse_local(0, 0, &url); |
| 527 | if( url.user && attempt_user(url.user) ) return; |
| 528 | |
| 529 | fossil_print( |
| 530 | "Cannot figure out who you are! Consider using the --user\n" |
| 531 | "command line option, setting your USER environment variable,\n" |
| 532 | "or setting a default user with \"fossil user default USER\".\n" |
| 533 |