aboutsummaryrefslogtreecommitdiff
path: root/sib-log
blob: 31ada287f7f2163e35a431773eff59a6ecaa862c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
# Copyright 2026 Hee-Suk Kim <[email protected]>
# SPDX-License-Identifier: GPL-3.0-only

. lib.bash

usage() {
    cat <<EOF
usage: ${NAME} [-n <lines>] [<chain-ish>]
  -n Truncate content to LINES (disables markdown rendering)
  -h Show this help
EOF
}

n_lines=
while [[ $# -gt 0 ]]; do
    case "$1" in
        -h) usage; exit 0 ;;
        -n) n_lines="${2:?$1 requires arg}"; shift 2 ;;
        -*) echo "unknown arg: $1" >&2; usage; exit 1 ;;
        *) break ;;
    esac
done

[[ $# -le 1 ]] || { usage >&2; die; }
target="${1:-HEAD}"
tid=$(sib rev-parse "$target" 2>/dev/null) || die invalid chain-ish $target

show_args=()
[[ -n $n_lines ]] && show_args=(-n "$n_lines")

sib rev-list "$tid" | while read -r chain; do
    SIB_SHOW_RESOLVED=1 sib-show "${show_args[@]}" $chain
    echo
    echo ---
    echo
done