summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2023-02-24 10:59:18 +0100
committerMiklos Vajna <vmiklos@collabora.com>2023-02-24 10:00:57 +0000
commit3ce714de3b5319efeee3f713c82d58649b3e0098 (patch)
treea45d3ae5b331a58eb866d0cb1f453cbed5a54f5c
parentb1b1ad1e4b562ee56eeeb87619732beff46da8b9 (diff)
git-cherry-gerrit.py: fix crash when the rev-list output is empty
Traceback (most recent call last): File "git-cherry-gerrit.py", line 103, in <module> main() File "git-cherry-gerrit.py", line 83, in main changeid = get_change_id(git_cat_file, from_hash) File "git-cherry-gerrit.py", line 29, in get_change_id size = first_line.strip().split(" ")[2] IndexError: list index out of range Change-Id: Icc53d038ceebc690998dc14da15f7b1b9ac4f341 Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/147618 Tested-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rwxr-xr-xscripts/git-cherry-gerrit.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/scripts/git-cherry-gerrit.py b/scripts/git-cherry-gerrit.py
index bb8235fa..9ee285b2 100755
--- a/scripts/git-cherry-gerrit.py
+++ b/scripts/git-cherry-gerrit.py
@@ -74,7 +74,11 @@ def main() -> None:
for to_hash in to_hashes:
to_change_ids.append(get_change_id(git_cat_file, to_hash))
- from_hashes = from_pipe(["git", "rev-list", branch_point + ".." + cherry_from]).split("\n")
+ from_hashes = []
+ buffer = from_pipe(["git", "rev-list", branch_point + ".." + cherry_from])
+ # If there are no commits, we want an empty list, not a list with one empty item.
+ if buffer:
+ from_hashes = buffer.split("\n")
whitelist: List[str] = []
if whitelist_file:
with open(whitelist_file, "r") as stream: