File inc/git.inc.php changed (mode: 100644) (index 8b8cd67..614f334) |
... |
... |
$rg_git_zero = "0000000000000000000000000000000000000000"; |
12 |
12 |
$rg_git_empty = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"; |
$rg_git_empty = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"; |
13 |
13 |
define('GIT_LINK_MASK', intval(base_convert('160000', 8, 10))); |
define('GIT_LINK_MASK', intval(base_convert('160000', 8, 10))); |
14 |
14 |
|
|
|
15 |
|
define ('RG_GIT_CMD', 'git -c gc.auto=0'); |
|
16 |
|
|
15 |
17 |
$rg_git_error = ""; |
$rg_git_error = ""; |
16 |
18 |
|
|
17 |
19 |
function rg_git_set_error($str) |
function rg_git_set_error($str) |
|
... |
... |
function rg_git_init($dst) |
228 |
230 |
// TODO: What to do if the creation fails? |
// TODO: What to do if the creation fails? |
229 |
231 |
if (!is_dir($dst . "/rocketgit")) { |
if (!is_dir($dst . "/rocketgit")) { |
230 |
232 |
$dst2 = $dst . '.tmp'; |
$dst2 = $dst . '.tmp'; |
231 |
|
$cmd = 'git init --bare ' . escapeshellarg($dst2); |
|
|
233 |
|
$cmd = RG_GIT_CMD . ' init --bare ' . escapeshellarg($dst2); |
232 |
234 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
233 |
235 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
234 |
236 |
rg_git_set_error("error on init " . $a['errmsg'] . ")"); |
rg_git_set_error("error on init " . $a['errmsg'] . ")"); |
|
... |
... |
function rg_git_clone($src, $dst) |
278 |
280 |
} |
} |
279 |
281 |
|
|
280 |
282 |
if (!file_exists($dst . "/rocketgit")) { |
if (!file_exists($dst . "/rocketgit")) { |
281 |
|
$cmd = "git clone --bare " . escapeshellarg($src) |
|
|
283 |
|
$cmd = RG_GIT_CMD . "clone --bare " . escapeshellarg($src) |
282 |
284 |
. " " . escapeshellarg($dst); |
. " " . escapeshellarg($dst); |
283 |
285 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
284 |
286 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
|
... |
... |
function rg_git_type($obj) |
321 |
323 |
break; |
break; |
322 |
324 |
} |
} |
323 |
325 |
|
|
324 |
|
$cmd = 'git cat-file -t ' . escapeshellarg($obj); |
|
|
326 |
|
$cmd = RG_GIT_CMD . ' cat-file -t ' . escapeshellarg($obj); |
325 |
327 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
326 |
328 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
327 |
329 |
rg_git_set_error('error on cat-file (' . $a['errmsg'] . ')'); |
rg_git_set_error('error on cat-file (' . $a['errmsg'] . ')'); |
|
... |
... |
function rg_git_content($obj) |
347 |
349 |
|
|
348 |
350 |
$ret = FALSE; |
$ret = FALSE; |
349 |
351 |
while (1) { |
while (1) { |
350 |
|
$cmd = 'git cat-file -p ' . escapeshellarg($obj); |
|
|
352 |
|
$cmd = RG_GIT_CMD . ' cat-file -p ' . escapeshellarg($obj); |
351 |
353 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
352 |
354 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
353 |
355 |
rg_git_set_error('error on cat-file (' . $a['errmsg'] . ')'); |
rg_git_set_error('error on cat-file (' . $a['errmsg'] . ')'); |
|
... |
... |
function rg_git_rev_ok($rev) |
424 |
426 |
|
|
425 |
427 |
$ret = FALSE; |
$ret = FALSE; |
426 |
428 |
while (1) { |
while (1) { |
427 |
|
$cmd = 'git rev-parse --verify ' . escapeshellarg($rev); |
|
|
429 |
|
$cmd = RG_GIT_CMD . ' rev-parse --verify ' . escapeshellarg($rev); |
428 |
430 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
429 |
431 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
430 |
432 |
rg_git_set_error("error on rev-parse (" . $a['errmsg'] . ")"); |
rg_git_set_error("error on rev-parse (" . $a['errmsg'] . ")"); |
|
... |
... |
function rg_git_whitespace_ok($old, $new) |
457 |
459 |
if (strcmp($old, $rg_git_zero) == 0) |
if (strcmp($old, $rg_git_zero) == 0) |
458 |
460 |
$old = $rg_git_empty; |
$old = $rg_git_empty; |
459 |
461 |
|
|
460 |
|
$cmd = "git diff --check" |
|
|
462 |
|
$cmd = RG_GIT_CMD . " diff --check" |
461 |
463 |
. " " . escapeshellarg($old) |
. " " . escapeshellarg($old) |
462 |
464 |
. " " . escapeshellarg($new); |
. " " . escapeshellarg($new); |
463 |
465 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
|
... |
... |
function rg_git_merge_base($repo_path, $a, $b) |
536 |
538 |
} |
} |
537 |
539 |
} |
} |
538 |
540 |
|
|
539 |
|
$cmd = 'git' |
|
|
541 |
|
$cmd = RG_GIT_CMD |
540 |
542 |
. $add |
. $add |
541 |
543 |
. ' merge-base' |
. ' merge-base' |
542 |
544 |
. ' ' . escapeshellarg($a) |
. ' ' . escapeshellarg($a) |
|
... |
... |
function rg_git_update_ref($repo_path, $ref, $old, $new, $reason) |
573 |
575 |
|
|
574 |
576 |
$ret = FALSE; |
$ret = FALSE; |
575 |
577 |
while (1) { |
while (1) { |
576 |
|
$cmd = 'git --git-dir=' . escapeshellarg($repo_path); |
|
577 |
|
$cmd .= ' update-ref'; |
|
|
578 |
|
$cmd = RG_GIT_CMD |
|
579 |
|
. ' --git-dir=' . escapeshellarg($repo_path) |
|
580 |
|
. ' update-ref'; |
578 |
581 |
|
|
579 |
582 |
if (!empty($reason)) |
if (!empty($reason)) |
580 |
583 |
$cmd .= " -m " . escapeshellarg($reason); |
$cmd .= " -m " . escapeshellarg($reason); |
|
... |
... |
function rg_git_shortlog($repo_path, $a, $b) |
613 |
616 |
|
|
614 |
617 |
$ret = FALSE; |
$ret = FALSE; |
615 |
618 |
while (1) { |
while (1) { |
616 |
|
$cmd = 'git shortlog' |
|
|
619 |
|
$cmd = RG_GIT_CMD . ' shortlog' |
617 |
620 |
. ' --git-dir=' . escapeshellarg($repo_path) |
. ' --git-dir=' . escapeshellarg($repo_path) |
618 |
621 |
. ' ' . escapeshellarg($a) |
. ' ' . escapeshellarg($a) |
619 |
622 |
. '..' . escapeshellarg($b); |
. '..' . escapeshellarg($b); |
|
... |
... |
function rg_git_ls_tree($repo_path, $tree, $path) |
649 |
652 |
$tree = " HEAD"; |
$tree = " HEAD"; |
650 |
653 |
} |
} |
651 |
654 |
|
|
652 |
|
$cmd = "git --git-dir=" . escapeshellarg($repo_path) |
|
|
655 |
|
$cmd = RG_GIT_CMD . " --git-dir=" . escapeshellarg($repo_path) |
653 |
656 |
. " ls-tree --long" . $op |
. " ls-tree --long" . $op |
654 |
657 |
. escapeshellarg($tree); |
. escapeshellarg($tree); |
655 |
658 |
if (!empty($path)) |
if (!empty($path)) |
|
... |
... |
function rg_git_log_simple($repo_path, $max, $from, $to, $also_patch, $files, |
1060 |
1063 |
$sep_start = '-=ROCKETGIT-START-' . $id . '=-'; |
$sep_start = '-=ROCKETGIT-START-' . $id . '=-'; |
1061 |
1064 |
$sep_end = '-=ROCKETGIT_END_OF_VARS-' . $id . '=-'; |
$sep_end = '-=ROCKETGIT_END_OF_VARS-' . $id . '=-'; |
1062 |
1065 |
|
|
1063 |
|
$cmd = "git --no-pager" |
|
|
1066 |
|
$cmd = RG_GIT_CMD . " --no-pager" |
1064 |
1067 |
. " --git-dir=" . escapeshellarg($repo_path) |
. " --git-dir=" . escapeshellarg($repo_path) |
1065 |
1068 |
. " log" |
. " log" |
1066 |
1069 |
. " --find-copies" |
. " --find-copies" |
|
... |
... |
function rg_git_files($old, $new) |
1545 |
1548 |
if (strcmp($old, $rg_git_zero) == 0) |
if (strcmp($old, $rg_git_zero) == 0) |
1546 |
1549 |
$old = $rg_git_empty; |
$old = $rg_git_empty; |
1547 |
1550 |
|
|
1548 |
|
$cmd = 'git diff --name-only ' . escapeshellarg($old) |
|
|
1551 |
|
$cmd = RG_GIT_CMD . ' diff --name-only ' . escapeshellarg($old) |
1549 |
1552 |
. ' ' . escapeshellarg($new); |
. ' ' . escapeshellarg($new); |
1550 |
1553 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
1551 |
1554 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
|
... |
... |
function rg_git_diff_tree($tree1, $tree2) |
2140 |
2143 |
|
|
2141 |
2144 |
$ret = FALSE; |
$ret = FALSE; |
2142 |
2145 |
while (1) { |
while (1) { |
2143 |
|
$cmd = "git diff-tree -r " . escapeshellarg($tree1) |
|
|
2146 |
|
$cmd = RG_GIT_CMD . " diff-tree -r " . escapeshellarg($tree1) |
2144 |
2147 |
. " " . escapeshellarg($tree2); |
. " " . escapeshellarg($tree2); |
2145 |
2148 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
2146 |
2149 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
|
... |
... |
function rg_git_content_by_file($treeish, $file) |
2185 |
2188 |
|
|
2186 |
2189 |
$ret = FALSE; |
$ret = FALSE; |
2187 |
2190 |
while (1) { |
while (1) { |
2188 |
|
$cmd = 'git show ' . escapeshellarg($treeish) . ':' |
|
|
2191 |
|
$cmd = RG_GIT_CMD . ' show ' . escapeshellarg($treeish) . ':' |
2189 |
2192 |
. escapeshellarg($file); |
. escapeshellarg($file); |
2190 |
2193 |
$a = rg_exec($cmd, '', FALSE, FALSE); |
$a = rg_exec($cmd, '', FALSE, FALSE); |
2191 |
2194 |
if ($a['ok'] != 1) { |
if ($a['ok'] != 1) { |
|
... |
... |
function rg_git_archive($repo_path, $treeish, $archive_name, $format) |
2297 |
2300 |
|
|
2298 |
2301 |
$ret = FALSE; |
$ret = FALSE; |
2299 |
2302 |
while (1) { |
while (1) { |
2300 |
|
$cmd = 'git --git-dir=' . escapeshellarg($repo_path) |
|
|
2303 |
|
$cmd = RG_GIT_CMD . ' --git-dir=' . escapeshellarg($repo_path) |
2301 |
2304 |
. ' archive --format=' . escapeshellarg($format) |
. ' archive --format=' . escapeshellarg($format) |
2302 |
2305 |
. ' --output=' . escapeshellarg($archive_name) |
. ' --output=' . escapeshellarg($archive_name) |
2303 |
2306 |
. ' ' . escapeshellarg($treeish); |
. ' ' . escapeshellarg($treeish); |
|
... |
... |
function rg_git_merge_tree($repo_path, $base, $a, $b) |
2365 |
2368 |
break; |
break; |
2366 |
2369 |
} |
} |
2367 |
2370 |
|
|
2368 |
|
$cmd = 'git --git-dir=' . escapeshellarg($repo_path) |
|
|
2371 |
|
$cmd = RG_GIT_CMD . ' --git-dir=' . escapeshellarg($repo_path) |
2369 |
2372 |
. ' merge-tree' |
. ' merge-tree' |
2370 |
2373 |
. ' ' . escapeshellarg($base) |
. ' ' . escapeshellarg($base) |
2371 |
2374 |
. ' ' . escapeshellarg($a) |
. ' ' . escapeshellarg($a) |
|
... |
... |
function rg_git_request_pull($repo_path, $start, $url, $end, $patch) |
2517 |
2520 |
break; |
break; |
2518 |
2521 |
$text .= $r; |
$text .= $r; |
2519 |
2522 |
|
|
2520 |
|
$cmd = 'git diff -M --stat --summary'; |
|
|
2523 |
|
$cmd = RG_GIT_CMD . ' diff -M --stat --summary'; |
2521 |
2524 |
if ($patch) |
if ($patch) |
2522 |
2525 |
$cmd .= ' --patch'; |
$cmd .= ' --patch'; |
2523 |
2526 |
$cmd .= escapeshellarg($start) . '..' . escapeshellarg($end); |
$cmd .= escapeshellarg($start) . '..' . escapeshellarg($end); |