Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Prune out some extra merge commits by comparing their parents correctly.
author
Avery Pennarun
<apenwarr@gmail.com>
Sat, 25 Apr 2009 01:49:19 +0000
(21:49 -0400)
committer
Avery Pennarun
<apenwarr@gmail.com>
Sat, 25 Apr 2009 01:49:19 +0000
(21:49 -0400)
git-subtree.sh
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
847e868
)
diff --git
a/git-subtree.sh
b/git-subtree.sh
index ffffb5ed881b8267c61fc0a4f92dc761b32f0e32..e6d8ce8817d39a813c44bf46d6810ff110690128 100755
(executable)
--- a/
git-subtree.sh
+++ b/
git-subtree.sh
@@
-168,9
+168,17
@@
merge_msg()
EOF
}
EOF
}
-tree_for_commit()
+t
opt
ree_for_commit()
{
{
- git ls-tree "$1" -- "$dir" |
+ commit="$1"
+ git log -1 --pretty=format:'%T' "$commit" -- || exit $?
+}
+
+subtree_for_commit()
+{
+ commit="$1"
+ dir="$2"
+ git ls-tree "$commit" -- "$dir" |
while read mode type tree name; do
assert [ "$name" = "$dir" ]
echo $tree
while read mode type tree name; do
assert [ "$name" = "$dir" ]
echo $tree
@@
-185,7
+193,7
@@
tree_changed()
if [ $# -ne 1 ]; then
return 0 # weird parents, consider it changed
else
if [ $# -ne 1 ]; then
return 0 # weird parents, consider it changed
else
- ptree=$(tree_for_commit $1)
+ ptree=$(t
opt
ree_for_commit $1)
if [ "$ptree" != "$tree" ]; then
return 0 # changed
else
if [ "$ptree" != "$tree" ]; then
return 0 # changed
else
@@
-226,7
+234,7
@@
cmd_split()
newparents=$(cache_get $parents)
debug " newparents: $newparents"
newparents=$(cache_get $parents)
debug " newparents: $newparents"
- tree=$(
tree_for_commit $rev
)
+ tree=$(
subtree_for_commit $rev "$dir"
)
debug " tree is: $tree"
[ -z $tree ] && continue
debug " tree is: $tree"
[ -z $tree ] && continue
@@
-235,7
+243,7
@@
cmd_split()
p="$p -p $parent"
done
p="$p -p $parent"
done
- if tree_changed $tree $parents; then
+ if tree_changed $tree $
new
parents; then
newrev=$(copy_commit $rev $tree "$p") || exit $?
else
newrev="$newparents"
newrev=$(copy_commit $rev $tree "$p") || exit $?
else
newrev="$newparents"