$ show xiaoshanyan9/git-log-tree
git-log-tree is a single-file Bash CLI tool that renders a fancy, colored git log graph in the terminal. It wraps `git log` with `--topo-order`, `--parents`, and a custom pretty format, then parses the output to draw a tree using Unicode box-drawing characters and ANSI colors. The script handles complex branching, merges, and orphan commits, assigning colors to branches with an algorithm that minimizes reuse and ensures contrast. It respects the `NO_COLOR` environment variable and auto-detects color support. The tool pipes output through `less -F -R -S -X` for paging. The repository includes a comprehensive BATS test that creates a synthetic git history via fast-import and verifies the exact rendered output, along with a GitHub Actions workflow for coverage via kcov. The code is well-structured for a Bash script, using associative arrays and bit manipulation for efficient color sorting, but is monolithic with global state, limiting component reusability.
The LLM identified 1 files worth highlighting for reuse:
The color assignment algorithm (functions init_colors, set_branch_color, assign_branch_color, remove_branch_color) is a self-contained pattern for assigning colors to branches in a graph while avoiding reuse of the same color as the previous branch and the last used color for that specific branch. It uses an associative array to track branch colors, a count-sorted array (using bit manipulation to pack count and color into a single integer) to select the least-used color, and handles dynamic addition/removal of branches. This algorithm could be extracted into any Bash script that needs to assign colors to a dynamic set of items with constraints, requiring minimal modification.