File: guilt-header

package info (click to toggle)
guilt 0.30-1.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 668 kB
  • ctags: 71
  • sloc: sh: 1,941; makefile: 119; perl: 42
file content (58 lines) | stat: -rwxr-xr-x 1,023 bytes parent folder | download
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
#!/bin/sh
#
# Copyright (c) Josef "Jeff" Sipek, 2006, 2007
#

USAGE="[-e] [<patchname>]"
. `dirname $0`/guilt

case $# in
	0)
		patch=`get_top`
		;;
	1)
		if [ "$1" = "-e" ]; then
			edit=t
			patch=`get_top`
		else
			patch="$1"
		fi
		;;
	2)
		[ "$1" != "-e" ] && usage

		edit=t
		patch="$2"

		;;
esac

# are there any patches applied?
[ -z "$patch" ] && die "No patches applied."

# check that patch exists in the series
ret=`get_series | grep -e "^$patch\$" | wc -l`
if [ $ret -eq 0 ]; then
	die "Patch $patch is not in the series"
fi

# FIXME: warn if we're editing an applied patch

TMP_MSG=`get_tmp_file msg`
TMP_DIFF=`get_tmp_file diff`

if [ -z "$edit" ]; then
	do_get_header "$GUILT_DIR/$branch/$patch"
else
	do_get_full_header "$GUILT_DIR/$branch/$patch" > "$TMP_MSG"
	do_get_patch "$GUILT_DIR/$branch/$patch" > "$TMP_DIFF"
	$editor "$TMP_MSG"
	mv "$GUILT_DIR/$branch/$patch" "$GUILT_DIR/$branch/$patch~"

	(
		cat "$TMP_MSG"
		cat "$TMP_DIFF"
	) > "$GUILT_DIR/$branch/$patch"
fi

rm -f "$TMP_MSG" "$TMP_DIFF"