]>
Commit | Line | Data |
---|---|---|
985db879 AW |
1 | #!/bin/bash |
2 | ||
79208cb7 AW |
3 | if [ "$#" -ne 3 ]; then |
4 | echo "Usage: $0 <orig tag>|<base release> <reconstruct> <options>" 1>&2 | |
985db879 AW |
5 | exit 1 |
6 | fi | |
7 | tag="$1" | |
79208cb7 AW |
8 | reconstruct="$2" |
9 | options="$3" | |
985db879 AW |
10 | |
11 | case "$tag" in | |
12 | v*) ;; | |
13 | *) tag="v${tag%.*}" ;; | |
14 | esac | |
15 | ||
16 | # Validate the tag. | |
17 | count=$( git tag -l "$tag" | wc -l ) | |
18 | if [ "$count" != 1 ]; then | |
19 | echo "$0: $tag: tag invalid" 1>&2 | |
20 | exit 1 | |
21 | fi | |
22 | ||
23 | #git ls-tree -r --full-tree HEAD | grep ^120 | \ | |
24 | #while read mode type blobid name | |
25 | ||
79208cb7 AW |
26 | ( |
27 | # Identify all new symlinks since the proffered tag. | |
28 | echo "# Recreate any symlinks created since the orig." | |
29 | git diff "$tag.." --raw | awk '(/^:000000 120000/ && $5 == "A") { print $NF }' | \ | |
30 | while read name | |
31 | do | |
32 | link=$( readlink "$name" ) | |
33 | ||
34 | echo "[ ! -L '$name' ] && ln -sf '$link' '$name'" | |
35 | done | |
36 | ||
37 | # Identify all removed files since the proffered tag. | |
38 | echo "# Remove any files deleted from the orig." | |
39 | git diff "$tag.." --raw | awk '(/^:/ && $5 == "D") { print $NF }' | \ | |
40 | while read name | |
41 | do | |
42 | echo "rm -f '$name'" | |
43 | done | |
44 | ||
45 | # All done, make sure this does not complete in error. | |
46 | echo "exit 0" | |
47 | ) >"$reconstruct" | |
48 | ||
49 | ( | |
50 | # Identify all new symlinks since the proffered tag. | |
51 | echo "# Ignore any symlinks created since the orig which are rebuilt by reconstruct." | |
52 | git diff "$tag.." --raw | awk '(/^:000000 120000/ && $5 == "A") { print $NF }' | \ | |
53 | while read name | |
54 | do | |
55 | echo "extend-diff-ignore=$name" | |
56 | done | |
57 | ) >"$options.update" | |
58 | ||
59 | ||
60 | head='^## autoreconstruct -- begin$' | |
61 | foot='^## autoreconstruct -- end$' | |
62 | sed -i -e " | |
63 | /$head/,/$foot/{ | |
64 | /$head/{ | |
65 | p; | |
66 | r $options.update | |
67 | }; | |
68 | /$foot/p; | |
69 | d | |
70 | } | |
71 | " "$options" | |
72 | rm -f "$options.update" |