1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-08 10:13:18 +01:00
git/t/t6000-rev-list-misc.sh

77 lines
1.7 KiB
Bash
Raw Normal View History

#!/bin/sh
test_description='miscellaneous rev-list tests'
. ./test-lib.sh
test_expect_success setup '
echo content1 >wanted_file &&
echo content2 >unwanted_file &&
git add wanted_file unwanted_file &&
git commit -m one
'
test_expect_success 'rev-list --objects heeds pathspecs' '
git rev-list --objects HEAD -- wanted_file >output &&
grep wanted_file output &&
! grep unwanted_file output
'
test_expect_success 'rev-list --objects with pathspecs and deeper paths' '
mkdir foo &&
>foo/file &&
git add foo/file &&
git commit -m two &&
git rev-list --objects HEAD -- foo >output &&
grep foo/file output &&
git rev-list --objects HEAD -- foo/file >output &&
grep foo/file output &&
! grep unwanted_file output
'
test_expect_success 'rev-list --objects with pathspecs and copied files' '
git checkout --orphan junio-testcase &&
git rm -rf . &&
mkdir two &&
echo frotz >one &&
cp one two/three &&
git add one two/three &&
test_tick &&
git commit -m that &&
ONE=$(git rev-parse HEAD:one)
git rev-list --objects HEAD two >output &&
grep "$ONE two/three" output &&
! grep one output
'
test_expect_success 'rev-list A..B and rev-list ^A B are the same' '
git commit --allow-empty -m another &&
git tag -a -m "annotated" v1.0 &&
git rev-list --objects ^v1.0^ v1.0 >expect &&
git rev-list --objects v1.0^..v1.0 >actual &&
test_cmp expect actual
'
revision: mark contents of an uninteresting tree uninteresting "git rev-list --objects ^A^{tree} B^{tree}" ought to mean "I want a list of objects inside B's tree, but please exclude the objects that appear inside A's tree". we see the top-level tree marked as uninteresting (i.e. ^A^{tree} in the above example) and call mark_tree_uninteresting() on it; this unfortunately prevents us from recursing into the tree and marking the objects in the tree as uninteresting. The reason why "git log ^A A" yields an empty set of commits, i.e. we do not have a similar issue for commits, is because we call mark_parents_uninteresting() after seeing an uninteresting commit. The uninteresting-ness of the commit itself does not prevent its parents from being marked as uninteresting. Introduce mark_tree_contents_uninteresting() and structure the code in handle_commit() in such a way that it makes it the responsibility of the callchain leading to this function to mark commits, trees and blobs as uninteresting, and also make it the responsibility of the helpers called from this function to mark objects that are reachable from them. Note that this is a very old bug that probably dates back to the day when "rev-list --objects" was introduced. The line to clear tree->object.parsed at the end of mark_tree_contents_uninteresting() can be removed when this fix is merged to the codebase after 6e454b9a (clear parsed flag when we free tree buffers, 2013-06-05). Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-16 00:38:01 +01:00
test_expect_success 'propagate uninteresting flag down correctly' '
git rev-list --objects ^HEAD^{tree} HEAD^{tree} >actual &&
>expect &&
test_cmp expect actual
'
test_expect_success 'symleft flag bit is propagated down from tag' '
git log --format="%m %s" --left-right v1.0...master >actual &&
cat >expect <<-\EOF &&
> two
> one
< another
< that
EOF
test_cmp expect actual
'
test_done