Bug 36260

Summary: git rev-list is bad at detecting ancestors
Product: Sisyphus Reporter: Ivan Zakharyaschev <imz>
Component: git-coreAssignee: placeholder <placeholder>
Status: NEW --- QA Contact: qa-sisyphus
Severity: normal    
Priority: P3 CC: glebfm, ldv, placeholder
Version: unstable   
Hardware: all   
OS: Linux   

Description Ivan Zakharyaschev 2019-03-11 03:13:20 MSK
$ cd /gears/r/rpm-build.git/
$ git merge-base --is-ancestor 4.0.4-alt114 4.0.4-alt128 && echo yes
yes
$ git rev-list 4.0.4-alt114 ^4.0.4-alt128 | wc -l
163
$ rpm -q git-core
git-core-2.19.2-alt1.x86_64

And this is also the method used in girar to detect an ancestor, which is broken (as we see) -- gb/gb-task-check-girar:76:

	if [ -z "$(GIT_ALTERNATE_OBJECT_DIRECTORIES="${1-}" git log -n1 --pretty=format:1 ^"$new_id" "$old_id")" ]; then

"git log" works the same as "git rev-list":

$ git --no-pager log -n1 --pretty=format:1 ^4.0.4-alt128 4.0.4-alt114        
1

The expected correct result is an empty string.
Comment 1 Ivan Zakharyaschev 2019-03-11 03:19:10 MSK
(In reply to comment #0)
> $ cd /gears/r/rpm-build.git/
> $ git merge-base --is-ancestor 4.0.4-alt114 4.0.4-alt128 && echo yes
> yes
> $ git rev-list 4.0.4-alt114 ^4.0.4-alt128 | wc -l
> 163

Here is the minimal example (using tags) in this repo:

$ git rev-list 4.0.4-alt124 ^4.0.4-alt128 | wc -l
196
$ git rev-list 4.0.4-alt125 ^4.0.4-alt128 | wc -l
0
$ git rev-list 4.0.4-alt124 ^4.0.4-alt127 | wc -l
0
Comment 2 Ivan Zakharyaschev 2019-03-11 03:26:17 MSK
(In reply to comment #1)
> (In reply to comment #0)
> > $ cd /gears/r/rpm-build.git/
> > $ git merge-base --is-ancestor 4.0.4-alt114 4.0.4-alt128 && echo yes
> > yes
> > $ git rev-list 4.0.4-alt114 ^4.0.4-alt128 | wc -l
> > 163
> 
> Here is the minimal example (using tags) in this repo:
> 
> $ git rev-list 4.0.4-alt124 ^4.0.4-alt128 | wc -l
> 196
> $ git rev-list 4.0.4-alt125 ^4.0.4-alt128 | wc -l
> 0
> $ git rev-list 4.0.4-alt124 ^4.0.4-alt127 | wc -l
> 0

The commit where this happens:

$ git rev-list 6d9d4fed64ef4d6763fffe5d72515fdb2427b417 ^4.0.4-alt128 | wc -l
0
$ git rev-list 6d9d4fed64ef4d6763fffe5d72515fdb2427b417^ ^4.0.4-alt128 | wc -l
196
$