h,help show the help
q quiet
d show debug messages
-p,prefix= the name of the subdir to split out
+P,prefix= the name of the subdir to split out
m,message= use the given message as the commit message for the merge commit
options for 'split'
annotate= add a prefix to commit message of new commits
--annotate) annotate="$1"; shift ;;
--no-annotate) annotate= ;;
-b) branch="$1"; shift ;;
- -p) prefix="$1"; shift ;;
+ -P) prefix="$1"; shift ;;
-m) message="$1"; shift ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
if [ -z "$prefix" ]; then
die "You must provide the --prefix option."
fi
+
+case "$command" in
+ add) [ -e "$prefix" ] &&
+ die "prefix '$prefix' already exists." ;;
+ *) [ -e "$prefix" ] ||
+ die "'$prefix' does not exist; use 'git subtree add'" ;;
+esac
+
dir="$(dirname "$prefix/.")"
if [ "$command" != "pull" ]; then
newrev="$1"
branch="$2"
branch_hash=$(git rev-parse $branch)
- match=$(git rev-list $newrev | grep $branch_hash)
+ match=$(git rev-list -1 $branch_hash ^$newrev)
- if [ -n "$match" ]; then
+ if [ -z "$match" ]; then
return 0
else
return 1
commit_message="Split '$dir/' into commit '$latest_new'"
fi
cat <<-EOF
- $message
+ $commit_message
git-subtree-dir: $dir
git-subtree-mainline: $latest_old
eval "$grl" |
while read rev parents; do
revcount=$(($revcount + 1))
- say -n "$revcount/$revmax ($createcount)
-"
+ say -n "$revcount/$revmax ($createcount)\r"
debug "Processing commit: $rev"
exists=$(cache_get $rev)
if [ -n "$exists" ]; then
rev="$new"
fi
- git merge -s subtree --message="$message" $rev
+ if [ -n "$message" ]; then
+ git merge -s subtree --message="$message" $rev
+ else
+ git merge -s subtree $rev
+ fi
}
cmd_pull()