{"id":10911,"url":"https://patchwork.libcamera.org/api/1.1/patches/10911/?format=json","web_url":"https://patchwork.libcamera.org/patch/10911/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<CAEmqJPrFWxpdjqP18m3x8Hj+HAWEFOfeU4giZX-daALa9Jon0A@mail.gmail.com>","date":"2021-01-20T10:52:47","name":"[libcamera-devel] Problem with utils/checkstyle.py in a pre-commit hook?","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"6f900dc7521225140b71a9de12a9d0e669bc2584","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/10911/mbox/","series":[{"id":1589,"url":"https://patchwork.libcamera.org/api/1.1/series/1589/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1589","date":"2021-01-20T10:52:47","name":"[libcamera-devel] Problem with utils/checkstyle.py in a pre-commit hook?","version":1,"mbox":"https://patchwork.libcamera.org/series/1589/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10911/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10911/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 41BFBBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Jan 2021 10:53:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BFFF16819A;\n\tWed, 20 Jan 2021 11:53:05 +0100 (CET)","from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com\n\t[IPv6:2a00:1450:4864:20::22a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 27F896817D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Jan 2021 11:53:04 +0100 (CET)","by mail-lj1-x22a.google.com with SMTP id x23so25485096lji.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Jan 2021 02:53:04 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"fuwICoq4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:from:date:message-id:subject:to;\n\tbh=s2z+AxAv5SFSabwAfK9HauDfwPfAyziOrNuzJH7PHEE=;\n\tb=fuwICoq4HHKfjNvunwC7iDF/1yf/SwHKWJ8+ZnGvmDRAdneWSOuZJbCvkCWkTsey93\n\tTgaV4XMxJ/Pr2nrPGyEETXJIaO7TR1q/qU0MWvjsuFl3MB0cNExpWeXh0129ZY6PXXag\n\t67VXKgaSQmXlRqbcpRm9b7OltkhkkJRKPWvyo+8idRuGZxDGFeGarm3+TWpzgk+8scgV\n\tw8oVESJeUOjD3OPZnN3vL3fzHEjaCwf6MRx1xwPFY9s6qqX+wYmsU9ZSiR3VmYH39OOT\n\tcfhAJKhwEBjj99ZjAplkKuxIbMBSJD6iLX2rtawJY79TnBEjHXdZxZBgPIR0MHndmwYB\n\t40LQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:from:date:message-id:subject:to;\n\tbh=s2z+AxAv5SFSabwAfK9HauDfwPfAyziOrNuzJH7PHEE=;\n\tb=B+sVoQg3Hlfwef4kZAdI9l7Z9//UHSr5PeO7KxkKHRK1tNUkJ2ZD/cHm2AmkdGBe5r\n\tnywUddyCNlOSFZIXAxu61Bivibc/NSExKqzUkbY7dZjaqMqUVzccYQvqXwN1fNhsnRrx\n\td6PYtC1liu9g3J7PitKF2SpZ3RbO6ltco1PKF43gT8QcFjhaPIyxsMxRGNkCaQptid68\n\tvm/y4AnMAmT/5Tl5iY366HkdVX7eEqfRD9ZuLzvnN2aavbTHkLIr8Wuul4RS5rgnFskt\n\tUmGqL1wMX47HOxJrsGOexU06Z7/UnAPflYMGTyXupEvfxr3y4RjA37/5taTY2REaeZ2e\n\tgi1g==","X-Gm-Message-State":"AOAM531wX8rHn6KBCbFSKMhrVfB9Whe++6uIvcKeKgvQ3889P9v+NpHg\n\tbLKIf98yrRXIslW6j2RnM7W/g0TQ/ETdKD5T60AztNdv8qS2NA==","X-Google-Smtp-Source":"ABdhPJymaSI2U0bCNlleyHiK57gHx+amthCP+JS5mU4bl0Ptekyn4bfO7UOoKzDWmJta0R+yvGPYaxwR9xSuBnw1QNI=","X-Received":"by 2002:a2e:93d6:: with SMTP id\n\tp22mr4276523ljh.169.1611139983279; \n\tWed, 20 Jan 2021 02:53:03 -0800 (PST)","MIME-Version":"1.0","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Wed, 20 Jan 2021 10:52:47 +0000","Message-ID":"<CAEmqJPrFWxpdjqP18m3x8Hj+HAWEFOfeU4giZX-daALa9Jon0A@mail.gmail.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Subject":"[libcamera-devel] Problem with utils/checkstyle.py in a pre-commit\n\thook?","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"multipart/mixed;\n\tboundary=\"===============7535059837732288234==\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Hi all,\n\nI have started noticing a problem with the utils/checkstyle.py script when\nrun in the provided pre-commit hook (utils/hooks/pre-commit).  Here is an\nexample output when I do a \"git commit --amend --fixup=xxxx\" command:\n\nfatal: ambiguous argument '': unknown revision or path not in the working\ntree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\nTraceback (most recent call last):\n  File \"./utils/checkstyle.py\", line 875, in <module>\n    sys.exit(main(sys.argv))\n  File \"./utils/checkstyle.py\", line 850, in main\n    commits.append(StagedChanges())\n  File \"./utils/checkstyle.py\", line 237, in __init__\n    Commit.__init__(self, '')\n  File \"./utils/checkstyle.py\", line 206, in __init__\n    self.__parse()\n  File \"./utils/checkstyle.py\", line 215, in __parse\n    self.__title = files[0]\nIndexError: list index out of range\n\nThis used to certainly work in the past, so I can only assume either\nsomething in the script, or my environment has changed.  The reason behind\nthe git command failure seems to be related to the last argument in the\nsubprocess call:\n\nret = subprocess.run(['git', 'show', '--pretty=oneline', '--name-status',\n                                  self.commit],\n\nstdout=subprocess.PIPE).stdout.decode('utf-8')\n\nwhere self.commit is an empty string.\n\nThis may have been introduced by commit 097720840 ('utils: checkstyle.py:\nMove commit handling to a separate section').  A fix that works for me is\nas follows:\n\n         self.__files = [CommitFile(f) for f in files[1:]]\n\nI was just wondering if I have something strange in my environment that is\ncausing these issues, or are other folks seeing this as well?\n\nRegards,\nNaush","diff":"diff --git a/utils/checkstyle.py b/utils/checkstyle.py\nindex 0e9659e98518..cb7b2d151412 100755\n--- a/utils/checkstyle.py\n+++ b/utils/checkstyle.py\n@@ -207,9 +207,11 @@ class Commit:\n\n     def __parse(self):\n         # Get the commit title and list of files.\n-        ret = subprocess.run(['git', 'show', '--pretty=oneline',\n'--name-status',\n-                              self.commit],\n-                             stdout=subprocess.PIPE).stdout.decode('utf-8')\n+        args = ['git', 'show', '--pretty=oneline', '--name-status']\n+        if self.commit != '':\n+            args.append(self.commit)\n+\n+        ret = subprocess.run(args,\nstdout=subprocess.PIPE).stdout.decode('utf-8')\n         files = ret.splitlines()\n","prefixes":["libcamera-devel"]}