Handle it successfully if a given parent commit has no parents.
Avery Pennarun committed
Apr 25, 2009 at 00:06 UTC
b9de53532c3e7aa6b01aa188e0f0f17a266c099d
1 file changed
+12
-1
git-subtree.sh
+12
-1
@@ -125,6 +125,16 @@ cache_set()
125
echo "$newrev" >"$cachedir/$oldrev"
126
}
127
128
+# if a commit doesn't have a parent, this might not work. But we only want
129
+# to remove the parent from the rev-list, and since it doesn't exist, it won't
130
+# be there anyway, so do nothing in that case.
131
+try_remove_previous()
132
+{
133
+ if git rev-parse "$1^" >/dev/null 2>&1; then
134
+ echo "^$1^"
135
+ fi
136
+}
137
+
138
find_existing_splits()
139
{
140
debug "Looking for prior splits..."
@@ -140,7 +150,8 @@ find_existing_splits()
150
if [ -n "$main" -a -n "$sub" ]; then
151
debug " Prior: $main -> $sub"
152
cache_set $main $sub
143
- echo "^$main^ ^$sub^"
153
+ try_remove_previous "$main"
154
+ try_remove_previous "$sub"
155
main=
156
sub=
157
fi