forked from jeffpc/guilt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguilt-rename
executable file
·45 lines (35 loc) · 915 Bytes
/
guilt-rename
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
#!/bin/sh
#
# Copyright (C) Viacheslav Galaktionov, 2023
#
USAGE="[<old_name>] <new_name>"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename "$0"` directly is no longer supported." >&2
exit 1
fi
_main() {
if [ $# -eq 1 ]; then
old_name=$(get_top)
new_name=$1
shift
elif [ $# -eq 2 ]; then
old_name=$1
new_name=$2
else
usage
fi
(
cd_to_toplevel
[ -f "$GUILT_DIR/$branch/$old_name" ] ||
die "Patch \"$old_name\" does not exist"
[ -f "$GUILT_DIR/$branch/$new_name" ] &&
die "Patch \"$new_name\" already exists"
if ! valid_patchname "$new_name"; then
die "The specified patch name is invalid according to git-check-ref-format(1)."
fi
mv "$GUILT_DIR/$branch/$old_name" "$GUILT_DIR/$branch/$new_name"
series_rename_patch "$old_name" "$new_name"
applied_rename_patch "$old_name" "$new_name"
ref_rename_patch "$old_name" "$new_name"
)
}