Skip to content

Commit 5497c14

Browse files
committed
verify-commits: Use merge-tree in clean merge check
1 parent 76923bf commit 5497c14

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

contrib/verify-commits/verify-commits.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def main():
9595
with open(dirname + "/trusted-keys", "r", encoding="utf8") as f:
9696
trusted_keys = f.read().splitlines()
9797

98-
# Set commit and branch and set variables
98+
# Set commit and variables
9999
current_commit = args.commit
100100
if ' ' in current_commit:
101101
print("Commit must not contain spaces", file=sys.stderr)
@@ -104,7 +104,6 @@ def main():
104104
no_sha1 = True
105105
prev_commit = ""
106106
initial_commit = current_commit
107-
branch = subprocess.check_output([GIT, 'show', '-s', '--format=%H', initial_commit]).decode('utf8').splitlines()[0]
108107

109108
# Iterate through commits
110109
while True:
@@ -164,15 +163,11 @@ def main():
164163
allow_unclean = current_commit in unclean_merge_allowed
165164
if len(parents) == 2 and check_merge and not allow_unclean:
166165
current_tree = subprocess.check_output([GIT, 'show', '--format=%T', current_commit]).decode('utf8').splitlines()[0]
167-
subprocess.call([GIT, 'checkout', '--force', '--quiet', parents[0]])
168-
subprocess.call([GIT, 'merge', '--no-ff', '--quiet', '--no-gpg-sign', parents[1]], stdout=subprocess.DEVNULL)
169-
recreated_tree = subprocess.check_output([GIT, 'show', '--format=format:%T', 'HEAD']).decode('utf8').splitlines()[0]
166+
recreated_tree = subprocess.check_output([GIT, "merge-tree", parents[0], parents[1]]).decode('utf8').splitlines()[0]
170167
if current_tree != recreated_tree:
171168
print("Merge commit {} is not clean".format(current_commit), file=sys.stderr)
172-
subprocess.call([GIT, 'diff', current_commit])
173-
subprocess.call([GIT, 'checkout', '--force', '--quiet', branch])
169+
subprocess.call([GIT, 'diff', recreated_tree, current_tree])
174170
sys.exit(1)
175-
subprocess.call([GIT, 'checkout', '--force', '--quiet', branch])
176171

177172
prev_commit = current_commit
178173
current_commit = parents[0]

0 commit comments

Comments
 (0)