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
7063b1a3659638c35c987dd9be2cbb7d5b13e9938d65bb034209374a1faf377b
Parent
9bdda2047fbde3d…
1 file changed
+4
-2
+4
-2
| --- src/user.c | ||
| +++ src/user.c | ||
| @@ -498,19 +498,21 @@ | ||
| 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{ |
| 508 | 509 | return; |
| 509 | 510 | } |
| 510 | 511 | } |
| 511 | 512 | |
| 513 | + memset(&url, 0, sizeof(url)); | |
| 512 | 514 | if( g.localOpen && attempt_user(db_lget("default-user",0)) ) return; |
| 513 | 515 | |
| 514 | 516 | if( attempt_user(db_get("default-user", 0)) ) return; |
| 515 | 517 | |
| 516 | 518 | if( attempt_user(fossil_getenv("FOSSIL_USER")) ) return; |
| @@ -519,12 +521,12 @@ | ||
| 519 | 521 | |
| 520 | 522 | if( attempt_user(fossil_getenv("LOGNAME")) ) return; |
| 521 | 523 | |
| 522 | 524 | if( attempt_user(fossil_getenv("USERNAME")) ) return; |
| 523 | 525 | |
| 524 | - url_parse(0, 0); | |
| 525 | - if( g.url.user && attempt_user(g.url.user) ) return; | |
| 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,19 +498,21 @@ | |
| 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{ |
| 508 | return; |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | if( g.localOpen && attempt_user(db_lget("default-user",0)) ) return; |
| 513 | |
| 514 | if( attempt_user(db_get("default-user", 0)) ) return; |
| 515 | |
| 516 | if( attempt_user(fossil_getenv("FOSSIL_USER")) ) return; |
| @@ -519,12 +521,12 @@ | |
| 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,19 +498,21 @@ | |
| 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{ |
| 509 | return; |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | memset(&url, 0, sizeof(url)); |
| 514 | if( g.localOpen && attempt_user(db_lget("default-user",0)) ) return; |
| 515 | |
| 516 | if( attempt_user(db_get("default-user", 0)) ) return; |
| 517 | |
| 518 | if( attempt_user(fossil_getenv("FOSSIL_USER")) ) return; |
| @@ -519,12 +521,12 @@ | |
| 521 | |
| 522 | if( attempt_user(fossil_getenv("LOGNAME")) ) return; |
| 523 | |
| 524 | if( attempt_user(fossil_getenv("USERNAME")) ) return; |
| 525 | |
| 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 |