From 376eb1f26d127a357517159d904eb993327c58ec Mon Sep 17 00:00:00 2001 From: Heikki Hokkanen Date: Sat, 24 May 2008 15:37:36 +0300 Subject: [PATCH] Pass commit hash as 'hb' for viewblob as well. --- doc/TODO | 4 +--- index.php | 18 +++++++++++++++++- templates/tree.php | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/TODO b/doc/TODO index 514ec7f..e230bb3 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,8 +1,6 @@ -- tree +- tree/blob - further directory/file viewing links should retain full path from commit in 'f' - main nav bar should show path "fragments" if present, and link to each -- blob - - pass base commit 'hb' as optional parameter - header pagenav: bolden current selection - commitdiff: after log, show changed files with section link to diff diff --git a/index.php b/index.php index 7324796..a85eb4b 100644 --- a/index.php +++ b/index.php @@ -403,16 +403,32 @@ elseif ($action === 'tree') { // for the header $info = git_get_commit_info($page['project']); $page['commit_id'] = $info['h']; - die('DEBUG'); } $page['entries'] = git_ls_tree($page['project'], $page['tree_id']); } +/* + * View a blob as inline, embedded on the page. + * @param p project + * @param h blob hash + * @param hb OPTIONAL base commit + */ elseif ($action === 'viewblob') { $template = 'blob'; $page['project'] = validate_project($_REQUEST['p']); $page['hash'] = validate_hash($_REQUEST['h']); $page['title'] = "$page[project] - Blob - ViewGit"; + if (isset($_REQUEST['hb'])) { + $page['commit_id'] = validate_hash($_REQUEST['hb']); + } + else { + $page['commit_id'] = 'HEAD'; + } + + // For the header's pagenav + $info = git_get_commit_info($page['project'], $page['commit_id']); + $page['commit_id'] = $info['h']; + $page['tree_id'] = $info['tree']; $page['data'] = join("\n", run_git($page['project'], "git cat-file blob $page[hash]")); } diff --git a/templates/tree.php b/templates/tree.php index 3312669..80355d5 100644 --- a/templates/tree.php +++ b/templates/tree.php @@ -12,7 +12,7 @@ foreach ($page['entries'] as $e) { if ($e['type'] === 'blob') { echo "\n"; echo "\t$e[mode]\n"; - echo "\t 'viewblob', 'p' => $page['project'], 'h' => $e['hash'])) ."\">". htmlspecialchars($e['name']) ."\n"; + echo "\t 'viewblob', 'p' => $page['project'], 'h' => $e['hash'], 'hb' => $page['commit_id'])) ."\">". htmlspecialchars($e['name']) ."\n"; echo "\t 'blob', 'p' => $page['project'], 'h' => $e['hash'], 'n' => $e['name'])) ."\">blob\n"; } else { -- 2.11.4.GIT