doc: git doesn't use git-foo invocations.
[guilt.git] / guilt-import
blob928e3257bf83c9a057c98b740f97a51ffc68387e
1 #!/bin/sh
3 # Copyright (c) Josef "Jeff" Sipek, 2007-2013
6 USAGE="[-P <patch> ] <patch_file>"
7 if [ -z "$GUILT_VERSION" ]; then
8 echo "Invoking `basename "$0"` directly is no longer supported." >&2
9 exit 1
12 _main() {
14 case "$1" in
15 -P)
16 newname="$2"
17 oldname="$3"
20 newname=`basename "$1"`
21 oldname="$1"
23 esac
25 if [ $# -lt 1 ] || [ $# -gt 3 ] || [ -z "$newname" ] || [ -z "$oldname" ]; then
26 usage
29 # make sure that there are no unapplied changes
30 if ! must_commit_first; then
31 die "Uncommited changes detected. Refresh first."
34 if [ ! -e "$oldname" ]; then
35 die "Specified file does not exist."
38 if [ -e "$GUILT_DIR/$branch/$newname" ]; then
39 die "Already tracking a patch under that name."
42 if ! valid_patchname "$newname"; then
43 die "The specified patch name is invalid according to git-check-ref-format(1)."
46 # create any directories as needed
47 mkdir_dir=`dirname "$GUILT_DIR/$branch/$newname"`
48 [ "$mkdir_dir" != "$GUILT_DIR/$branch" ] && mkdir -p "$mkdir_dir"
50 cp "$oldname" "$GUILT_DIR/$branch/$newname"
52 # insert the patch into the series file
53 series_insert_patch "$newname"