Fossil SCM

Merge trunk and fix typo (missing backslash)

jan.nijtmans 2013-12-13 14:19 UTC tkt-change-hook merge
Commit 847107015b57a8cf7acce08f0891a70a28add25a
+203 -2
--- src/file.c
+++ src/file.c
@@ -318,12 +318,213 @@
318318
/*
319319
** Wrapper around the access() system call.
320320
*/
321321
int file_access(const char *zFilename, int flags){
322322
#ifdef _WIN32
323
+ SECURITY_DESCRIPTOR *sdPtr = NULL;
324
+ unsigned long size;
325
+ PSID pSid = 0;
326
+ BOOL SidDefaulted;
327
+ SID_IDENTIFIER_AUTHORITY samba_unmapped = {{0, 0, 0, 0, 0, 22}};
328
+ GENERIC_MAPPING genMap;
329
+ HANDLE hToken = NULL;
330
+ DWORD desiredAccess = 0, grantedAccess = 0;
331
+ BOOL accessYesNo = FALSE;
332
+ PRIVILEGE_SET privSet;
333
+ DWORD privSetSize = sizeof(PRIVILEGE_SET);
334
+ int rc = 0;
335
+ DWORD attr;
323336
wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
324
- int rc = _waccess(zMbcs, flags);
337
+
338
+ attr = GetFileAttributesW(zMbcs);
339
+
340
+ if( attr==INVALID_FILE_ATTRIBUTES ){
341
+ /*
342
+ * File might not exist.
343
+ */
344
+
345
+ if( GetLastError()!=ERROR_SHARING_VIOLATION ){
346
+ fossil_filename_free(zMbcs);
347
+ return -1;
348
+ }
349
+ }
350
+
351
+ if( flags==F_OK ){
352
+ /*
353
+ * File exists, nothing else to check.
354
+ */
355
+
356
+ fossil_filename_free(zMbcs);
357
+ return 0;
358
+ }
359
+
360
+ if( (flags & W_OK)
361
+ && (attr & FILE_ATTRIBUTE_READONLY)
362
+ && !(attr & FILE_ATTRIBUTE_DIRECTORY) ){
363
+ /*
364
+ * The attributes say the file is not writable. If the file is a
365
+ * regular file (i.e., not a directory), then the file is not
366
+ * writable, full stop. For directories, the read-only bit is
367
+ * (mostly) ignored by Windows, so we can't ascertain anything about
368
+ * directory access from the attrib data. However, if we have the
369
+ * advanced 'getFileSecurityProc', then more robust ACL checks
370
+ * will be done below.
371
+ */
372
+
373
+ fossil_filename_free(zMbcs);
374
+ return -1;
375
+ }
376
+
377
+ /*
378
+ * It looks as if the permissions are ok, but if we are on NT, 2000 or XP,
379
+ * we have a more complex permissions structure so we try to check that.
380
+ * The code below is remarkably complex for such a simple thing as finding
381
+ * what permissions the OS has set for a file.
382
+ */
383
+
384
+ /*
385
+ * First find out how big the buffer needs to be.
386
+ */
387
+
388
+ size = 0;
389
+ GetFileSecurityW(zMbcs,
390
+ OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
391
+ | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
392
+ 0, 0, &size);
393
+
394
+ /*
395
+ * Should have failed with ERROR_INSUFFICIENT_BUFFER
396
+ */
397
+
398
+ if( GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
399
+ /*
400
+ * Most likely case is ERROR_ACCESS_DENIED, which we will convert
401
+ * to EACCES - just what we want!
402
+ */
403
+
404
+ fossil_filename_free(zMbcs);
405
+ return -1;
406
+ }
407
+
408
+ /*
409
+ * Now size contains the size of buffer needed.
410
+ */
411
+
412
+ sdPtr = (SECURITY_DESCRIPTOR *) HeapAlloc(GetProcessHeap(), 0, size);
413
+
414
+ if( sdPtr == NULL ){
415
+ goto accessError;
416
+ }
417
+
418
+ /*
419
+ * Call GetFileSecurity() for real.
420
+ */
421
+
422
+ if( !GetFileSecurityW(zMbcs,
423
+ OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
424
+ | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
425
+ sdPtr, size, &size) ){
426
+ /*
427
+ * Error getting owner SD
428
+ */
429
+
430
+ goto accessError;
431
+ }
432
+
433
+ /*
434
+ * As of Samba 3.0.23 (10-Jul-2006), unmapped users and groups are
435
+ * assigned to SID domains S-1-22-1 and S-1-22-2, where "22" is the
436
+ * top-level authority. If the file owner and group is unmapped then
437
+ * the ACL access check below will only test against world access,
438
+ * which is likely to be more restrictive than the actual access
439
+ * restrictions. Since the ACL tests are more likely wrong than
440
+ * right, skip them. Moreover, the unix owner access permissions are
441
+ * usually mapped to the Windows attributes, so if the user is the
442
+ * file owner then the attrib checks above are correct (as far as they
443
+ * go).
444
+ */
445
+
446
+ if( !GetSecurityDescriptorOwner(sdPtr,&pSid,&SidDefaulted) ||
447
+ memcmp(GetSidIdentifierAuthority(pSid),&samba_unmapped,
448
+ sizeof(SID_IDENTIFIER_AUTHORITY))==0 ){
449
+ HeapFree(GetProcessHeap(), 0, sdPtr);
450
+ fossil_filename_free(zMbcs);
451
+ return 0; /* Attrib tests say access allowed. */
452
+ }
453
+
454
+ /*
455
+ * Perform security impersonation of the user and open the resulting
456
+ * thread token.
457
+ */
458
+
459
+ if( !ImpersonateSelf(SecurityImpersonation) ){
460
+ /*
461
+ * Unable to perform security impersonation.
462
+ */
463
+
464
+ goto accessError;
465
+ }
466
+ if( !OpenThreadToken(GetCurrentThread(),
467
+ TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken) ){
468
+ /*
469
+ * Unable to get current thread's token.
470
+ */
471
+
472
+ goto accessError;
473
+ }
474
+
475
+ RevertToSelf();
476
+
477
+ /*
478
+ * Setup desiredAccess according to the access priveleges we are
479
+ * checking.
480
+ */
481
+
482
+ if( flags & R_OK ){
483
+ desiredAccess |= FILE_GENERIC_READ;
484
+ }
485
+ if( flags & W_OK){
486
+ desiredAccess |= FILE_GENERIC_WRITE;
487
+ }
488
+
489
+ memset(&genMap, 0x0, sizeof(GENERIC_MAPPING));
490
+ genMap.GenericRead = FILE_GENERIC_READ;
491
+ genMap.GenericWrite = FILE_GENERIC_WRITE;
492
+ genMap.GenericExecute = FILE_GENERIC_EXECUTE;
493
+ genMap.GenericAll = FILE_ALL_ACCESS;
494
+
495
+ /*
496
+ * Perform access check using the token.
497
+ */
498
+
499
+ if( !AccessCheck(sdPtr, hToken, desiredAccess,
500
+ &genMap, &privSet, &privSetSize, &grantedAccess,
501
+ &accessYesNo) ){
502
+ /*
503
+ * Unable to perform access check.
504
+ */
505
+
506
+ accessError:
507
+ if( sdPtr != NULL ){
508
+ HeapFree(GetProcessHeap(), 0, sdPtr);
509
+ }
510
+ if( hToken != NULL ){
511
+ CloseHandle(hToken);
512
+ }
513
+ fossil_filename_free(zMbcs);
514
+ return -1;
515
+ }
516
+
517
+ /*
518
+ * Clean up.
519
+ */
520
+
521
+ HeapFree(GetProcessHeap(), 0, sdPtr);
522
+ CloseHandle(hToken);
523
+ if( !accessYesNo ){
524
+ rc = -1;
525
+ }
325526
#else
326527
char *zMbcs = fossil_utf8_to_filename(zFilename);
327528
int rc = access(zMbcs, flags);
328529
#endif
329530
fossil_filename_free(zMbcs);
@@ -743,11 +944,11 @@
743944
#ifdef _WIN32
744945
char *zPwdUtf8;
745946
int nPwd;
746947
int i;
747948
wchar_t zPwd[2000];
748
- if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){
949
+ if( GetCurrentDirectoryW(count(zPwd), zPwd)==0 ){
749950
fossil_fatal("cannot find the current working directory.");
750951
}
751952
zPwdUtf8 = fossil_filename_to_utf8(zPwd);
752953
nPwd = strlen(zPwdUtf8);
753954
if( nPwd > nBuf-1 ){
754955
--- src/file.c
+++ src/file.c
@@ -318,12 +318,213 @@
318 /*
319 ** Wrapper around the access() system call.
320 */
321 int file_access(const char *zFilename, int flags){
322 #ifdef _WIN32
 
 
 
 
 
 
 
 
 
 
 
 
 
323 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
324 int rc = _waccess(zMbcs, flags);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325 #else
326 char *zMbcs = fossil_utf8_to_filename(zFilename);
327 int rc = access(zMbcs, flags);
328 #endif
329 fossil_filename_free(zMbcs);
@@ -743,11 +944,11 @@
743 #ifdef _WIN32
744 char *zPwdUtf8;
745 int nPwd;
746 int i;
747 wchar_t zPwd[2000];
748 if( _wgetcwd(zPwd, sizeof(zPwd)/sizeof(zPwd[0])-1)==0 ){
749 fossil_fatal("cannot find the current working directory.");
750 }
751 zPwdUtf8 = fossil_filename_to_utf8(zPwd);
752 nPwd = strlen(zPwdUtf8);
753 if( nPwd > nBuf-1 ){
754
--- src/file.c
+++ src/file.c
@@ -318,12 +318,213 @@
318 /*
319 ** Wrapper around the access() system call.
320 */
321 int file_access(const char *zFilename, int flags){
322 #ifdef _WIN32
323 SECURITY_DESCRIPTOR *sdPtr = NULL;
324 unsigned long size;
325 PSID pSid = 0;
326 BOOL SidDefaulted;
327 SID_IDENTIFIER_AUTHORITY samba_unmapped = {{0, 0, 0, 0, 0, 22}};
328 GENERIC_MAPPING genMap;
329 HANDLE hToken = NULL;
330 DWORD desiredAccess = 0, grantedAccess = 0;
331 BOOL accessYesNo = FALSE;
332 PRIVILEGE_SET privSet;
333 DWORD privSetSize = sizeof(PRIVILEGE_SET);
334 int rc = 0;
335 DWORD attr;
336 wchar_t *zMbcs = fossil_utf8_to_filename(zFilename);
337
338 attr = GetFileAttributesW(zMbcs);
339
340 if( attr==INVALID_FILE_ATTRIBUTES ){
341 /*
342 * File might not exist.
343 */
344
345 if( GetLastError()!=ERROR_SHARING_VIOLATION ){
346 fossil_filename_free(zMbcs);
347 return -1;
348 }
349 }
350
351 if( flags==F_OK ){
352 /*
353 * File exists, nothing else to check.
354 */
355
356 fossil_filename_free(zMbcs);
357 return 0;
358 }
359
360 if( (flags & W_OK)
361 && (attr & FILE_ATTRIBUTE_READONLY)
362 && !(attr & FILE_ATTRIBUTE_DIRECTORY) ){
363 /*
364 * The attributes say the file is not writable. If the file is a
365 * regular file (i.e., not a directory), then the file is not
366 * writable, full stop. For directories, the read-only bit is
367 * (mostly) ignored by Windows, so we can't ascertain anything about
368 * directory access from the attrib data. However, if we have the
369 * advanced 'getFileSecurityProc', then more robust ACL checks
370 * will be done below.
371 */
372
373 fossil_filename_free(zMbcs);
374 return -1;
375 }
376
377 /*
378 * It looks as if the permissions are ok, but if we are on NT, 2000 or XP,
379 * we have a more complex permissions structure so we try to check that.
380 * The code below is remarkably complex for such a simple thing as finding
381 * what permissions the OS has set for a file.
382 */
383
384 /*
385 * First find out how big the buffer needs to be.
386 */
387
388 size = 0;
389 GetFileSecurityW(zMbcs,
390 OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
391 | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
392 0, 0, &size);
393
394 /*
395 * Should have failed with ERROR_INSUFFICIENT_BUFFER
396 */
397
398 if( GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
399 /*
400 * Most likely case is ERROR_ACCESS_DENIED, which we will convert
401 * to EACCES - just what we want!
402 */
403
404 fossil_filename_free(zMbcs);
405 return -1;
406 }
407
408 /*
409 * Now size contains the size of buffer needed.
410 */
411
412 sdPtr = (SECURITY_DESCRIPTOR *) HeapAlloc(GetProcessHeap(), 0, size);
413
414 if( sdPtr == NULL ){
415 goto accessError;
416 }
417
418 /*
419 * Call GetFileSecurity() for real.
420 */
421
422 if( !GetFileSecurityW(zMbcs,
423 OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
424 | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
425 sdPtr, size, &size) ){
426 /*
427 * Error getting owner SD
428 */
429
430 goto accessError;
431 }
432
433 /*
434 * As of Samba 3.0.23 (10-Jul-2006), unmapped users and groups are
435 * assigned to SID domains S-1-22-1 and S-1-22-2, where "22" is the
436 * top-level authority. If the file owner and group is unmapped then
437 * the ACL access check below will only test against world access,
438 * which is likely to be more restrictive than the actual access
439 * restrictions. Since the ACL tests are more likely wrong than
440 * right, skip them. Moreover, the unix owner access permissions are
441 * usually mapped to the Windows attributes, so if the user is the
442 * file owner then the attrib checks above are correct (as far as they
443 * go).
444 */
445
446 if( !GetSecurityDescriptorOwner(sdPtr,&pSid,&SidDefaulted) ||
447 memcmp(GetSidIdentifierAuthority(pSid),&samba_unmapped,
448 sizeof(SID_IDENTIFIER_AUTHORITY))==0 ){
449 HeapFree(GetProcessHeap(), 0, sdPtr);
450 fossil_filename_free(zMbcs);
451 return 0; /* Attrib tests say access allowed. */
452 }
453
454 /*
455 * Perform security impersonation of the user and open the resulting
456 * thread token.
457 */
458
459 if( !ImpersonateSelf(SecurityImpersonation) ){
460 /*
461 * Unable to perform security impersonation.
462 */
463
464 goto accessError;
465 }
466 if( !OpenThreadToken(GetCurrentThread(),
467 TOKEN_DUPLICATE | TOKEN_QUERY, FALSE, &hToken) ){
468 /*
469 * Unable to get current thread's token.
470 */
471
472 goto accessError;
473 }
474
475 RevertToSelf();
476
477 /*
478 * Setup desiredAccess according to the access priveleges we are
479 * checking.
480 */
481
482 if( flags & R_OK ){
483 desiredAccess |= FILE_GENERIC_READ;
484 }
485 if( flags & W_OK){
486 desiredAccess |= FILE_GENERIC_WRITE;
487 }
488
489 memset(&genMap, 0x0, sizeof(GENERIC_MAPPING));
490 genMap.GenericRead = FILE_GENERIC_READ;
491 genMap.GenericWrite = FILE_GENERIC_WRITE;
492 genMap.GenericExecute = FILE_GENERIC_EXECUTE;
493 genMap.GenericAll = FILE_ALL_ACCESS;
494
495 /*
496 * Perform access check using the token.
497 */
498
499 if( !AccessCheck(sdPtr, hToken, desiredAccess,
500 &genMap, &privSet, &privSetSize, &grantedAccess,
501 &accessYesNo) ){
502 /*
503 * Unable to perform access check.
504 */
505
506 accessError:
507 if( sdPtr != NULL ){
508 HeapFree(GetProcessHeap(), 0, sdPtr);
509 }
510 if( hToken != NULL ){
511 CloseHandle(hToken);
512 }
513 fossil_filename_free(zMbcs);
514 return -1;
515 }
516
517 /*
518 * Clean up.
519 */
520
521 HeapFree(GetProcessHeap(), 0, sdPtr);
522 CloseHandle(hToken);
523 if( !accessYesNo ){
524 rc = -1;
525 }
526 #else
527 char *zMbcs = fossil_utf8_to_filename(zFilename);
528 int rc = access(zMbcs, flags);
529 #endif
530 fossil_filename_free(zMbcs);
@@ -743,11 +944,11 @@
944 #ifdef _WIN32
945 char *zPwdUtf8;
946 int nPwd;
947 int i;
948 wchar_t zPwd[2000];
949 if( GetCurrentDirectoryW(count(zPwd), zPwd)==0 ){
950 fossil_fatal("cannot find the current working directory.");
951 }
952 zPwdUtf8 = fossil_filename_to_utf8(zPwd);
953 nPwd = strlen(zPwdUtf8);
954 if( nPwd > nBuf-1 ){
955
+21 -6
--- src/info.c
+++ src/info.c
@@ -2057,11 +2057,11 @@
20572057
int fNewPropagateColor; /* True if color propagates after edit */
20582058
int fHasClosed = 0; /* True if closed tag already set */
20592059
const char *zChngTime = 0; /* Value of chngtime= query param, if any */
20602060
char *zUuid;
20612061
Blob comment;
2062
- char *zBranchName = "";
2062
+ char *zBranchName = 0;
20632063
Stmt q;
20642064
20652065
login_check_credentials();
20662066
if( !g.perm.Write ){ login_needed(); return; }
20672067
rid = name_to_typed_rid(P("r"), "ci");
@@ -2199,16 +2199,23 @@
21992199
blob_zero(&comment);
22002200
blob_append(&comment, zNewComment, -1);
22012201
zUuid[10] = 0;
22022202
style_header("Edit Check-in [%s]", zUuid);
22032203
/*
2204
- ** chgbn: Handle change of branch name in remaining of form.
2204
+ ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
2205
+ ** remaining of form.
22052206
*/
22062207
@ <script>
2208
+ @ function chgcbn(checked, branch){
2209
+ @ val = gebi('brname').value;
2210
+ @ if( !val || !checked) val = branch;
2211
+ @ cidbrid = document.getElementById('cbranch');
2212
+ @ if( cidbrid ) cidbrid.textContent = val;
2213
+ @ }
22072214
@ function chgbn(val, branch){
2208
- @ if (!val) val=branch;
2209
- @ gebi('newbr').checked=(val!=branch);
2215
+ @ if( !val ) val = branch;
2216
+ @ gebi('newbr').checked = (val!=branch);
22102217
@ cidbrid = document.getElementById('cbranch');
22112218
@ if( cidbrid ) cidbrid.textContent = val;
22122219
@ }
22132220
@ </script>
22142221
if( P("preview") ){
@@ -2328,15 +2335,23 @@
23282335
}
23292336
}
23302337
db_finalize(&q);
23312338
@ </td></tr>
23322339
2340
+ if( !zBranchName ){
2341
+ zBranchName = db_get("main-branch", "trunk");
2342
+ }
2343
+ if( !zNewBranch || !zNewBranch[0]){
2344
+ zNewBranch = zBranchName;
2345
+ }
23332346
@ <tr><th align="right" valign="top">Branching:</th>
23342347
@ <td valign="top">
2335
- @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) />
2348
+ @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2349
+ @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
23362350
@ Make this check-in the start of a new branch named:</label>
2337
- @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
2351
+ @ <input id="brname" type="text" style="width:15;" name="brname"
2352
+ @ value="%h(zNewBranch)"
23382353
@ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
23392354
if( !fHasClosed ){
23402355
if( is_a_leaf(rid) ){
23412356
@ <tr><th align="right" valign="top">Leaf Closure:</th>
23422357
@ <td valign="top">
23432358
--- src/info.c
+++ src/info.c
@@ -2057,11 +2057,11 @@
2057 int fNewPropagateColor; /* True if color propagates after edit */
2058 int fHasClosed = 0; /* True if closed tag already set */
2059 const char *zChngTime = 0; /* Value of chngtime= query param, if any */
2060 char *zUuid;
2061 Blob comment;
2062 char *zBranchName = "";
2063 Stmt q;
2064
2065 login_check_credentials();
2066 if( !g.perm.Write ){ login_needed(); return; }
2067 rid = name_to_typed_rid(P("r"), "ci");
@@ -2199,16 +2199,23 @@
2199 blob_zero(&comment);
2200 blob_append(&comment, zNewComment, -1);
2201 zUuid[10] = 0;
2202 style_header("Edit Check-in [%s]", zUuid);
2203 /*
2204 ** chgbn: Handle change of branch name in remaining of form.
 
2205 */
2206 @ <script>
 
 
 
 
 
 
2207 @ function chgbn(val, branch){
2208 @ if (!val) val=branch;
2209 @ gebi('newbr').checked=(val!=branch);
2210 @ cidbrid = document.getElementById('cbranch');
2211 @ if( cidbrid ) cidbrid.textContent = val;
2212 @ }
2213 @ </script>
2214 if( P("preview") ){
@@ -2328,15 +2335,23 @@
2328 }
2329 }
2330 db_finalize(&q);
2331 @ </td></tr>
2332
 
 
 
 
 
 
2333 @ <tr><th align="right" valign="top">Branching:</th>
2334 @ <td valign="top">
2335 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) />
 
2336 @ Make this check-in the start of a new branch named:</label>
2337 @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
 
2338 @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
2339 if( !fHasClosed ){
2340 if( is_a_leaf(rid) ){
2341 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2342 @ <td valign="top">
2343
--- src/info.c
+++ src/info.c
@@ -2057,11 +2057,11 @@
2057 int fNewPropagateColor; /* True if color propagates after edit */
2058 int fHasClosed = 0; /* True if closed tag already set */
2059 const char *zChngTime = 0; /* Value of chngtime= query param, if any */
2060 char *zUuid;
2061 Blob comment;
2062 char *zBranchName = 0;
2063 Stmt q;
2064
2065 login_check_credentials();
2066 if( !g.perm.Write ){ login_needed(); return; }
2067 rid = name_to_typed_rid(P("r"), "ci");
@@ -2199,16 +2199,23 @@
2199 blob_zero(&comment);
2200 blob_append(&comment, zNewComment, -1);
2201 zUuid[10] = 0;
2202 style_header("Edit Check-in [%s]", zUuid);
2203 /*
2204 ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
2205 ** remaining of form.
2206 */
2207 @ <script>
2208 @ function chgcbn(checked, branch){
2209 @ val = gebi('brname').value;
2210 @ if( !val || !checked) val = branch;
2211 @ cidbrid = document.getElementById('cbranch');
2212 @ if( cidbrid ) cidbrid.textContent = val;
2213 @ }
2214 @ function chgbn(val, branch){
2215 @ if( !val ) val = branch;
2216 @ gebi('newbr').checked = (val!=branch);
2217 @ cidbrid = document.getElementById('cbranch');
2218 @ if( cidbrid ) cidbrid.textContent = val;
2219 @ }
2220 @ </script>
2221 if( P("preview") ){
@@ -2328,15 +2335,23 @@
2335 }
2336 }
2337 db_finalize(&q);
2338 @ </td></tr>
2339
2340 if( !zBranchName ){
2341 zBranchName = db_get("main-branch", "trunk");
2342 }
2343 if( !zNewBranch || !zNewBranch[0]){
2344 zNewBranch = zBranchName;
2345 }
2346 @ <tr><th align="right" valign="top">Branching:</th>
2347 @ <td valign="top">
2348 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2349 @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
2350 @ Make this check-in the start of a new branch named:</label>
2351 @ <input id="brname" type="text" style="width:15;" name="brname"
2352 @ value="%h(zNewBranch)"
2353 @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
2354 if( !fHasClosed ){
2355 if( is_a_leaf(rid) ){
2356 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2357 @ <td valign="top">
2358
+21 -6
--- src/info.c
+++ src/info.c
@@ -2057,11 +2057,11 @@
20572057
int fNewPropagateColor; /* True if color propagates after edit */
20582058
int fHasClosed = 0; /* True if closed tag already set */
20592059
const char *zChngTime = 0; /* Value of chngtime= query param, if any */
20602060
char *zUuid;
20612061
Blob comment;
2062
- char *zBranchName = "";
2062
+ char *zBranchName = 0;
20632063
Stmt q;
20642064
20652065
login_check_credentials();
20662066
if( !g.perm.Write ){ login_needed(); return; }
20672067
rid = name_to_typed_rid(P("r"), "ci");
@@ -2199,16 +2199,23 @@
21992199
blob_zero(&comment);
22002200
blob_append(&comment, zNewComment, -1);
22012201
zUuid[10] = 0;
22022202
style_header("Edit Check-in [%s]", zUuid);
22032203
/*
2204
- ** chgbn: Handle change of branch name in remaining of form.
2204
+ ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
2205
+ ** remaining of form.
22052206
*/
22062207
@ <script>
2208
+ @ function chgcbn(checked, branch){
2209
+ @ val = gebi('brname').value;
2210
+ @ if( !val || !checked) val = branch;
2211
+ @ cidbrid = document.getElementById('cbranch');
2212
+ @ if( cidbrid ) cidbrid.textContent = val;
2213
+ @ }
22072214
@ function chgbn(val, branch){
2208
- @ if (!val) val=branch;
2209
- @ gebi('newbr').checked=(val!=branch);
2215
+ @ if( !val ) val = branch;
2216
+ @ gebi('newbr').checked = (val!=branch);
22102217
@ cidbrid = document.getElementById('cbranch');
22112218
@ if( cidbrid ) cidbrid.textContent = val;
22122219
@ }
22132220
@ </script>
22142221
if( P("preview") ){
@@ -2328,15 +2335,23 @@
23282335
}
23292336
}
23302337
db_finalize(&q);
23312338
@ </td></tr>
23322339
2340
+ if( !zBranchName ){
2341
+ zBranchName = db_get("main-branch", "trunk");
2342
+ }
2343
+ if( !zNewBranch || !zNewBranch[0]){
2344
+ zNewBranch = zBranchName;
2345
+ }
23332346
@ <tr><th align="right" valign="top">Branching:</th>
23342347
@ <td valign="top">
2335
- @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) />
2348
+ @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2349
+ @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
23362350
@ Make this check-in the start of a new branch named:</label>
2337
- @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
2351
+ @ <input id="brname" type="text" style="width:15;" name="brname"
2352
+ @ value="%h(zNewBranch)"
23382353
@ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
23392354
if( !fHasClosed ){
23402355
if( is_a_leaf(rid) ){
23412356
@ <tr><th align="right" valign="top">Leaf Closure:</th>
23422357
@ <td valign="top">
23432358
--- src/info.c
+++ src/info.c
@@ -2057,11 +2057,11 @@
2057 int fNewPropagateColor; /* True if color propagates after edit */
2058 int fHasClosed = 0; /* True if closed tag already set */
2059 const char *zChngTime = 0; /* Value of chngtime= query param, if any */
2060 char *zUuid;
2061 Blob comment;
2062 char *zBranchName = "";
2063 Stmt q;
2064
2065 login_check_credentials();
2066 if( !g.perm.Write ){ login_needed(); return; }
2067 rid = name_to_typed_rid(P("r"), "ci");
@@ -2199,16 +2199,23 @@
2199 blob_zero(&comment);
2200 blob_append(&comment, zNewComment, -1);
2201 zUuid[10] = 0;
2202 style_header("Edit Check-in [%s]", zUuid);
2203 /*
2204 ** chgbn: Handle change of branch name in remaining of form.
 
2205 */
2206 @ <script>
 
 
 
 
 
 
2207 @ function chgbn(val, branch){
2208 @ if (!val) val=branch;
2209 @ gebi('newbr').checked=(val!=branch);
2210 @ cidbrid = document.getElementById('cbranch');
2211 @ if( cidbrid ) cidbrid.textContent = val;
2212 @ }
2213 @ </script>
2214 if( P("preview") ){
@@ -2328,15 +2335,23 @@
2328 }
2329 }
2330 db_finalize(&q);
2331 @ </td></tr>
2332
 
 
 
 
 
 
2333 @ <tr><th align="right" valign="top">Branching:</th>
2334 @ <td valign="top">
2335 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) />
 
2336 @ Make this check-in the start of a new branch named:</label>
2337 @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
 
2338 @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
2339 if( !fHasClosed ){
2340 if( is_a_leaf(rid) ){
2341 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2342 @ <td valign="top">
2343
--- src/info.c
+++ src/info.c
@@ -2057,11 +2057,11 @@
2057 int fNewPropagateColor; /* True if color propagates after edit */
2058 int fHasClosed = 0; /* True if closed tag already set */
2059 const char *zChngTime = 0; /* Value of chngtime= query param, if any */
2060 char *zUuid;
2061 Blob comment;
2062 char *zBranchName = 0;
2063 Stmt q;
2064
2065 login_check_credentials();
2066 if( !g.perm.Write ){ login_needed(); return; }
2067 rid = name_to_typed_rid(P("r"), "ci");
@@ -2199,16 +2199,23 @@
2199 blob_zero(&comment);
2200 blob_append(&comment, zNewComment, -1);
2201 zUuid[10] = 0;
2202 style_header("Edit Check-in [%s]", zUuid);
2203 /*
2204 ** chgcbn/chgbn: Handle change of (checkbox for) branch name in
2205 ** remaining of form.
2206 */
2207 @ <script>
2208 @ function chgcbn(checked, branch){
2209 @ val = gebi('brname').value;
2210 @ if( !val || !checked) val = branch;
2211 @ cidbrid = document.getElementById('cbranch');
2212 @ if( cidbrid ) cidbrid.textContent = val;
2213 @ }
2214 @ function chgbn(val, branch){
2215 @ if( !val ) val = branch;
2216 @ gebi('newbr').checked = (val!=branch);
2217 @ cidbrid = document.getElementById('cbranch');
2218 @ if( cidbrid ) cidbrid.textContent = val;
2219 @ }
2220 @ </script>
2221 if( P("preview") ){
@@ -2328,15 +2335,23 @@
2335 }
2336 }
2337 db_finalize(&q);
2338 @ </td></tr>
2339
2340 if( !zBranchName ){
2341 zBranchName = db_get("main-branch", "trunk");
2342 }
2343 if( !zNewBranch || !zNewBranch[0]){
2344 zNewBranch = zBranchName;
2345 }
2346 @ <tr><th align="right" valign="top">Branching:</th>
2347 @ <td valign="top">
2348 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag)
2349 @ onchange="chgcbn(this.checked,'%h(zBranchName)')" />
2350 @ Make this check-in the start of a new branch named:</label>
2351 @ <input id="brname" type="text" style="width:15;" name="brname"
2352 @ value="%h(zNewBranch)"
2353 @ onkeyup="chgbn(this.value,'%h(zBranchName)')" /></td></tr>
2354 if( !fHasClosed ){
2355 if( is_a_leaf(rid) ){
2356 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2357 @ <td valign="top">
2358
+1 -1
--- src/th_main.c
+++ src/th_main.c
@@ -864,11 +864,11 @@
864864
}
865865
if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
866866
if( nArg+1!=argc && nArg+2!=argc ){
867867
return Th_WrongNumArgs(interp, REGEXP_WRONGNUMARGS);
868868
}
869
- memset(&urlData, '0', sizeof(urlData));
869
+ memset(&urlData, '\0', sizeof(urlData));
870870
url_parse_local(argv[nArg], 0, &urlData);
871871
if( urlData.isSsh || urlData.isFile ){
872872
Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
873873
return TH_ERROR;
874874
}
875875
--- src/th_main.c
+++ src/th_main.c
@@ -864,11 +864,11 @@
864 }
865 if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
866 if( nArg+1!=argc && nArg+2!=argc ){
867 return Th_WrongNumArgs(interp, REGEXP_WRONGNUMARGS);
868 }
869 memset(&urlData, '0', sizeof(urlData));
870 url_parse_local(argv[nArg], 0, &urlData);
871 if( urlData.isSsh || urlData.isFile ){
872 Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
873 return TH_ERROR;
874 }
875
--- src/th_main.c
+++ src/th_main.c
@@ -864,11 +864,11 @@
864 }
865 if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
866 if( nArg+1!=argc && nArg+2!=argc ){
867 return Th_WrongNumArgs(interp, REGEXP_WRONGNUMARGS);
868 }
869 memset(&urlData, '\0', sizeof(urlData));
870 url_parse_local(argv[nArg], 0, &urlData);
871 if( urlData.isSsh || urlData.isFile ){
872 Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
873 return TH_ERROR;
874 }
875
+1 -1
--- src/th_main.c
+++ src/th_main.c
@@ -864,11 +864,11 @@
864864
}
865865
if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
866866
if( nArg+1!=argc && nArg+2!=argc ){
867867
return Th_WrongNumArgs(interp, REGEXP_WRONGNUMARGS);
868868
}
869
- memset(&urlData, '0', sizeof(urlData));
869
+ memset(&urlData, '\0', sizeof(urlData));
870870
url_parse_local(argv[nArg], 0, &urlData);
871871
if( urlData.isSsh || urlData.isFile ){
872872
Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
873873
return TH_ERROR;
874874
}
875875
--- src/th_main.c
+++ src/th_main.c
@@ -864,11 +864,11 @@
864 }
865 if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
866 if( nArg+1!=argc && nArg+2!=argc ){
867 return Th_WrongNumArgs(interp, REGEXP_WRONGNUMARGS);
868 }
869 memset(&urlData, '0', sizeof(urlData));
870 url_parse_local(argv[nArg], 0, &urlData);
871 if( urlData.isSsh || urlData.isFile ){
872 Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
873 return TH_ERROR;
874 }
875
--- src/th_main.c
+++ src/th_main.c
@@ -864,11 +864,11 @@
864 }
865 if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++;
866 if( nArg+1!=argc && nArg+2!=argc ){
867 return Th_WrongNumArgs(interp, REGEXP_WRONGNUMARGS);
868 }
869 memset(&urlData, '\0', sizeof(urlData));
870 url_parse_local(argv[nArg], 0, &urlData);
871 if( urlData.isSsh || urlData.isFile ){
872 Th_ErrorMessage(interp, "url must be http:// or https://", 0, 0);
873 return TH_ERROR;
874 }
875

Keyboard Shortcuts

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