squash merge subtree changes as a single commit
"
eval $(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
-. $(git --exec-path)/git-sh-setup
+PATH=$(git --exec-path):$PATH
+. git-sh-setup
require_work_tree
quiet=
if [ -z "$prefix" ]; then
die "You must provide the --prefix option."
fi
-dir="$prefix"
+dir="$(dirname "$prefix/.")"
if [ "$command" != "pull" ]; then
revs=$(git rev-parse $default --revs-only "$@") || exit $?
sq=
main=
sub=
- git log --grep="^git-subtree-dir: $dir\$" \
+ git log --grep="^git-subtree-dir: $dir/*\$" \
--pretty=format:'START %H%n%s%n%n%b%nEND%n' HEAD |
while read a b junk; do
debug "$a $b $junk"
revs="$2"
main=
sub=
- git log --grep="^git-subtree-dir: $dir\$" \
+ git log --grep="^git-subtree-dir: $dir/*\$" \
--pretty=format:'START %H%n%s%n%n%b%nEND%n' $revs |
while read a b junk; do
case "$a" in
- START) main="$b"; sq="$b" ;;
+ START) sq="$b" ;;
git-subtree-mainline:) main="$b" ;;
git-subtree-split:) sub="$b" ;;
END)
+ debug " Main is: '$main'"
if [ -z "$main" -a -n "$sub" ]; then
# squash commits refer to a subtree
+ debug " Squash: $sq from $sub"
cache_set "$sq" "$sub"
fi
if [ -n "$main" -a -n "$sub" ]; then
git ls-tree "$commit" -- "$dir" |
while read mode type tree name; do
assert [ "$name" = "$dir" ]
+ assert [ "$type" = "tree" ]
echo $tree
break
done
debug "Adding $dir as '$rev'..."
git read-tree --prefix="$dir" $rev || exit $?
- git checkout "$dir" || exit $?
+ git checkout -- "$dir" || exit $?
tree=$(git write-tree) || exit $?
headrev=$(git rev-parse HEAD) || exit $?