summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 210d083)
raw | patch | inline | side by side (parent: 210d083)
author | Avery Pennarun <apenwarr@gmail.com> | |
Sat, 25 Apr 2009 02:05:30 +0000 (22:05 -0400) | ||
committer | Avery Pennarun <apenwarr@gmail.com> | |
Sat, 25 Apr 2009 02:05:30 +0000 (22:05 -0400) |
Now we cut out a commit if any of its parents had the same tree; just use
that parent in its place. This makes the history look nice, but I don't
think it's quite right...
that parent in its place. This makes the history look nice, but I don't
think it's quite right...
git-subtree.sh | patch | blob | history | |
test.sh | patch | blob | history |
diff --git a/git-subtree.sh b/git-subtree.sh
index e6d8ce8817d39a813c44bf46d6810ff110690128..03107e2251c35e0f31e4e29ab9f0fb5515079ced 100755 (executable)
--- a/git-subtree.sh
+++ b/git-subtree.sh
fi
}
+copy_or_skip()
+{
+ rev="$1"
+ tree="$2"
+ newparents="$3"
+ assert [ -n "$tree" ]
+
+ p=""
+ for parent in $newparents; do
+ ptree=$(toptree_for_commit $parent) || exit $?
+ if [ "$ptree" = "$tree" ]; then
+ # any identical parent means this commit is unnecessary
+ echo $parent
+ return 0
+ elif [ -n "$ptree" ]; then
+ # an existing, non-identical parent is important
+ p="$p -p $parent"
+ fi
+ done
+
+ copy_commit $rev $tree "$p" || exit $?
+}
+
cmd_split()
{
debug "Splitting $dir..."
debug " tree is: $tree"
[ -z $tree ] && continue
- p=""
- for parent in $newparents; do
- p="$p -p $parent"
- done
-
- if tree_changed $tree $newparents; then
- newrev=$(copy_commit $rev $tree "$p") || exit $?
- else
- newrev="$newparents"
- fi
+ newrev=$(copy_or_skip "$rev" "$tree" "$newparents") || exit $?
debug " newrev is: $newrev"
cache_set $rev $newrev
cache_set latest_new $newrev
index 8a9d92f7038c9bda4d1456b75397ebbfd766253e..a8ed0dbc7d9b927ddb12d7e42c925ce12867a68d 100755 (executable)
--- a/test.sh
+++ b/test.sh
cd ../mainline
git fetch ../subproj subproj-merge-split3
git branch subproj-merge-split3 FETCH_HEAD
-git merge subproj-merge-split3
+git merge -s subtree subproj-merge-split3