blob: 9b22c34c2d08a7aef78f46a17f16ba586ea2beb1 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/bin/sh
# Copyright (c) 2023 Daiki Ueno
# License: GPLv3+ <http://gnu.org/licenses/gpl.html>
progname=$0
mode=save
verbose=false
while test $# -gt 0; do
case "$1" in
--save )
mode=save
shift ;;
--restore )
mode=restore
shift ;;
--help )
echo "Usage: preserve-timestamp [--verbose] [--save|--restore] FILE"
exit ;;
--verbose )
verbose=true
shift ;;
-* )
echo "preserve-timestamp: unknown option $1" 1>&2
echo "Try 'preserve-timestamp --help' for more information." 1>&2
exit 1 ;;
* )
break ;;
esac
done
if test $# = 0; then
echo "$progname: *** missing FILE argument" 1>&2
echo "$progname: *** Stop." 1>&2
exit 1
fi
file=$1
case $mode in
save )
: > "$file"
git ls-files --recurse-submodules | \
while read f; do
if $verbose; then
echo "$f"
fi
{ stat --printf="@%.Y " "$f"; echo "$f"; } >> "$file"
done
;;
restore )
while read t f; do
if $verbose; then
echo "$f"
fi
touch -d "$t" "$f"
done < "$file"
;;
esac
|