]> git.ipfire.org Git - thirdparty/git.git/blob - git-gui/CREDITS-GEN
Merge git://repo.or.cz/git-gui into maint
[thirdparty/git.git] / git-gui / CREDITS-GEN
1 #!/bin/sh
2
3 CF=CREDITS-FILE
4 tip=
5
6 tree_search ()
7 {
8 head=$1
9 tree=$2
10 for p in $(git rev-list --parents --max-count=1 $head 2>/dev/null)
11 do
12 test $tree = $(git rev-parse $p^{tree} 2>/dev/null) &&
13 vn=$(git describe --abbrev=4 $p 2>/dev/null) &&
14 case "$vn" in
15 gitgui-[0-9]*) echo $p; break;;
16 esac
17 done
18 }
19
20 generate_credits ()
21 {
22 tip=$1 &&
23 rm -f "$2" &&
24 git shortlog -n -s $tip | sed 's/: .*$//' >"$2" || exit
25 }
26
27 # Always use the tarball credits file if found, just
28 # in case we are somehow contained in a larger git
29 # repository that doesn't actually track our state.
30 # (At least one package manager is doing this.)
31 #
32 # We may be a subproject, so try looking for the merge
33 # commit that supplied this directory content if we are
34 # not at the toplevel. We probably will always be the
35 # second parent in the commit, but we shouldn't rely on
36 # that fact.
37 #
38
39 credits_tmp=/var/tmp/gitgui-credits-$$
40 trap 'rm -f "$credits_tmp"' 0
41
42 orig="$credits_tmp"
43
44 if test -f credits
45 then
46 orig=credits
47 elif prefix="$(git rev-parse --show-prefix 2>/dev/null)" &&
48 test -n "$prefix" &&
49 head=$(git rev-list --max-count=1 HEAD -- . 2>/dev/null) &&
50 tree=$(git rev-parse --verify "HEAD:$prefix" 2>/dev/null) &&
51 tip=$(tree_search $head $tree) &&
52 test -n "$tip"
53 then
54 generate_credits $tip "$orig" || exit
55 elif tip="$(git rev-parse --verify HEAD 2>/dev/null)" &&
56 test -n "$tip"
57 then
58 generate_credits $tip "$orig" || exit
59 else
60 echo "error: Cannot locate authorship information." >&2
61 exit 1
62 fi
63
64 if test -f "$orig" && cmp -s "$orig" "$CF"
65 then
66 : noop
67 else
68 rm -f "$CF" &&
69 cat "$orig" >"$CF"
70 fi
71