-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-qimport
executable file
·52 lines (40 loc) · 1.11 KB
/
git-qimport
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
#!/bin/bash
#
# Copyright (C) 2013 MORITA Kazutaka <[email protected]>
#
# This code is based on guilt-import from Guilt (Git Quilt):
# Copyright (c) Josef "Jeff" Sipek, 2007-2011
#
. git-qsh-setup
USAGE="<file>..."
if [ $# -lt 1 ]; then
usage
fi
_import() {
newname="$1"
oldname="$2"
# 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 "$GITQ_DIR/$branch/$newname" ]; then
die "Already tracking a patch under that name."
fi
cp "$oldname" "$GITQ_DIR/$branch/$newname"
# insert the patch into the series file
cp "$series" "$series.tmp"
echo "$newname" >> "$series.tmp"
mv "$series.tmp" "$series"
echo "import $newname"
}
for f in $@; do
name=$(sed ':loop; N; $!b loop; ;s/\n\t/,/g' $f | \
grep ^Subject: | \
sed -e 's/Subject: \(\[[^]]*\] \)*\[PATCH[^/]*\( \([0-9]*\/\)[0-9]*\)*\] /\3/' | \
sed 's/Subject: //' | \
tr ' /' '_' | sed 's/[^a-zA-Z0-9_]//g')
_import $name $f
done