mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge bitcoin/bitcoin#27461: verify-commits: error and exit cleanly when git is too old.
1fefcf27ed
verify-commits: error and exit cleanly when git is too old. (Cory Fields) Pull request description: Requested by fanquake. Rather than failing with a cryptic error with older git, fail gracefully and mention why. The new option semantics [are explained here](1f0c3a29da
). Note: my local git versions are currently too old to test the new functionality, so I've only verified the failure case. ACKs for top commit: josibake: ACK1fefcf27ed
achow101: ACK1fefcf27ed
Tree-SHA512: f3dc583edf6ff6ff9bf06f33de967e10b8423ce62e7370912ffdca8a4ca4bfe4c2e783e9ad76281ce9e6748a4643d187aa5cb4a6b9ec4c1582910f02b94b6e3c
This commit is contained in:
commit
69460bd8bc
1 changed files with 14 additions and 1 deletions
|
@ -178,7 +178,20 @@ def main():
|
||||||
allow_unclean = current_commit in unclean_merge_allowed
|
allow_unclean = current_commit in unclean_merge_allowed
|
||||||
if len(parents) == 2 and check_merge and not allow_unclean:
|
if len(parents) == 2 and check_merge and not allow_unclean:
|
||||||
current_tree = subprocess.check_output([GIT, 'show', '--format=%T', current_commit]).decode('utf8').splitlines()[0]
|
current_tree = subprocess.check_output([GIT, 'show', '--format=%T', current_commit]).decode('utf8').splitlines()[0]
|
||||||
recreated_tree = subprocess.check_output([GIT, "merge-tree", parents[0], parents[1]]).decode('utf8').splitlines()[0]
|
|
||||||
|
# This merge-tree functionality requires git >= 2.38. The
|
||||||
|
# --write-tree option was added in order to opt-in to the new
|
||||||
|
# behavior. Older versions of git will not recognize the option and
|
||||||
|
# will instead exit with code 128.
|
||||||
|
try:
|
||||||
|
recreated_tree = subprocess.check_output([GIT, "merge-tree", "--write-tree", parents[0], parents[1]]).decode('utf8').splitlines()[0]
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
if e.returncode == 128:
|
||||||
|
print("git v2.38+ is required for this functionality.", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
|
||||||
if current_tree != recreated_tree:
|
if current_tree != recreated_tree:
|
||||||
print("Merge commit {} is not clean".format(current_commit), file=sys.stderr)
|
print("Merge commit {} is not clean".format(current_commit), file=sys.stderr)
|
||||||
subprocess.call([GIT, 'diff', recreated_tree, current_tree])
|
subprocess.call([GIT, 'diff', recreated_tree, current_tree])
|
||||||
|
|
Loading…
Add table
Reference in a new issue