Fixed regression with splitting out new subtree
A folder in a repository that wasn't initially imported as a subtree could no longer be splitted into an entirely new subtree with no parent. A fix and a new test to fix that regression is added here.
Pelle Wessman committed
May 20, 2010 at 22:40 UTC
39f5fff0d53bcc68f5c698150d2d3b35eececc27
2 files changed
+13
-1
git-subtree.sh
+4
-1
@@ -253,6 +253,7 @@ find_existing_splits()
253
if [ -n "$main" -a -n "$sub" ]; then
254
debug " Prior: $main -> $sub"
255
cache_set $main $sub
256
+ cache_set $sub $sub
257
try_remove_previous "$main"
258
try_remove_previous "$sub"
259
fi
@@ -569,7 +570,9 @@ cmd_split()
570
# ugly. is there no better way to tell if this is a subtree
571
# vs. a mainline commit? Does it matter?
572
if [ -z $tree ]; then
572
- cache_set $rev $rev
573
+ if [ -n "$newparents" ]; then
574
+ cache_set $rev $rev
575
+ fi
576
continue
577
fi
578
test.sh
+9
@@ -294,6 +294,15 @@ git subtree split --prefix subdir --branch mainsub4
294
# but it wasn't, because it's cache was not set to itself)
295
check_equal "$(git log --pretty=format:%P -1 mainsub4)" "$(git rev-parse sub3)"
296
297
+mkdir subdir2
298
+create subdir2/main-sub5
299
+git commit -m "main-sub5"
300
+git subtree split --prefix subdir2 --branch mainsub5
301
+
302
+# also test that we still can split out an entirely new subtree
303
+# if the parent of the first commit in the tree isn't empty,
304
+# then the new subtree has accidently been attached to something
305
+check_equal "$(git log --pretty=format:%P -1 mainsub5)" ""
306
307
308
# make sure no patch changes more than one file. The original set of commits