commit 089c1ca9e16cfa006ffc0840df8606f604f3510d Author: MoserMichael <mosermichael@gmail.com> AuthorDate: Tue Jan 6 08:20:32 2026 +0200 Commit: MoserMichael <mosermichael@gmail.com> CommitDate: Tue Jan 6 08:20:32 2026 +0200 fix root commit handling in git blame :100644 100644 87aadf6 577d5f2 M git_html_listing.sh diff --git a/git_html_listing.sh b/git_html_listing.sh index 87aadf6..577d5f2 100644 --- a/git_html_listing.sh +++ b/git_html_listing.sh @@ -95,7 +95,9 @@ for f in $(git ls-files); do cross_link_path=$(basename "${link_path}") - git blame --color-lines ${f} | ${script_dir}/ansi2html.sh | sed -E "s@^<span class=\"f([0-9]+)\">([0-9a-f]+)@<span class=\"f\1\"><a href=\"${cross_link_path}#\2\">\2</a>@" | sed -E "s@^([0-9a-f]+)@<a href=\"${cross_link_path}#\1\">\1</a>@" >${out_blame_html_path} + #git blame --color-lines ${f} | ${script_dir}/ansi2html.sh >${out_blame_html_path} + + git blame --root --color-lines ${f} | ${script_dir}/ansi2html.sh | sed -E "s@^<span class=\"f([0-9]+)\">([0-9a-f]+)@<span class=\"f\1\"><a href=\"${cross_link_path}#\2\">\2</a>@" | sed -E "s@^([0-9a-f]+)@<a href=\"${cross_link_path}#\1\">\1</a>@" >${out_blame_html_path} html_index="${html_index}<li> ${f} <a href=\"${link_path}\">Log</a> <a href=\"${blame_link_path}\">Blame</a> " commit ba16ef1f851c849ecccf33d81dce27ad381e06a1 Author: MoserMichael <mosermichael@gmail.com> AuthorDate: Tue Jan 6 07:55:37 2026 +0200 Commit: MoserMichael <mosermichael@gmail.com> CommitDate: Tue Jan 6 07:55:37 2026 +0200 fix link from blame to log :100644 100644 62e2015 87aadf6 M git_html_listing.sh diff --git a/git_html_listing.sh b/git_html_listing.sh index 62e2015..87aadf6 100644 --- a/git_html_listing.sh +++ b/git_html_listing.sh @@ -93,7 +93,9 @@ for f in $(git ls-files); do blame_link_path="${f}.blame.html" out_blame_html_path="${out_file}.blame.html" - git blame --color-lines ${f} | ${script_dir}/ansi2html.sh | sed -E "s@^<span class=\"f([0-9]+)\">([0-9a-f]+)@<span class=\"f\1\"><a href=\"${link_path}#\2\">\2</a>@" >${out_blame_html_path} + cross_link_path=$(basename "${link_path}") + + git blame --color-lines ${f} | ${script_dir}/ansi2html.sh | sed -E "s@^<span class=\"f([0-9]+)\">([0-9a-f]+)@<span class=\"f\1\"><a href=\"${cross_link_path}#\2\">\2</a>@" | sed -E "s@^([0-9a-f]+)@<a href=\"${cross_link_path}#\1\">\1</a>@" >${out_blame_html_path} html_index="${html_index}<li> ${f} <a href=\"${link_path}\">Log</a> <a href=\"${blame_link_path}\">Blame</a> " commit 451c39128b94c6d00d1efd82678d68ec83875fef Author: MoserMichael <mosermichael@gmail.com> AuthorDate: Tue Jan 6 07:41:14 2026 +0200 Commit: MoserMichael <mosermichael@gmail.com> CommitDate: Tue Jan 6 07:41:14 2026 +0200 add git blame to listing :100644 100644 561c867 62e2015 M git_html_listing.sh diff --git a/git_html_listing.sh b/git_html_listing.sh index 561c867..62e2015 100644 --- a/git_html_listing.sh +++ b/git_html_listing.sh @@ -82,16 +82,21 @@ for f in $(git ls-files); do dname=$(dirname "$out_file") mkdir -p "$dname" - link_name=${f} + #link_name=${f} link_path="${f}.html" out_html_path="${out_file}.html" echo "<html><body><h2>History listing for file: ${f}</h2>" >${out_html_path} - git log --color=always --follow --pretty=fuller -p --ignore-cr-at-eol --raw ${f} | ${script_dir}/ansi2html.sh >>${out_html_path} + git log --color=always --follow --pretty=fuller -p --ignore-cr-at-eol --raw ${f} | ${script_dir}/ansi2html.sh | sed -E 's/^<span class="f3">commit (([0-9a-f]{8})[0-9a-f]+)<\/span>/<span class="f3"><a name="\2"\/>commit \1<\/span>/' >${out_html_path} + + blame_link_path="${f}.blame.html" + out_blame_html_path="${out_file}.blame.html" - html_index="${html_index}<li><a href=\"${link_path}\">$f</a>" + git blame --color-lines ${f} | ${script_dir}/ansi2html.sh | sed -E "s@^<span class=\"f([0-9]+)\">([0-9a-f]+)@<span class=\"f\1\"><a href=\"${link_path}#\2\">\2</a>@" >${out_blame_html_path} + html_index="${html_index}<li> ${f} <a href=\"${link_path}\">Log</a> <a href=\"${blame_link_path}\">Blame</a> " + done echo "${html_prefix}${html_index}" >${out_dir}/index.html commit 568c0ac627f28595e8ad3cb81ad63024ca18434b Author: MoserMichael <mosermichael@gmail.com> AuthorDate: Thu Nov 20 08:29:50 2025 +0200 Commit: MoserMichael <mosermichael@gmail.com> CommitDate: Thu Nov 20 08:29:50 2025 +0200 fix header :100644 100644 1157340 561c867 M git_html_listing.sh diff --git a/git_html_listing.sh b/git_html_listing.sh index 1157340..561c867 100644 --- a/git_html_listing.sh +++ b/git_html_listing.sh @@ -56,9 +56,6 @@ script_dir=$(dirname $0) script_dir=$(realpath "${script_dir}") html_index="" -origin_url=$(git config --get remote.origin.url) -html_prefix="<html><body><h2>History listing for git repository: ${origin_url}</h2><ul>" - #if [[ -d "$out_dir" ]]; then # rm -rf "$out_dir" #fi @@ -75,6 +72,9 @@ mkdir -p "$out_dir" pushd "$git_dir" +origin_url=$(git config --get remote.origin.url) +html_prefix="<html><body><h2>History listing for git repository: ${origin_url}</h2><ul>" + for f in $(git ls-files); do echo "Processing $f" out_file="$out_dir/$f" commit 68e600ab0f073de653a350bd827deda6926271b0 Author: MoserMichael <mosermichael@gmail.com> AuthorDate: Thu Nov 20 08:26:00 2025 +0200 Commit: MoserMichael <mosermichael@gmail.com> CommitDate: Thu Nov 20 08:26:00 2025 +0200 fix options :100644 100644 1a25db4 1157340 M git_html_listing.sh diff --git a/git_html_listing.sh b/git_html_listing.sh index 1a25db4..1157340 100644 --- a/git_html_listing.sh +++ b/git_html_listing.sh @@ -32,15 +32,12 @@ while getopts "hg:o:" opt; do git_dir=$OPTARG ;; o) - DOCKER_REGISTRY_REPOSITORY_NAME=$OPTARG - ;; - r) - DOCKER_REGISTRY=$OPTARG + out_dir=$OPTARG ;; v) - set -x - export PS4='+(${BASH_SOURCE}:${LINENO})' - VERBOSE=1 + set -x + export PS4='+(${BASH_SOURCE}:${LINENO})' + VERBOSE=1 ;; *) Help "Invalid option" commit e2781be8146fa40cb6891240cddc8a57a43bf4ee Author: MoserMichael <mosermichael@gmail.com> AuthorDate: Thu Nov 20 07:42:31 2025 +0200 Commit: MoserMichael <mosermichael@gmail.com> CommitDate: Thu Nov 20 07:42:31 2025 +0200 add command line options :100644 100644 a51089f 1a25db4 M git_html_listing.sh diff --git a/git_html_listing.sh b/git_html_listing.sh index a51089f..1a25db4 100644 --- a/git_html_listing.sh +++ b/git_html_listing.sh @@ -2,13 +2,59 @@ # Licence: LGPLv2 -out_dir="temp_dir" +out_dir="html_history_listing" git_dir="." +function Help() +{ + if [[ $1 != "" ]]; then + echo "Error: $*" + fi + + cat <<EOF +Usage: $0 -g <git_repo_directory> -o <html_output_directory> [-v] [-h] + +A shell script for producing a nice html listing for the history of each file. +The script creates a index.html file that contains a link per html file in given git repository. +Each linked html file contains the change log for one file contained in the repository. + + +EOF + exit 1 +} + +while getopts "hg:o:" opt; do + case ${opt} in + h) + Help + ;; + g) + git_dir=$OPTARG + ;; + o) + DOCKER_REGISTRY_REPOSITORY_NAME=$OPTARG + ;; + r) + DOCKER_REGISTRY=$OPTARG + ;; + v) + set -x + export PS4='+(${BASH_SOURCE}:${LINENO})' + VERBOSE=1 + ;; + *) + Help "Invalid option" + ;; + esac +done out_dir=$(realpath "${out_dir}") git_dir=$(realpath "${git_dir}") +if [[ ! -d "$git_dir" ]]; then + Help "git repo directory ${git_dir} does not exist" +fi + script_dir=$(dirname $0) script_dir=$(realpath "${script_dir}") html_index="" @@ -20,6 +66,14 @@ html_prefix="<html><body><h2>History listing for git repository: ${origin_url}</ # rm -rf "$out_dir" #fi +cat <<EOF +** building html listing ** + +For repository directory: ${git_dir} +html listing directory: ${out_dir} + +EOF + mkdir -p "$out_dir" pushd "$git_dir" commit 1aba1075367fd497503b8b4b976c19ed4c95e600 Author: MoserMichael <mosermichael@gmail.com> AuthorDate: Thu Nov 20 07:23:47 2025 +0200 Commit: MoserMichael <mosermichael@gmail.com> CommitDate: Thu Nov 20 07:23:47 2025 +0200 path changes :100644 100644 ba8a116 a51089f M git_html_listing.sh diff --git a/git_html_listing.sh b/git_html_listing.sh index ba8a116..a51089f 100644 --- a/git_html_listing.sh +++ b/git_html_listing.sh @@ -5,6 +5,7 @@ out_dir="temp_dir" git_dir="." + out_dir=$(realpath "${out_dir}") git_dir=$(realpath "${git_dir}") @@ -13,7 +14,7 @@ script_dir=$(realpath "${script_dir}") html_index="" origin_url=$(git config --get remote.origin.url) -html_prefix="<html><body><h2>History listing for git repository ${origin_url}</h2><ul>" +html_prefix="<html><body><h2>History listing for git repository: ${origin_url}</h2><ul>" #if [[ -d "$out_dir" ]]; then # rm -rf "$out_dir" @@ -30,9 +31,11 @@ for f in $(git ls-files); do dname=$(dirname "$out_file") mkdir -p "$dname" - link_name=${f%.*} + link_name=${f} link_path="${f}.html" - out_html_path="${out_file%.*}.html" + out_html_path="${out_file}.html" + + echo "<html><body><h2>History listing for file: ${f}</h2>" >${out_html_path} git log --color=always --follow --pretty=fuller -p --ignore-cr-at-eol --raw ${f} | ${script_dir}/ansi2html.sh >>${out_html_path} commit 0e6c62ee691b35961cd9b3a9e72af5f4ea496310 Author: MoserMichael <mosermichael@gmail.com> AuthorDate: Thu Nov 20 07:17:15 2025 +0200 Commit: MoserMichael <mosermichael@gmail.com> CommitDate: Thu Nov 20 07:17:15 2025 +0200 zeroth version :000000 100644 0000000 ba8a116 A git_html_listing.sh diff --git a/git_html_listing.sh b/git_html_listing.sh new file mode 100644 index 0000000..ba8a116 --- /dev/null +++ b/git_html_listing.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +# Licence: LGPLv2 + +out_dir="temp_dir" +git_dir="." + +out_dir=$(realpath "${out_dir}") +git_dir=$(realpath "${git_dir}") + +script_dir=$(dirname $0) +script_dir=$(realpath "${script_dir}") +html_index="" + +origin_url=$(git config --get remote.origin.url) +html_prefix="<html><body><h2>History listing for git repository ${origin_url}</h2><ul>" + +#if [[ -d "$out_dir" ]]; then +# rm -rf "$out_dir" +#fi + +mkdir -p "$out_dir" + +pushd "$git_dir" + +for f in $(git ls-files); do + echo "Processing $f" + out_file="$out_dir/$f" + + dname=$(dirname "$out_file") + mkdir -p "$dname" + + link_name=${f%.*} + link_path="${f}.html" + out_html_path="${out_file%.*}.html" + + git log --color=always --follow --pretty=fuller -p --ignore-cr-at-eol --raw ${f} | ${script_dir}/ansi2html.sh >>${out_html_path} + + html_index="${html_index}<li><a href=\"${link_path}\">$f</a>" + +done + +echo "${html_prefix}${html_index}" >${out_dir}/index.html + + +