From: Junio C Hamano Date: Mon, 4 Aug 2008 00:47:16 +0000 (-0700) Subject: Topo-sort before --simplify-merges X-Git-Tag: v1.6.1-rc1~232^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=65347030590bcc251a9ff2ed96487a0f1b9e9fa8;p=git.git Topo-sort before --simplify-merges This makes the algorithm more honest about what it is doing. We start from an already limited, topo-sorted list, and postprocess it by simplifying the irrelevant merges away. Signed-off-by: Junio C Hamano --- diff --git a/revision.c b/revision.c index 662d66be7..0aaa4c10b 100644 --- a/revision.c +++ b/revision.c @@ -1493,6 +1493,8 @@ static void simplify_merges(struct rev_info *revs) struct commit_list *list; struct commit_list *yet_to_do, **tail; + sort_in_topological_order(&revs->commits, revs->lifo); + /* feed the list reversed */ yet_to_do = NULL; for (list = revs->commits; list; list = list->next) @@ -1522,9 +1524,6 @@ static void simplify_merges(struct rev_info *revs) if (commit->util == commit) tail = &commit_list_insert(commit, tail)->next; } - - /* sort topologically at the end */ - sort_in_topological_order(&revs->commits, revs->lifo); } static void set_children(struct rev_info *revs) diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh new file mode 100755 index 000000000..510bb9679 --- /dev/null +++ b/t/t6012-rev-list-simplify.sh @@ -0,0 +1,93 @@ +#!/bin/sh + +test_description='merge simplification' + +. ./test-lib.sh + +note () { + git tag "$1" +} + +_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' +_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" + +unnote () { + git name-rev --tags --stdin | sed -e "s|$_x40 (tags/\([^)]*\)) |\1 |g" +} + +test_expect_success setup ' + echo "Hi there" >file && + git add file && + test_tick && git commit -m "Initial file" && + note A && + + git branch other-branch && + + echo "Hello" >file && + git add file && + test_tick && git commit -m "Modified file" && + note B && + + git checkout other-branch && + + echo "Hello" >file && + git add file && + test_tick && git commit -m "Modified the file identically" && + note C && + + echo "This is a stupid example" >another-file && + git add another-file && + test_tick && git commit -m "Add another file" && + note D && + + test_tick && git merge -m "merge" master && + note E && + + echo "Yet another" >elif && + git add elif && + test_tick && git commit -m "Irrelevant change" && + note F && + + git checkout master && + echo "Yet another" >elif && + git add elif && + test_tick && git commit -m "Another irrelevant change" && + note G && + + test_tick && git merge -m "merge" other-branch && + note H && + + echo "Final change" >file && + test_tick && git commit -a -m "Final change" && + note I +' + +FMT='tformat:%P %H | %s' + +check_result () { + for c in $1 + do + echo "$c" + done >expect && + shift && + param="$*" && + test_expect_success "log $param" ' + git log --pretty="$FMT" --parents $param | + unnote >actual && + sed -e "s/^.* \([^ ]*\) .*/\1/" >check