Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 964
Description
Description
Using:
- git version 2.4.6
- gitdb==0.6.4
- GitPython==1.0.1
The use case for git merge-base --is-ancestor from git manpage:
Check if the first is an ancestor of the second , and exit with status 0 if true, or with status 1 if not. Errors are signaled by a non-zero status that is not 1.
Related to #169 (comment)
The problem is that the output of git merge-base --is-ancestor comes from the return code and unlike without the --is-ancestor flag, this command doesn't return commit SHAs but is a simple yes-no check. The current implementation doesn't take into account the return code and the command cannot be usefully run.
Current Behaviour
revA is ancestor to revB
$ git merge-base --is-ancestor $revA$revB;echo$? 0>>>repo.merge_base(revA, revB, is_ancestor=True) [ ]revA is not ancestor to revB
$ git merge-base --is-ancestor $revA$revB;echo$? 1>>>repo.merge_base(revA, revB, is_ancestor=True) [ ]revA is not ancestor to revB and revB doesn't exist
$ git merge-base --is-ancestor $revA$revB;echo$? fatal: Not a valid commit name $revB 128>>>repo.merge_base(revA, revB, is_ancestor=True) GitCommandError: 'git merge-base --is-ancestor $revA $revB'returnedwithexitcode128stderr: 'fatal: Not a valid commit name $revB'Desired Behaviour
When the kwargis_ancestor is used, don't return a list, but return a bool that is true if the return code is 0. Return False if return code is 1. Raise Error as before for all other cases
$ git merge-base --is-ancestor $revA$revB;echo$? 0>>>repo.merge_base(revA, revB, is_ancestor=True) TruerevA is not ancestor to revB
$ git merge-base --is-ancestor $revA$revB;echo$? 1>>>repo.merge_base(revA, revB, is_ancestor=True) FalserevA is not ancestor to revB and revB doesn't exist
$ git merge-base --is-ancestor $revA$revB;echo$? fatal: Not a valid commit name $revB 128>>>repo.merge_base(revA, revB, is_ancestor=True) GitCommandError: 'git merge-base --is-ancestor $revA $revB'returnedwithexitcode128stderr: 'fatal: Not a valid commit name $revB'