File: guilt-fork

package info (click to toggle)
guilt 0.36-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,312 kB
  • sloc: sh: 3,063; makefile: 95; perl: 42
file content (55 lines) | stat: -rwxr-xr-x 1,204 bytes parent folder | download | duplicates (3)
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
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2007-2013
#

USAGE="[<new_name>]"
if [ -z "$GUILT_VERSION" ]; then
	echo "Invoking `basename "$0"` directly is no longer supported." >&2
	exit 1
fi

_main() {

if [ $# -gt 1 ]; then
	usage
fi

patch=`get_top`
if [ -z "$patch" ]; then
	die "No patches are applied."
fi

# make sure that there are no unapplied changes
if ! must_commit_first; then
	die "Uncommited changes detected. Refresh first."
fi

# Rename patches smartly
if [ $# -eq 1 ]; then
	newpatch="$1"
else
	base=$(echo "$patch" \
		| sed -r -e 's:(\.diff?|\.patch)$::')
	num=$(echo "$base" | sed -nre 's:.*-([0-9]+)$:\1:'p)
	[ -n "$num" ] || num=1
	newpatch="${base%-$num}-$(($num+1))${patch#$base}"
fi

if ! valid_patchname "$newpatch"; then
	die "The specified patch name is invalid according to git-check-ref-format(1)."
fi

if [ -e "$GUILT_DIR/$branch/$newpatch" ]; then
	die "Patch \"$newpatch\" already exists. Choose another name."
fi

# copy the patch
cp "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$newpatch"

# replace the series & applied file references
series_rename_patch "$patch" "$newpatch"
applied_rename_patch "$patch" "$newpatch"
ref_rename_patch "$patch" "$newpatch"

}