forked from jeffpc/guilt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguilt-import
executable file
·55 lines (43 loc) · 1.09 KB
/
guilt-import
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="[-P <patch> ] <patch_file>"
if [ -z "$GUILT_VERSION" ]; then
echo "Invoking `basename "$0"` directly is no longer supported." >&2
exit 1
fi
_main() {
case "$1" in
-P)
newname="$2"
oldname="$3"
;;
*)
newname=`basename "$1"`
oldname="$1"
;;
esac
if [ $# -lt 1 ] || [ $# -gt 3 ] || [ -z "$newname" ] || [ -z "$oldname" ]; then
usage
fi
# make sure that there are no unapplied changes
if ! must_commit_first; then
die "Uncommited changes detected. Refresh first."
fi
if [ ! -e "$oldname" ]; then
die "Specified file does not exist."
fi
if [ -e "$GUILT_DIR/$branch/$newname" ]; then
die "Already tracking a patch under that name."
fi
if ! valid_patchname "$newname"; then
die "The specified patch name is invalid according to git-check-ref-format(1)."
fi
# create any directories as needed
mkdir_dir=`dirname "$GUILT_DIR/$branch/$newname"`
[ "$mkdir_dir" != "$GUILT_DIR/$branch" ] && mkdir -p "$mkdir_dir"
cp "$oldname" "$GUILT_DIR/$branch/$newname"
# insert the patch into the series file
series_insert_patch "$newname"
}