Bug 36260 - git rev-list is bad at detecting ancestors
Summary: git rev-list is bad at detecting ancestors
Status: NEW
Alias: None
Product: Sisyphus
Classification: Development
Component: git-core (show other bugs)
Version: unstable
Hardware: all Linux
: P3 normal
Assignee: placeholder@altlinux.org
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-11 03:13 MSK by Ivan Zakharyaschev
Modified: 2019-03-11 03:26 MSK (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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
$