summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2010-06-24 02:11:04 -0400
committerAvery Pennarun <apenwarr@gmail.com>2010-06-24 02:11:04 -0400
commit8e770bd389f1810a4b1a53da51e0761ca1435f3a (patch)
tree94ab1c47218efd452a4736341cde635ad2f96597
parent9c632ea29ccd58a9967690c2670edec31dc468cd (diff)
parent39f5fff0d53bcc68f5c698150d2d3b35eececc27 (diff)
downloadgit-8e770bd389f1810a4b1a53da51e0761ca1435f3a.tar.gz
Merge remote branch 'origin/master'
* origin/master: Fixed regression with splitting out new subtree Use 'git merge -Xsubtree' when git version >= 1.7.0.
-rwxr-xr-xgit-subtree.sh22
-rwxr-xr-xtest.sh9
2 files changed, 26 insertions, 5 deletions
diff --git a/git-subtree.sh b/git-subtree.sh
index 935dfca7f3..a15d91ffb1 100755
--- a/git-subtree.sh
+++ b/git-subtree.sh
@@ -257,6 +257,7 @@ find_existing_splits()
if [ -n "$main" -a -n "$sub" ]; then
debug " Prior: $main -> $sub"
cache_set $main $sub
+ cache_set $sub $sub
try_remove_previous "$main"
try_remove_previous "$sub"
fi
@@ -573,7 +574,9 @@ cmd_split()
# ugly. is there no better way to tell if this is a subtree
# vs. a mainline commit? Does it matter?
if [ -z $tree ]; then
- cache_set $rev $rev
+ if [ -n "$newparents" ]; then
+ cache_set $rev $rev
+ fi
continue
fi
@@ -638,11 +641,20 @@ cmd_merge()
debug "New squash commit: $new"
rev="$new"
fi
-
- if [ -n "$message" ]; then
- git merge -s subtree --message="$message" $rev
+
+ version=$(git version)
+ if [ "$version" \< "git version 1.7" ]; then
+ if [ -n "$message" ]; then
+ git merge -s subtree --message="$message" $rev
+ else
+ git merge -s subtree $rev
+ fi
else
- git merge -s subtree $rev
+ if [ -n "$message" ]; then
+ git merge -Xsubtree="$prefix" --message="$message" $rev
+ else
+ git merge -Xsubtree="$prefix" $rev
+ fi
fi
}
diff --git a/test.sh b/test.sh
index 8c1f1ea6bd..45237c3374 100755
--- a/test.sh
+++ b/test.sh
@@ -294,6 +294,15 @@ git subtree split --prefix subdir --branch mainsub4
# but it wasn't, because it's cache was not set to itself)
check_equal "$(git log --pretty=format:%P -1 mainsub4)" "$(git rev-parse sub3)"
+mkdir subdir2
+create subdir2/main-sub5
+git commit -m "main-sub5"
+git subtree split --prefix subdir2 --branch mainsub5
+
+# also test that we still can split out an entirely new subtree
+# if the parent of the first commit in the tree isn't empty,
+# then the new subtree has accidently been attached to something
+check_equal "$(git log --pretty=format:%P -1 mainsub5)" ""
# make sure no patch changes more than one file. The original set of commits