[go: nahoru, domu]

Skip to content

Commit

Permalink
Updated the graph-dag script to differentiate unreachable commits
Browse files Browse the repository at this point in the history
  • Loading branch information
whiteinge committed Jul 31, 2012
1 parent a272415 commit 627118c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 24 deletions.
55 changes: 55 additions & 0 deletions cars_2012-04-27_git/git-graph-dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Draw a graphviz diagram of the Git DAG
#
# Labels consist of the short SHA1 and any refs.
# Unreachable commits (ignoring the reflog) will be marked with an asterisk and
# drawn with dashed lines.
#
# Largely stolen from https://git.wiki.kernel.org/index.php/ExampleScripts
#
# Usage:
# git graph-dag HEAD~10.. | dot -Tpng | display -antialias
#
# Accepts any range or arguments that git rev-list accepts.

set -e

if [[ -z $@ ]] ; then
echo -e "Usage: git graph-dag HEAD~10.. | dot -Tpng | display -antialias"
exit 1
fi

echo "digraph lattice {"

# Draw the DAG and connect parents
git rev-list --parents "$@" |
while read commit parents
do
for p in $parents
do
echo "n$commit -> n$p"
done
done

# Make pretty labels with the short sha1 and any refs
git rev-list --pretty=format:"%H %h %d" "$@" | awk '
BEGIN {
command = "git fsck --unreachable --no-reflogs | cut -d\" \" -f3"
while (command | getline unr) unreachable[unr] = 1
close(command)
}
!/^commit/ {
refs = ""
for (i=3; i<=NF; i++) refs = refs " " $i
unreachable[$1] == 1 ? isunr = 1 : isunr = 0
printf "n%s [shape=Mrecord, style=%s, label=\"{%s%s}\"]\n", \
$1, \
isunr == 1 ? "dashed" : "filled", \
isunr == 1 ? "*" $2 : $2, \
refs == "" ? "" : refs
}'

echo "}"
24 changes: 0 additions & 24 deletions cars_2012-04-27_git/graph-dag.sh

This file was deleted.

0 comments on commit 627118c

Please sign in to comment.