List of commits:
Subject Hash Author Date (UTC)
Add support for SHA-256 git repos 8b88927d353c7b588909d0b1220c8922b32129c0 Catalin(ux) M. BOIE 2022-12-21 11:03:19
Look-up pkg_repo using pkg_repo uid f2b188b8cb151c376d8ee8c81f8e82c02ed93cd1 Catalin(ux) M. BOIE 2022-12-12 05:29:13
Cosmetic 04ae5ac6b9805198966a21755d1d430ef5b6a6dd Catalin(ux) M. BOIE 2022-12-11 17:17:39
Keep-alive mechanism for builder/worker 7e3add2ab41feefe37a858439934b8599fb30933 Catalin(ux) M. BOIE 2022-12-10 19:36:53
Bumped version to 0.76 09bb0cc92a9dfce513ce1289a22e71faf4ad1fe1 Catalin(ux) M. BOIE 2022-10-22 06:27:35
Cosmetic 45c59081c97489ccccd35efffa522607fee25a63 Catalin(ux) M. BOIE 2022-10-22 05:52:56
Mostly worker stuff ccf3a8d8da2ad1b0d97418fabb5028b40721835f Catalin(ux) M. BOIE 2022-10-22 05:50:04
wh: lambda: seems we cannot pass x-Amz-Client-Context header empty anymore 7f065b0fb6ceed5d2339afd7590f5a795ed3582e Catalin(ux) M. BOIE 2022-10-21 19:33:58
workers: wrong URL for delete a2b2ff5925b1ee9b4a033da93084c008b7af8c64 Catalin(ux) M. BOIE 2022-10-21 16:03:56
Typo 4557595fb985fb2a0a482a387ef0a61293b511ed Catalin(ux) M. BOIE 2022-03-29 17:06:57
Builder improvements 2c27620922c4990454dc3039b2f1c4a86388501f Catalin(ux) M. BOIE 2022-03-29 06:28:16
Extra space in debian/conffiles preventing Debian build 416ed9995151c29bffb4ca3f0f6901aab7cbaa8e Catalin(ux) M. BOIE 2022-03-28 19:36:06
Show global pkg sub repos; cosmetic 43f60158b760b2789261e703ff2fa0781f590e04 Catalin(ux) M. BOIE 2022-03-28 18:21:07
Cosmetic a60d33914b8a1754c84ddc5440533df9b89337ad Catalin(ux) M. BOIE 2022-03-16 07:40:37
Cosmetic 8bb684cb885e0ad0f24519990a564031ea0e43a9 Catalin(ux) M. BOIE 2022-02-19 08:12:45
Set install_id under lock to not get errors 46904e58621450cc164afe769a2aeb597fbaecd8 Catalin(ux) M. BOIE 2022-02-17 18:08:59
Cosmetic bc38d3b0196d5701f75209a3125543ba096fe340 Catalin(ux) M. BOIE 2022-02-16 19:45:29
Bumped version to 0.75 1341db08f1342e7a6838305e94d31849d6b583c4 Catalin(ux) M. BOIE 2022-02-16 18:58:45
Misc small fixes 7bc12d7ee158d99979dbb91f293162472917a2e2 Catalin(ux) M. BOIE 2022-02-16 18:58:18
We did not validated the plan id - now is fixed. 3786d759107c4028f181c7de77d39382d9f572bf Catalin(ux) M. BOIE 2022-02-16 18:55:05
Commit 8b88927d353c7b588909d0b1220c8922b32129c0 - Add support for SHA-256 git repos
Author: Catalin(ux) M. BOIE
Author date (UTC): 2022-12-21 11:03
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2022-12-21 11:03
Parent(s): f2b188b8cb151c376d8ee8c81f8e82c02ed93cd1
Signer:
Signing key:
Signing status: N
Tree: 620ccc49824af89b65af6f00b256b4bf03ab2255
File Lines added Lines deleted
compare.csv 1 0
duilder.conf 1 1
hooks/pre-commit 11 4
hooks/update 2 1
inc/git.inc.php 115 63
inc/repo.inc.php 15 4
inc/struct.inc.php 7 0
root/themes/default/hints/repo/clone_owner.html 1 1
root/themes/default/repo/add_edit.html 9 1
root/themes/default/repo/commits/line.html 2 2
root/themes/default/repo/log/line.html 1 1
root/themes/default/repo/main.html 1 1
tests/_run_tests.sh 1 1
tests/git-sha256.php 134 0
tests/git.php 3 3
File compare.csv changed (mode: 100644) (index cf28f2f..d5be4cc)
... ... Business model,Support and sponsors/#good,Open core/#bad,Monthly fee/#bad,n/a,n/
5 5 GNU Ethical Repository Criteria Evaluations ([[link https://www.gnu.org/software/repo-criteria.html]]),"A (-A4, +A+0, +A+1, +A+2, +A+5)/#good",C/#bad,F/#bad,?,A?/#good,?,? GNU Ethical Repository Criteria Evaluations ([[link https://www.gnu.org/software/repo-criteria.html]]),"A (-A4, +A+0, +A+1, +A+2, +A+5)/#good",C/#bad,F/#bad,?,A?/#good,?,?
6 6 ,,,,,,, ,,,,,,,
7 7 [Features],RocketGit,Gitlab CE,GitHub,gitolite,Pagure.io,Gogs.io,Phabricator [Features],RocketGit,Gitlab CE,GitHub,gitolite,Pagure.io,Gogs.io,Phabricator
8 Git SHA-256 support,Yes,?,?,?,?,?,?
8 9 Easy installation {How easy can you install the software on your server?},Yes,Yes,Yes?,Yes,Yes,Yes,? Easy installation {How easy can you install the software on your server?},Yes,Yes,Yes?,Yes,Yes,Yes,?
9 10 SELinux policy {SELinux is an application firewall used to improve the security},Yes,No,?,not needed/#good,?,?,? SELinux policy {SELinux is an application firewall used to improve the security},Yes,No,?,not needed/#good,?,?,?
10 11 Distro friendly {Is a 'yum/dnf/apt-get/etc. update' enough to update the software? Is it free of a inner package manager?},Yes,No (see 1),No (see 1),Yes,Yes?,Yes?,? Distro friendly {Is a 'yum/dnf/apt-get/etc. update' enough to update the software? Is it free of a inner package manager?},Yes,No (see 1),No (see 1),Yes,Yes?,Yes?,?
File duilder.conf changed (mode: 100644) (index 7e0f9f9..92da4d4)
1 1 PRJ="rocketgit" PRJ="rocketgit"
2 VER="0.76"
2 VER="0.77"
3 3 REV="1" REV="1"
4 4 SHORT_DESCRIPTION="Light and fast Git hosting solution" SHORT_DESCRIPTION="Light and fast Git hosting solution"
5 5 EXCLUDE=".exclude" EXCLUDE=".exclude"
File hooks/pre-commit changed (mode: 100755) (index 363df8b..022dabc)
... ... rg_log("_SERVER: " . rg_array2string($_SERVER));
33 33 umask(0077); umask(0077);
34 34
35 35
36 if (rg_git_rev_ok("HEAD") !== FALSE)
37 $against = $rg_git_empty;
38 else
39 $against = "HEAD";
36 if (rg_git_rev_ok("HEAD") !== FALSE) {
37 $hash = rg_git_repo_get_hash($repo_path);
38 if (empty($hash))
39 exit(1);
40 if (strcmp($hash, 'sha1') == 0)
41 $against = RG_GIT_EMPTY;
42 else
43 $against = RG_GIT_EMPTY_SHA256;
44 } else {
45 $against = 'HEAD';
46 }
40 47
41 48 // TODO: Here we can deny non ascii file names // TODO: Here we can deny non ascii file names
42 49 // git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0') // git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0')
File hooks/update changed (mode: 100755) (index 95023a2..05300b5)
... ... if (empty($a['refname']) || empty($a['old_rev']) || empty($a['new_rev']))
80 80 rg_git_fatal("Invalid parameters: ref=[" . $a['refname'] rg_git_fatal("Invalid parameters: ref=[" . $a['refname']
81 81 . "] old=[" . $a['old_rev'] . "] new=[" . $a['new_rev'] . "]!"); . "] old=[" . $a['old_rev'] . "] new=[" . $a['new_rev'] . "]!");
82 82
83 if (strcmp($a['new_rev'], $rg_git_zero) == 0)
83 if ((strcmp($a['new_rev'], RG_GIT_ZERO) == 0)
84 || (strcmp($a['new_rev'], RG_GIT_ZERO_SHA256) == 0))
84 85 $a['new_rev_type'] = rg_git_type($a['old_rev']); $a['new_rev_type'] = rg_git_type($a['old_rev']);
85 86 else else
86 87 $a['new_rev_type'] = rg_git_type($a['new_rev']); $a['new_rev_type'] = rg_git_type($a['new_rev']);
File inc/git.inc.php changed (mode: 100644) (index f76bbcd..dd2e737)
... ... $rg_git_patch_limit_default = 5000;
9 9 if (!isset($rg_git_debug)) if (!isset($rg_git_debug))
10 10 $rg_git_debug = 0; $rg_git_debug = 0;
11 11
12 $rg_git_zero = "0000000000000000000000000000000000000000";
13 $rg_git_empty = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
12 define('RG_GIT_ZERO', '0000000000000000000000000000000000000000');
13 define('RG_GIT_ZERO_SHA256', '0000000000000000000000000000000000000000000000000000000000000000');
14
15 // generated by 'git hash-object -t tree /dev/null'
16 define('RG_GIT_EMPTY', '4b825dc642cb6eb9a060e54bf8d69288fbee4904');
17 define('RG_GIT_EMPTY_SHA256', '6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321');
18
14 19 define('GIT_LINK_MASK', intval(base_convert('160000', 8, 10))); define('GIT_LINK_MASK', intval(base_convert('160000', 8, 10)));
15 20 define('RG_GIT_HASH_LEN', 10); define('RG_GIT_HASH_LEN', 10);
16 21
 
... ... function rg_git_repo_is_empty($repo_path)
69 74 return 0; return 0;
70 75 } }
71 76
77 /*
78 * Returns the type of the repo (sha1 or sha256)
79 */
80 function rg_git_repo_get_hash($repo_path)
81 {
82 $f = $repo_path . '/rocketgit/hash';
83 if (!file_exists($f))
84 return 'sha1';
85
86 $hash = @file_get_contents($f);
87 if ($hash === FALSE)
88 return '';
89
90 return trim($hash);
91 }
92
72 93 /* /*
73 94 * Returns true if the ref is present in the repo * Returns true if the ref is present in the repo
74 95 */ */
 
... ... function rg_git_info_pack($band, $msg)
225 246 */ */
226 247 function rg_git_from_to($from, $to) function rg_git_from_to($from, $to)
227 248 { {
228 global $rg_git_zero;
229 global $rg_git_empty;
230
231 249 if (empty($from) && empty($to)) { if (empty($from) && empty($to)) {
232 250 rg_log_debug('from/to empty'); rg_log_debug('from/to empty');
233 251 $from_to = ''; $from_to = '';
234 252 } else if (empty($from)) { } else if (empty($from)) {
235 253 rg_log_debug('from empty'); rg_log_debug('from empty');
236 254 $from_to = $to; $from_to = $to;
237 } else if (strcmp($from, $rg_git_zero) == 0) {
255 } else if (strcmp($from, RG_GIT_ZERO) == 0) {
238 256 rg_log_debug('from zero'); rg_log_debug('from zero');
239 $from_to = $rg_git_empty . '..' . $to;
257 $from_to = RG_GIT_EMPTY . '..' . $to;
258 } else if (strcmp($from, RG_GIT_ZERO_SHA256) == 0) {
259 rg_log_debug('from zero 256');
260 $from_to = RG_GIT_EMPTY_SHA256 . '..' . $to;
240 261 } else if (empty($to)) { } else if (empty($to)) {
241 262 rg_log_debug('to empty'); rg_log_debug('to empty');
242 263 $from_to = $from; $from_to = $from;
 
... ... function rg_git_install_hooks($dst)
332 353 /* /*
333 354 * Init a dir to host a git repository * Init a dir to host a git repository
334 355 */ */
335 function rg_git_init($dst)
356 function rg_git_init($dst, $branch, $hash)
336 357 { {
337 358 rg_prof_start("git_init"); rg_prof_start("git_init");
338 rg_log_enter("git_init: dst=$dst");
359 rg_log_enter('git_init: dst=' . $dst . ' branch=' . $branch
360 . ' hash=' . $hash);
339 361
340 362 $ret = FALSE; $ret = FALSE;
341 363 while (1) { while (1) {
 
... ... function rg_git_init($dst)
351 373 // TODO: What to do if the creation fails? // TODO: What to do if the creation fails?
352 374 if (!is_dir($dst . "/rocketgit")) { if (!is_dir($dst . "/rocketgit")) {
353 375 $dst2 = $dst . '.tmp'; $dst2 = $dst . '.tmp';
354 $cmd = RG_GIT_CMD . ' init --bare ' . escapeshellarg($dst2);
376 if (strcmp($hash, 'sha256') == 0)
377 $hash_add = ' --object-format=sha256';
378 else
379 $hash_add = '';
380 $cmd = RG_GIT_CMD . ' init --bare'
381 . ' --initial-branch=' . escapeshellarg($branch)
382 . $hash_add
383 . ' ' . escapeshellarg($dst2);
355 384 $a = rg_exec($cmd, '', FALSE, FALSE, FALSE); $a = rg_exec($cmd, '', FALSE, FALSE, FALSE);
356 385 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
386 rg_internal_error('git init: ' . $a['stderr']);
357 387 rg_git_set_error("error on init " . $a['errmsg'] . ")"); rg_git_set_error("error on init " . $a['errmsg'] . ")");
358 388 break; break;
359 389 } }
 
... ... function rg_git_init($dst)
363 393 break; break;
364 394 } }
365 395
396 $r = @file_put_contents($dst2 . '/rocketgit/hash', $hash);
397 if ($r === FALSE) {
398 rg_git_set_error('cannot create [' . $dst
399 . '/rocketgit/hash] file (' . rg_php_err() . ')');
400 break;
401 }
402
366 403 $r = @rename($dst2, $dst); $r = @rename($dst2, $dst);
367 404 if ($r === FALSE) { if ($r === FALSE) {
368 405 rg_git_set_error('cannot rename git dir from .tmp'); rg_git_set_error('cannot rename git dir from .tmp');
 
... ... function rg_git_clone($src, $dst)
430 467 */ */
431 468 function rg_git_type($obj) function rg_git_type($obj)
432 469 { {
433 global $rg_git_zero;
434
435 470 rg_prof_start('git_type'); rg_prof_start('git_type');
436 471 rg_log_enter('git_type: obj=' . $obj); rg_log_enter('git_type: obj=' . $obj);
437 472
438 473 $ret = FALSE; $ret = FALSE;
439 474 while (1) { while (1) {
440 if (strcmp($obj, $rg_git_zero) == 0) {
475 if (strcmp($obj, RG_GIT_ZERO) == 0) {
476 $ret = 'zero';
477 break;
478 }
479
480 if (strcmp($obj, RG_GIT_ZERO_SHA256) == 0) {
441 481 $ret = 'zero'; $ret = 'zero';
442 482 break; break;
443 483 } }
 
... ... function rg_git_rev_ok($rev)
562 602 */ */
563 603 function rg_git_whitespace_ok($old, $new) function rg_git_whitespace_ok($old, $new)
564 604 { {
565 global $rg_git_zero;
566 global $rg_git_empty;
567
568 605 rg_prof_start("git_whitespace_ok"); rg_prof_start("git_whitespace_ok");
569 606 rg_log_enter("git_whitespace_ok: old=$old new=$new"); rg_log_enter("git_whitespace_ok: old=$old new=$new");
570 607
571 608 $ret = FALSE; $ret = FALSE;
572 609 while (1) { while (1) {
573 if (strcmp($old, $rg_git_zero) == 0)
574 $old = $rg_git_empty;
610 if (strcmp($old, RG_GIT_ZERO) == 0)
611 $old = RG_GIT_EMPTY;
612 else if (strcmp($old, RG_GIT_ZERO_SHA256) == 0)
613 $old = RG_GIT_EMPTY_SHA256;
575 614
576 615 $cmd = RG_GIT_CMD . " diff --check" $cmd = RG_GIT_CMD . " diff --check"
577 616 . " " . escapeshellarg($old) . " " . escapeshellarg($old)
 
... ... function rg_git_whitespace_ok($old, $new)
597 636 */ */
598 637 function rg_git_load_ref($repo_path, $ref) function rg_git_load_ref($repo_path, $ref)
599 638 { {
600 global $rg_git_empty;
601
602 639 $b = rg_git_reference($ref); $b = rg_git_reference($ref);
603 640 if ($b === FALSE) if ($b === FALSE)
604 641 return FALSE; return FALSE;
 
... ... function rg_git_load_ref($repo_path, $ref)
622 659 */ */
623 660 function rg_git_merge_base($repo_path, $refname_or_hash, $b) function rg_git_merge_base($repo_path, $refname_or_hash, $b)
624 661 { {
625 global $rg_git_zero;
626 global $rg_git_empty;
627
628 662 rg_prof_start('git_merge_base'); rg_prof_start('git_merge_base');
629 663 rg_log_enter('git_merge_base' . ' refname_or_hash=' . $refname_or_hash rg_log_enter('git_merge_base' . ' refname_or_hash=' . $refname_or_hash
630 664 . ' b=' . $b); . ' b=' . $b);
 
... ... function rg_git_merge_base($repo_path, $refname_or_hash, $b)
637 671
638 672 if ($r === 1) { if ($r === 1) {
639 673 rg_log('DEBUG_MERGE: repo is empty. Return rg_git_empty.'); rg_log('DEBUG_MERGE: repo is empty. Return rg_git_empty.');
640 $ret = $rg_git_empty;
674 $hash = rg_git_repo_get_hash($repo_path);
675 if (empty($hash))
676 break;
677 if (strcmp($hash, 'sha1') == 0)
678 $ret = RG_GIT_EMPTY;
679 else
680 $ret = RG_GIT_EMPTY_SHA256;
641 681 break; break;
642 682 } }
643 683
 
... ... function rg_git_ls_tree($repo_path, $tree, $path)
812 852 } }
813 853
814 854 if (empty($a['data']) && !empty($path)) { if (empty($a['data']) && !empty($path)) {
855 rg_log_debug('a[data] is empty; a: ' . print_r($a, TRUE));
815 856 rg_git_set_error('path does not exists'); rg_git_set_error('path does not exists');
816 857 break; break;
817 858 } }
 
... ... function rg_git_log_simple($repo_path, $max, $from, $to, $also_patch, $files,
1266 1307 . $patches . $patches
1267 1308 . " --pretty=\"format:" . " --pretty=\"format:"
1268 1309 . $sep_start . $sep_start
1269 . "sha1:%H%x00\"\""
1270 . "sha1_short:%h%x00\"\""
1310 . "hash:%H%x00\"\""
1311 . "hash_short:%h%x00\"\""
1271 1312 . "tree:%T%x00\"\"" . "tree:%T%x00\"\""
1272 1313 . "tree_short:%t%x00\"\"" . "tree_short:%t%x00\"\""
1273 1314 . "parents:%P%x00\"\"" . "parents:%P%x00\"\""
 
... ... function rg_git_log_simple($repo_path, $max, $from, $to, $also_patch, $files,
1295 1336 } }
1296 1337 $a = rg_exec($cmd, '', FALSE, FALSE, FALSE); $a = rg_exec($cmd, '', FALSE, FALSE, FALSE);
1297 1338 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
1339 rg_log_debug('stderr: ' . $a['stderr']);
1298 1340 rg_internal_error("error on log (" . $a['errmsg'] . ")" rg_internal_error("error on log (" . $a['errmsg'] . ")"
1299 1341 . " cmd=" . $cmd); . " cmd=" . $cmd);
1300 1342 rg_git_set_error("could not generate log; try again later"); rg_git_set_error("could not generate log; try again later");
 
... ... function rg_git_log_detect_big_diff($stat)
1476 1518 $ret = array(); $ret = array();
1477 1519 $at_least_one_bad = FALSE; $at_least_one_bad = FALSE;
1478 1520 foreach ($stat as $junk => $per_commit) { foreach ($stat as $junk => $per_commit) {
1479 $hash = $per_commit['vars']['sha1'];
1521 $hash = $per_commit['vars']['hash'];
1480 1522
1481 1523 $good_files = array(); $good_files = array();
1482 1524 $cur = 'good'; $cur = 'good';
 
... ... function rg_git_stats($log)
1706 1748 */ */
1707 1749 function rg_git_files($old, $new) function rg_git_files($old, $new)
1708 1750 { {
1709 global $rg_git_zero;
1710 global $rg_git_empty;
1711
1712 1751 rg_prof_start("git_files"); rg_prof_start("git_files");
1713 1752 rg_log_enter('git_files old=' . $old . ' new=' . $new); rg_log_enter('git_files old=' . $old . ' new=' . $new);
1714 1753
1715 1754 $ret = FALSE; $ret = FALSE;
1716 1755 while (1) { while (1) {
1717 if (strcmp($old, $rg_git_zero) == 0)
1718 $old = $rg_git_empty;
1756 if (strcmp($old, RG_GIT_ZERO) == 0)
1757 $old = RG_GIT_EMPTY;
1758 else if (strcmp($old, RG_GIT_ZERO_SHA256) == 0)
1759 $old = RG_GIT_EMPTY_SHA256;
1719 1760
1720 $cmd = RG_GIT_CMD . ' diff --name-only ' . escapeshellarg($old)
1761 $cmd = RG_GIT_CMD . ' diff --name-only '
1762 . ' ' . escapeshellarg($old)
1721 1763 . ' ' . escapeshellarg($new); . ' ' . escapeshellarg($new);
1722 1764 $a = rg_exec($cmd, '', FALSE, FALSE, FALSE); $a = rg_exec($cmd, '', FALSE, FALSE, FALSE);
1723 1765 if ($a['ok'] != 1) { if ($a['ok'] != 1) {
1724 1766 rg_git_set_error("error on git diff (" . $a['errmsg'] . ")"); rg_git_set_error("error on git diff (" . $a['errmsg'] . ")");
1767 rg_log_debug('stderr: ' . $a['stderr']);
1725 1768 break; break;
1726 1769 } }
1727 1770
 
... ... function rg_git_files($old, $new)
1738 1781 /* /*
1739 1782 * Nice diff per file * Nice diff per file
1740 1783 * Outputs the result of replacing variables in a template with real variables * Outputs the result of replacing variables in a template with real variables
1741 * @id - uniq id, most of the time the commit sha1; used to differentiate
1784 * @id - uniq id, most of the time the commit hash; used to differentiate
1742 1785 * between same files in different commits. * between same files in different commits.
1743 1786 * @a - output of rg_git_diff2array[index]['files'] * @a - output of rg_git_diff2array[index]['files']
1744 1787 * TODO: Switch to rg_template_table? * TODO: Switch to rg_template_table?
 
... ... function rg_git_files_stats($hash, $a, $dir)
1896 1939 */ */
1897 1940 function rg_git_update_tag($db, $a) function rg_git_update_tag($db, $a)
1898 1941 { {
1899 global $rg_git_zero;
1900
1901 1942 rg_prof_start("git_update_tag"); rg_prof_start("git_update_tag");
1902 1943 rg_log_enter("git_update_tag: " . rg_array2string($a)); rg_log_enter("git_update_tag: " . rg_array2string($a));
1903 1944
 
... ... function rg_git_update_tag($db, $a)
1912 1953 $history['ui_login']['uid'] = $a['login_uid']; $history['ui_login']['uid'] = $a['login_uid'];
1913 1954
1914 1955 if (strcmp($a['new_rev_type'], "tag") == 0) { // Annotated if (strcmp($a['new_rev_type'], "tag") == 0) { // Annotated
1915 if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create
1956 if ((strcmp($a['old_rev'], RG_GIT_ZERO) == 0)
1957 || (strcmp($a['old_rev'], RG_GIT_ZERO_SHA256) == 0)) { // create
1916 1958 $x['needed_rights'] = 'S'; $x['needed_rights'] = 'S';
1917 1959 if (rg_rights_allow($db, $x) !== TRUE) if (rg_rights_allow($db, $x) !== TRUE)
1918 1960 rg_git_fatal($a['refname'] . "\nNo rights to" rg_git_fatal($a['refname'] . "\nNo rights to"
 
... ... function rg_git_update_tag($db, $a)
1920 1962 $history['history_category'] = REPO_CAT_GIT_ATAG_CREATE; $history['history_category'] = REPO_CAT_GIT_ATAG_CREATE;
1921 1963 $history['history_message'] = 'Annotated tag ' $history['history_message'] = 'Annotated tag '
1922 1964 . $a['refname'] . ' created (' . $a['new_rev'] . ')'; . $a['refname'] . ' created (' . $a['new_rev'] . ')';
1923 } else if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete
1965 } else if ((strcmp($a['new_rev'], RG_GIT_ZERO) == 0)
1966 || (strcmp($a['new_rev'], RG_GIT_ZERO_SHA256) == 0)) { // delete
1924 1967 rg_log("delete ann tag"); rg_log("delete ann tag");
1925 1968 $x['needed_rights'] = 'n'; $x['needed_rights'] = 'n';
1926 1969 if (rg_rights_allow($db, $x) !== TRUE) if (rg_rights_allow($db, $x) !== TRUE)
 
... ... function rg_git_update_tag($db, $a)
1942 1985 . $a['old_rev'] . ' to ' . $a['new_rev']; . $a['old_rev'] . ' to ' . $a['new_rev'];
1943 1986 } }
1944 1987 } else { // Un-annotated } else { // Un-annotated
1945 if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create
1988 if ((strcmp($a['old_rev'], RG_GIT_ZERO) == 0)
1989 || (strcmp($a['old_rev'], RG_GIT_ZERO_SHA256) == 0)) { // create
1946 1990 $x['needed_rights'] = 'Y'; $x['needed_rights'] = 'Y';
1947 1991 if (rg_rights_allow($db, $x) !== TRUE) if (rg_rights_allow($db, $x) !== TRUE)
1948 1992 rg_git_fatal($a['refname'] . "\nNo rights to" rg_git_fatal($a['refname'] . "\nNo rights to"
 
... ... function rg_git_update_tag($db, $a)
1951 1995 $history['history_message'] = 'Un-annotated tag ' $history['history_message'] = 'Un-annotated tag '
1952 1996 . $a['refname'] . ' created' . $a['refname'] . ' created'
1953 1997 . ' (' . $a['new_rev'] . ')'; . ' (' . $a['new_rev'] . ')';
1954 } else if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete
1998 } else if ((strcmp($a['new_rev'], RG_GIT_ZERO) == 0)
1999 || (strcmp($a['new_rev'], RG_GIT_ZERO_SHA256) == 0)) { // delete
1955 2000 $x['needed_rights'] = 'u'; $x['needed_rights'] = 'u';
1956 2001 if (rg_rights_allow($db, $x) !== TRUE) if (rg_rights_allow($db, $x) !== TRUE)
1957 2002 rg_git_fatal($a['refname'] . "\nNo rights to" rg_git_fatal($a['refname'] . "\nNo rights to"
 
... ... function rg_git_update_tag($db, $a)
1996 2041 */ */
1997 2042 function rg_git_update_branch($db, $a) function rg_git_update_branch($db, $a)
1998 2043 { {
1999 global $rg_git_zero;
2000
2001 2044 rg_prof_start("git_update_branch"); rg_prof_start("git_update_branch");
2002 2045 rg_log_enter("git_update_branch: " . rg_array2string($a)); rg_log_enter("git_update_branch: " . rg_array2string($a));
2003 2046
 
... ... function rg_git_update_branch($db, $a)
2012 2055 $history['ri']['repo_id'] = $a['repo_id']; $history['ri']['repo_id'] = $a['repo_id'];
2013 2056 $history['ui_login']['uid'] = $a['login_uid']; $history['ui_login']['uid'] = $a['login_uid'];
2014 2057
2015 if (strcmp($a['new_rev'], $rg_git_zero) == 0) { // delete
2058 if ((strcmp($a['new_rev'], RG_GIT_ZERO) == 0)
2059 || (strcmp($a['new_rev'], RG_GIT_ZERO_SHA256) == 0)) { // delete
2016 2060 $x = $_x; $x = $_x;
2017 2061 $x['needed_rights'] = 'D'; $x['needed_rights'] = 'D';
2018 2062 if (rg_rights_allow($db, $x) !== TRUE) if (rg_rights_allow($db, $x) !== TRUE)
 
... ... function rg_git_update_branch($db, $a)
2027 2071
2028 2072 // If we have 'H' (anonymous push), we have also 'create branch' right // If we have 'H' (anonymous push), we have also 'create branch' right
2029 2073 $check_fast_forward = 1; $check_fast_forward = 1;
2030 if (strcmp($a['old_rev'], $rg_git_zero) == 0) { // create
2074 if ((strcmp($a['old_rev'], RG_GIT_ZERO) == 0)
2075 || (strcmp($a['old_rev'], RG_GIT_ZERO_SHA256) == 0)) { // create
2031 2076 $x = $_x; $x = $_x;
2032 2077 $x['needed_rights'] = 'H|C'; $x['needed_rights'] = 'H|C';
2033 2078 if (rg_rights_allow($db, $x) !== TRUE) if (rg_rights_allow($db, $x) !== TRUE)
 
... ... function rg_git_update_branch($db, $a)
2162 2207 rg_git_fatal($a['refname'] . ": " . rg_event_error()); rg_git_fatal($a['refname'] . ": " . rg_event_error());
2163 2208 rg_event_signal_daemon('', 0); rg_event_signal_daemon('', 0);
2164 2209
2165 if (strcmp($a['old_rev'], $rg_git_zero) == 0) {
2210 if ((strcmp($a['old_rev'], RG_GIT_ZERO) == 0)
2211 || (strcmp($a['old_rev'], RG_GIT_ZERO_SHA256) == 0)) {
2166 2212 $history['history_category'] = REPO_CAT_GIT_BRANCH_CREATE; $history['history_category'] = REPO_CAT_GIT_BRANCH_CREATE;
2167 2213 $history['history_message'] = 'Reference ' $history['history_message'] = 'Reference '
2168 2214 . $a['refname'] . ' created' . $a['refname'] . ' created'
 
... ... function rg_git_log2listing($log, $rg, $commit_table)
2415 2461 foreach ($log as $index => $i) foreach ($log as $index => $i)
2416 2462 $log[$index]['vars']['commit_url'] = $log[$index]['vars']['commit_url'] =
2417 2463 rg_xss_safe($rg['mr']['id']) rg_xss_safe($rg['mr']['id'])
2418 . "#sha1-" . rg_xss_safe($i['vars']['sha1']);
2464 . "#hash-" . rg_xss_safe($i['vars']['hash']);
2419 2465 $rg['HTML:commit_table'] = rg_git_log_template($log, $rg['HTML:commit_table'] = rg_git_log_template($log,
2420 2466 'repo/log', $rg); 'repo/log', $rg);
2421 2467 } else { } else {
 
... ... function rg_git_log2listing($log, $rg, $commit_table)
2447 2493 = gmdate("Y-m-d H:i", $i['vars']['committer date']); = gmdate("Y-m-d H:i", $i['vars']['committer date']);
2448 2494
2449 2495 // stats // stats
2450 $r = rg_git_files_stats($i['vars']['sha1'], $i['files'],
2496 $r = rg_git_files_stats($i['vars']['hash'], $i['files'],
2451 2497 'repo/fstat'); 'repo/fstat');
2452 2498 if ($r === FALSE) if ($r === FALSE)
2453 2499 $i['HTML:x_stats'] = rg_template('repo/err/stats.html', $rg, TRUE /*xss*/); $i['HTML:x_stats'] = rg_template('repo/err/stats.html', $rg, TRUE /*xss*/);
 
... ... function rg_git_log2listing($log, $rg, $commit_table)
2456 2502
2457 2503 // diff // diff
2458 2504 //rg_log_debug('i[files]=' . print_r($i['files'], TRUE)); //rg_log_debug('i[files]=' . print_r($i['files'], TRUE));
2459 $r = rg_git_diff($i['vars']['sha1'], $i['files'],
2505 $r = rg_git_diff($i['vars']['hash'], $i['files'],
2460 2506 'repo/diff.html'); 'repo/diff.html');
2461 2507 if ($r === FALSE) if ($r === FALSE)
2462 2508 $i['HTML:x_diff'] = rg_template('repo/err/diff.html', $rg, TRUE /*xss*/); $i['HTML:x_diff'] = rg_template('repo/err/diff.html', $rg, TRUE /*xss*/);
 
... ... function rg_git_archive($repo_path, $treeish, $archive_name, $format)
2530 2576 */ */
2531 2577 function rg_git_merge_tree($repo_path, $base, $a, $b) function rg_git_merge_tree($repo_path, $base, $a, $b)
2532 2578 { {
2533 global $rg_git_zero;
2534 global $rg_git_empty;
2535
2536 2579 rg_prof_start('git_merge_tree'); rg_prof_start('git_merge_tree');
2537 2580 rg_log_enter('git_merge_tree base=' rg_log_enter('git_merge_tree base='
2538 2581 . $base . ' a=' . $a . ' b=' . $b); . $base . ' a=' . $a . ' b=' . $b);
 
... ... function rg_git_merge_tree($repo_path, $base, $a, $b)
2543 2586 if ($r === -1) if ($r === -1)
2544 2587 break; break;
2545 2588
2546 if ($r === 1)
2547 $a = $rg_git_empty;
2589 if ($r === 1) {
2590 $hash = rg_git_repo_get_hash($repo_path);
2591 if (empty($hash))
2592 break;
2593 if (strcmp($hash, 'sha1') == 0)
2594 $a = RG_GIT_EMPTY;
2595 else
2596 $a = RG_GIT_EMPTY_SHA256;
2597 }
2548 2598
2549 2599 $head = rg_git_load_ref($repo_path, $a); $head = rg_git_load_ref($repo_path, $a);
2550 2600 if ($head === FALSE) if ($head === FALSE)
 
... ... function rg_git_merge_without_conflict($repo_path, $a, $b)
2639 2689 */ */
2640 2690 function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg) function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2641 2691 { {
2642 global $rg_git_zero;
2643 global $rg_git_empty;
2644
2645 2692 rg_prof_start('git_merge'); rg_prof_start('git_merge');
2646 2693 rg_log_enter('git_merge' . ' ref_name=' . $ref_name rg_log_enter('git_merge' . ' ref_name=' . $ref_name
2647 2694 . ' new=' . $new . ' ff=' . $ff . ' msg=[' . $msg . ']'); . ' new=' . $new . ' ff=' . $ff . ' msg=[' . $msg . ']');
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2652 2699 if ($r === -1) if ($r === -1)
2653 2700 break; break;
2654 2701
2655 if ($r === 1)
2656 $ref_name_tmp = $rg_git_empty;
2657 else
2702 if ($r === 1) {
2703 $hash = rg_git_repo_get_hash($repo_path);
2704 if (empty($hash))
2705 break;
2706 if (strcmp($hash, 'sha1') == 0)
2707 $ref_name_tmp = RG_GIT_EMPTY;
2708 else
2709 $ref_name_tmp = RG_GIT_EMPTY_SHA256;
2710 } else {
2658 2711 $ref_name_tmp = $ref_name; $ref_name_tmp = $ref_name;
2712 }
2659 2713
2660 2714 $r = rg_git_lock($repo_path, 60); $r = rg_git_lock($repo_path, 60);
2661 2715 if ($r === FALSE) if ($r === FALSE)
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2678 2732 rg_log_debug('ref_name points to ' . $cur); rg_log_debug('ref_name points to ' . $cur);
2679 2733
2680 2734 // If repo was empty, we are forced to do a ff // If repo was empty, we are forced to do a ff
2681 if (strcmp($mb, $rg_git_empty) == 0) {
2735 if ((strcmp($mb, RG_GIT_EMPTY) == 0)
2736 || (strcmp($mb, RG_GIT_EMPTY_SHA256) == 0)) {
2682 2737 rg_log_debug('merge base is empty, allow fast-forward.'); rg_log_debug('merge base is empty, allow fast-forward.');
2683 2738 $ff = 1; $ff = 1;
2684 2739 } }
 
... ... function rg_git_merge($repo_path, $ref_name, $new, $ff, $msg)
2751 2806 */ */
2752 2807 function rg_git_request_pull($repo_path, $start, $url, $end, $patch) function rg_git_request_pull($repo_path, $start, $url, $end, $patch)
2753 2808 { {
2754 global $rg_git_zero;
2755 global $rg_git_empty;
2756
2757 2809 rg_prof_start('git_request_pull'); rg_prof_start('git_request_pull');
2758 2810 rg_log_enter('git_request_pull' . ' start=' . $start rg_log_enter('git_request_pull' . ' start=' . $start
2759 2811 . ' url=' . $url . ' end=' . $end . ' url=' . $url . ' end=' . $end
File inc/repo.inc.php changed (mode: 100644) (index 4bb4e42..72de84d)
... ... function rg_repo_cosmetic($db, &$row)
153 153
154 154 if (isset($row['disk_used_mb'])) if (isset($row['disk_used_mb']))
155 155 $row['disk_used'] = rg_1024($row['disk_used_mb'] * 1024 * 1024); $row['disk_used'] = rg_1024($row['disk_used_mb'] * 1024 * 1024);
156
157 if (empty($row['main_branch']))
158 $row['main_branch'] = 'main';
159
160 if (empty($row['hash']))
161 $row['hash'] = 'sha1';
156 162 } }
157 163
158 164 /* /*
 
... ... function rg_repo_event_storage_create($db, $e)
627 633 } }
628 634
629 635 if ($e['ri']['master'] == 0) { if ($e['ri']['master'] == 0) {
630 $r = rg_git_init($by_id_path);
636 $r = rg_git_init($by_id_path, $e['ri']['main_branch'],
637 $e['ri']['hash']);
631 638 if ($r === FALSE) { if ($r === FALSE) {
632 639 rg_repo_set_error("cannot init master" rg_repo_set_error("cannot init master"
633 640 . " (" . rg_git_error() . ")"); . " (" . rg_git_error() . ")");
 
... ... function rg_repo_edit($db, $ui_login, &$new)
1154 1161 $new['itime'] = time(); $new['itime'] = time();
1155 1162 $new['uid'] = $ui_login['uid']; $new['uid'] = $ui_login['uid'];
1156 1163 if (!isset($new['main_branch'])) if (!isset($new['main_branch']))
1157 $new['main_branch'] = '';
1164 $new['main_branch'] = 'main';
1158 1165
1159 1166 if ($new['repo_id'] == 0) { if ($new['repo_id'] == 0) {
1160 1167 $new['deleted'] = 0; $new['deleted'] = 0;
 
... ... function rg_repo_edit($db, $ui_login, &$new)
1166 1173 $sql = "INSERT INTO repos (uid, master, name" $sql = "INSERT INTO repos (uid, master, name"
1167 1174 . ", itime, max_commit_size, description" . ", itime, max_commit_size, description"
1168 1175 . ", git_dir_done, public, license, template" . ", git_dir_done, public, license, template"
1169 . ", main_branch)"
1176 . ", main_branch, hash)"
1170 1177 . " VALUES (@@uid@@, @@master@@, @@name@@" . " VALUES (@@uid@@, @@master@@, @@name@@"
1171 1178 . ", @@itime@@, @@max_commit_size@@" . ", @@itime@@, @@max_commit_size@@"
1172 1179 . ", @@description@@, 0, @@public@@" . ", @@description@@, 0, @@public@@"
1173 . ", @@license@@, @@template@@, @@main_branch@@)"
1180 . ", @@license@@, @@template@@, @@main_branch@@"
1181 . ", @@hash@@)"
1174 1182 . " RETURNING repo_id"; . " RETURNING repo_id";
1175 1183 } else { } else {
1176 1184 $sql = "UPDATE repos SET name = @@name@@" $sql = "UPDATE repos SET name = @@name@@"
 
... ... function rg_repo_edit($db, $ui_login, &$new)
1180 1188 . ", license = @@license@@" . ", license = @@license@@"
1181 1189 . ", template = @@template@@" . ", template = @@template@@"
1182 1190 . ", main_branch = @@main_branch@@" . ", main_branch = @@main_branch@@"
1191 . ", hash = @@hash@@"
1183 1192 . " WHERE repo_id = @@repo_id@@"; . " WHERE repo_id = @@repo_id@@";
1184 1193 } }
1185 1194 $res = rg_sql_query_params($db, $sql, $new); $res = rg_sql_query_params($db, $sql, $new);
 
... ... function rg_repo_edit_high_level($db, &$rg)
1734 1743 . 'Application version(s) affected?' . "\n\n" . 'Application version(s) affected?' . "\n\n"
1735 1744 . 'Steps to reproduce?'; . 'Steps to reproduce?';
1736 1745 $rg['ri']['main_branch'] = ''; $rg['ri']['main_branch'] = '';
1746 $rg['ri']['hash'] = 'sha1';
1737 1747 } }
1738 1748 break; break;
1739 1749 } }
 
... ... function rg_repo_edit_high_level($db, &$rg)
1747 1757 $rg['ri']['license'] = trim(rg_var_str('license')); $rg['ri']['license'] = trim(rg_var_str('license'));
1748 1758 $rg['ri']['template'] = trim(rg_var_str('template')); $rg['ri']['template'] = trim(rg_var_str('template'));
1749 1759 $rg['ri']['main_branch'] = trim(rg_var_str_nocr('main_branch')); $rg['ri']['main_branch'] = trim(rg_var_str_nocr('main_branch'));
1760 $rg['ri']['hash'] = trim(rg_var_str_nocr('hash'));
1750 1761 rg_repo_cosmetic($db, $rg['ri']); rg_repo_cosmetic($db, $rg['ri']);
1751 1762 //rg_log_ml("CHECK: after repo edit: rg[ri]=" . print_r($rg['ri'], TRUE)); //rg_log_ml("CHECK: after repo edit: rg[ri]=" . print_r($rg['ri'], TRUE));
1752 1763
File inc/struct.inc.php changed (mode: 100644) (index 33ee0ed..94d02b6)
... ... $rg_sql_struct[48]['other'] = array(
754 754 'conns_flags' => 'ALTER TABLE conns ADD flags TEXT DEFAULT \'\'' 'conns_flags' => 'ALTER TABLE conns ADD flags TEXT DEFAULT \'\''
755 755 ); );
756 756 $rg_sql_struct_parts['build_stats'] = array('extra_index' => array('job_id')); $rg_sql_struct_parts['build_stats'] = array('extra_index' => array('job_id'));
757 // Here 0.76 was released
758
759 $rg_sql_struct[49]['tables'] = array();
760 $rg_sql_struct[49]['other'] = array(
761 'repo_hash' => 'ALTER TABLE repos ADD hash TEXT DEFAULT \'sha1\''
762 );
763 // Here 0.77 was released
757 764
758 765 // Do not forget to add the new created tables to statistics. // Do not forget to add the new created tables to statistics.
759 766
File root/themes/default/hints/repo/clone_owner.html changed (mode: 100644) (index 5f001ea..128ece2)
2 2 If you have the project locally, but not versioned with Git:<br /> If you have the project locally, but not versioned with Git:<br />
3 3 <div class="xcode"> <div class="xcode">
4 4 cd local_project_dir<br /> cd local_project_dir<br />
5 git init<br />
5 git init --initial-branch @@ri::main_branch@@ --object-format @@ri::hash@@<br />
6 6 git remote add origin @@ri::clone_url_http@@<br /> git remote add origin @@ri::clone_url_http@@<br />
7 7 # or<br /> # or<br />
8 8 git remote add origin @@ri::clone_url_ssh@@<br /> git remote add origin @@ri::clone_url_ssh@@<br />
File root/themes/default/repo/add_edit.html changed (mode: 100644) (index 2ac3404..e3be131)
36 36 </p> </p>
37 37
38 38 <p> <p>
39 <label for="main_branch">Main branch name (empty = auto-detect)</label><br />
39 <label for="main_branch">Main branch name (empty = main)</label><br />
40 40 <input type="text" name="main_branch" id="main_branch" value="@@ri::main_branch@@" /> <input type="text" name="main_branch" id="main_branch" value="@@ri::main_branch@@" />
41 41 </p> </p>
42 42
43 <p>
44 <label for="hash">Object format (SHA-256 is experimental)</label><br />
45 <select name="hash" id="hash">
46 <option value="sha1"@@if(@@ri::hash@@ == sha1){{ selected="selected"}}{{}}>SHA-1</option>
47 <option value="sha256"@@if(@@ri::hash@@ == sha256){{ selected="selected"}}{{}}>SHA-256</option>
48 </select>
49 </p>
50
43 51 <p> <p>
44 52 <label for="template">Bug template</label><br /> <label for="template">Bug template</label><br />
45 53 <textarea name="template" id="template" rows="6">@@ri::template@@</textarea> <textarea name="template" id="template" rows="6">@@ri::template@@</textarea>
File root/themes/default/repo/commits/line.html changed (mode: 100644) (index ec190d8..50d59ee)
1 <div id="sha1-@@vars::sha1@@" class="commit_details">
2 <b>Commit @@vars::sha1@@</b>
1 <div id="hash-@@vars::hash@@" class="commit_details">
2 <b>Commit @@vars::hash@@</b>
3 3 - @@vars::subject@@<br /> - @@vars::subject@@<br />
4 4
5 5 @@vars::x_body@@ @@vars::x_body@@
File root/themes/default/repo/log/line.html changed (mode: 100644) (index cb19dbd..d6be5c4)
1 1 <tr> <tr>
2 2 <td>@@subject@@</td> <td>@@subject@@</td>
3 <td><a href="@@if("@@commit_url@@" != ""){{@@commit_url@@}}{{@@url_repo@@/source/log/commit/@@sha1@@}}">@@sha1@@</a></td>
3 <td><a href="@@if("@@commit_url@@" != ""){{@@commit_url@@}}{{@@url_repo@@/source/log/commit/@@hash@@}}">@@hash@@</a></td>
4 4 <td>@@author name@@</td> <td>@@author name@@</td>
5 5 <td>@@author date UTC@@</td> <td>@@author date UTC@@</td>
6 6 </tr> </tr>
File root/themes/default/repo/main.html changed (mode: 100644) (index 23f3b40..8242e10)
6 6 <span class="repo_title_info"> <span class="repo_title_info">
7 7 (@@if(@@ri::public@@ == 1){{public}}{{private}}) (@@if(@@ri::public@@ == 1){{public}}{{private}})
8 8 (License: @@if("@@ri::license@@" == ""){{Unspecified}}{{@@ri::license@@}}) (License: @@if("@@ri::license@@" == ""){{Unspecified}}{{@@ri::license@@}})
9 (since @@ri::itime_nice@@)
9 (since @@ri::itime_nice@@) (hash @@ri::hash@@)
10 10 </span> </span>
11 11 <div class="buttons">@@watch_form@@ @@watch_error@@</div> <div class="buttons">@@watch_form@@ @@watch_error@@</div>
12 12 </div> </div>
File tests/_run_tests.sh changed (mode: 100755) (index 37456df..7c53857)
2 2
3 3 . ./env.txt . ./env.txt
4 4
5 tests="pkg_subrepo pkg_rpm gpg http_api http_304 ldap_core ldap \
5 tests="git-sha256 pkg_subrepo pkg_rpm gpg http_api http_304 ldap_core ldap \
6 6 admin_set_web git_big_push admin_set_git by_http wh_lambda http_keys \ admin_set_web git_big_push admin_set_git by_http wh_lambda http_keys \
7 7 http_forgot \ http_forgot \
8 8 api wh_cloud pr_anon wh_http ssh http_totp totp git_log1 \ api wh_cloud pr_anon wh_http ssh http_totp totp git_log1 \
File tests/git-sha256.php added (mode: 100644) (index 0000000..7278120)
1 <?php
2 error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
4
5 $test_normal = TRUE;
6
7 $INC = dirname(__FILE__) . "/../inc";
8 require_once(dirname(__FILE__) . "/config.php");
9 require_once($INC . "/init.inc.php");
10 require_once($INC . "/git.inc.php");
11 require_once("helpers.inc.php");
12 require_once("http.inc.php");
13
14 rg_log_set_file("git-sha256.log");
15
16 require_once("common.php");
17
18 $_testns = 'git-sha256';
19
20
21 rg_log('');
22 rg_log_enter('Preparing repo...');
23 $r = rg_exec('mkdir -p temp_repos'
24 . ' && rm -rf temp_repos/git-sha256'
25 . ' && mkdir temp_repos/git-sha256'
26 . ' && cd temp_repos/git-sha256'
27 . ' && git init --initial-branch=main --object-format=sha256'
28 . ' && echo "a signature" > bla.txt'
29 . ' && git add bla.txt'
30 . ' && git commit -a -m "bla"',
31 '', FALSE, FALSE, FALSE);
32 if ($r['ok'] != 1) {
33 rg_log_ml('out: ' . print_r($r, TRUE));
34 rg_log('Seems init repo!');
35 exit(1);
36 }
37 rg_log_exit();
38
39
40 rg_test_create_user($db, $rg_ui);
41 $info = array('id' => $rg_ui['username']);
42 prepare_http($info);
43
44 $repo = array('hash' => 'sha256');
45 rg_test_create_repo($db, $rg_ui, $repo);
46
47 $r = test_login($test_url, $rg_ui);
48 if ($r === FALSE) {
49 rg_log("Cannot login!");
50 exit(1);
51 }
52
53 rg_test_upload_ssh_key($db, $rg_ui, 'git-sha256', $kn);
54
55
56 rg_log('');
57 rg_log_enter('Trying to push main...');
58 $remote = 'ssh://rocketgit@' . $rg_ssh_host . ':' .$rg_ssh_port
59 . '/user/' . escapeshellarg($rg_ui['username'])
60 . '/' . escapeshellarg($repo['name']);
61 $r = rg_exec("cd temp_repos/git-sha256 && git remote add origin $remote"
62 . " && git push origin main",
63 '', FALSE, FALSE, FALSE);
64 if ($r['ok'] != 1) {
65 rg_log_ml('out: ' . print_r($r, TRUE));
66 rg_log('Seems I cannot push main!');
67 exit(1);
68 }
69 rg_log_exit();
70
71
72 rg_log('');
73 rg_log_enter('Trying to push tags...');
74 $r = rg_exec("cd temp_repos/git-sha256 && git push --tags",
75 '', FALSE, FALSE, FALSE);
76 if ($r['ok'] != 1) {
77 rg_log_ml('error: ' . $r['errmsg']);
78 rg_log("Seems I cannot push tags!");
79 exit(1);
80 }
81 rg_log_exit();
82
83
84 $commit = trim(@file_get_contents('git-sha256/.git/refs/heads/main'));
85 rg_log("Loaded main from .git: $commit");
86
87 rg_log('');
88 rg_log_enter('Checking on web that everything is OK...');
89 $data = array();
90 $headers = array();
91 $r = do_req($info, $test_url . '/user/' . rawurlencode($rg_ui['username'])
92 . '/' . rawurlencode($repo['name']) . '/source/log/commit/'
93 . $commit, $data, $headers);
94 if ($r === FALSE) {
95 rg_log("Cannot load main commit!");
96 exit(1);
97 }
98 rg_log_exit();
99
100
101 rg_log('');
102 rg_log_enter('Checking on web that tag is OK...');
103 $data = array();
104 $headers = array();
105 $r = do_req($info, $test_url . '/user/' . rawurlencode($rg_ui['username'])
106 . '/' . rawurlencode($repo['name'])
107 . '/source/tree/tag/unannot1/blob/bla.txt', $data, $headers);
108 if (strstr($r['body'], 'a signature') === FALSE) {
109 rg_log_ml("r: " . print_r($r, TRUE));
110 rg_log_ml('Cannot see \'a signature\'!');
111 exit(1);
112 }
113 rg_log_exit();
114
115
116 rg_log('');
117 rg_log_enter('Trying to push a sha1 repo into a sha256 repo...');
118 $r = rg_exec('rm -rf temp_repos/git-sha256'
119 . ' && mkdir temp_repos/git-sha256'
120 . ' && cd temp_repos/git-sha256'
121 . ' && git init --initial-branch=main --object-format sha1'
122 . ' && echo "bla" > bla.txt && git add bla.txt && git commit -m "bla"'
123 . ' && git remote add origin ' . $remote
124 . ' && git push --force origin main',
125 '', FALSE, FALSE, FALSE);
126 if (($r['ok'] == 1) || !strstr($r['stderr'], 'the receiving end does not support this repository\'s hash algorithm')) {
127 rg_log_ml('out: ' . print_r($r, TRUE));
128 rg_log('Seems I can push sha1 into sha256!');
129 exit(1);
130 }
131 rg_log_exit();
132
133
134 rg_log('OK!');
File tests/git.php changed (mode: 100644) (index 42ee65b..ef7c22c)
... ... if ($r['ok'] != 1) {
30 30 } }
31 31 $r = rg_git_merge_base('temp_repos/git_empty', 'main', $r = rg_git_merge_base('temp_repos/git_empty', 'main',
32 32 '3fa5ae7e933e33308a6f3ec70edcf2499c1914ac'); '3fa5ae7e933e33308a6f3ec70edcf2499c1914ac');
33 if ($r !== $rg_git_empty) {
34 rg_log('Test must return ' . $rg_git_empty . ' but returned: ' . $r);
33 if ($r !== RG_GIT_EMPTY) {
34 rg_log('Test must return ' . RG_GIT_EMPTY . ' but returned: ' . $r);
35 35 exit(1); exit(1);
36 36 } }
37 37 rg_log_exit(); rg_log_exit();
 
... ... rg_log_exit();
154 154
155 155 rg_log(''); rg_log('');
156 156 rg_log_enter("[*] Checking if git-init works..."); rg_log_enter("[*] Checking if git-init works...");
157 $r = rg_git_init("git.tmp");
157 $r = rg_git_init("git.tmp", 'main', 'sha1');
158 158 if ($r !== TRUE) { if ($r !== TRUE) {
159 159 rg_log("Cannot run rg_git_init (" . rg_git_error() . ")!"); rg_log("Cannot run rg_git_init (" . rg_git_error() . ")!");
160 160 exit(1); exit(1);
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main