blob: e2b4bdc6d86d32e395c3d8fe55b467cc23349097 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
#!/bin/bash
set -e
usage() {
printf "%s [--no-test]\n" "$CMD_NAME"
printf "\n"
printf " --no-test: by default, the script only prints what it\n"
printf " would do. You can also set NO_TEST=1 environment variable.\n"
printf "\n"
}
get_bool() {
local name="$1"
local val="${!name}"
case "$val" in
1|y|yes|Yes|YES|true|True|TRUE|on|On|ON)
echo -n 1
return 0
;;
0|n|no|No|NO|false|False|FALSE|off|Off|OFF)
echo -n 0
return 0
;;
*)
printf "%s" "$2"
;;
esac
}
die() {
echo "ERROR: $*"
exit 1
}
_pprint() {
local a
local sp=''
for a; do
printf "$sp%q" "$a"
sp=' '
done
}
call() {
local m=""
[ "$SKIP" = 1 ] && m="SKIP: "
if [ "$NO_TEST" != 1 ]; then
printf "WOULD: %s%s\n" "$m" "$(_pprint "$@")"
return 0
fi
printf "CALL: %s%s\n" "$m" "$(_pprint "$@")"
[ "$SKIP" = 1 ] || "$@"
}
git_config_reset() {
local key="$1"
local val="$2"
local c=(git config --replace-all "$key" "$val")
test "$#" -eq 2 || die "invalid arguments to git_config_add(): $@"
if [ "$(git config --get-all "$key")" = "$val" ]; then
SKIP=1 call "${c[@]}"
return 0
fi
call "${c[@]}"
}
git_config_add() {
local key="$1"
local val="$2"
local c=(git config --add "$key" "$val")
test "$#" -eq 2 || die "invalid arguments to git_config_add(): $@"
if git config --get-all "$key" | grep -qFx "$val"; then
SKIP=1 call "${c[@]}"
return 0
fi
call "${c[@]}"
}
CMD_NAME="$0"
NO_TEST="$(get_bool NO_TEST 0)"
for a; do
case "$a" in
--no-test)
NO_TEST=1
;;
-h|--help)
usage
exit 0
;;
*)
usage
die "Invalid argument \"$a\""
;;
esac
done
case "$(git config --get-all remote.origin.url)" in
"https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git"| \
"git@gitlab.freedesktop.org:NetworkManager/NetworkManager.git"| \
"ssh://git@gitlab.freedesktop.org/NetworkManager/NetworkManager")
;;
*)
die "unexpected git repository. Expected that remote.origin.url is set to \"https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git\""
;;
esac
git_config_add blame.ignoreRevsFile '.git-blame-ignore-revs'
git_config_reset blame.markIgnoredLines true
git_config_reset blame.markUnblamableLines true
git_config_add notes.displayref 'refs/notes/bugs'
git_config_add remote.origin.fetch 'refs/notes/bugs:refs/notes/bugs'
git_config_reset remote.origin.pushurl 'git@gitlab.freedesktop.org:NetworkManager/NetworkManager.git'
git_config_add 'alias.backport-merge' '! (git show main:contrib/scripts/git-backport-merge || git show origin/main:contrib/scripts/git-backport-merge) | bash -s -'
if [ "$NO_TEST" != 1 ]; then
printf "Run with \"--no-test\" or see \"-h\"\n" >&2
printf "\n" >&2
printf " \"%s\" --no-test\n" "$CMD_NAME" >&2
fi
|