)]}'
{
  "commit": "129228c8b01a8fe0345e33fe07d185047721bd68",
  "tree": "f9911f37dfd77d1f30d28d8611f45adbdd23cfd9",
  "parents": [
    "a1537331abaf66fddd3553dd827381a01bcda46c"
  ],
  "author": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Fri Apr 25 19:22:36 2025 +0200"
  },
  "committer": {
    "name": "Tom de Vries",
    "email": "tdevries@suse.de",
    "time": "Fri Apr 25 19:22:36 2025 +0200"
  },
  "message": "[pre-commit] Add codespell-log commit-msg hook\n\nNow that we\u0027re using codespell to check spelling in gdb files, can we use\ncodespell to bring this spelling warning:\n...\n$ echo usuable | codespell -\n1: usuable\n\tusuable \u003d\u003d\u003e usable\n...\nto:\n...\n$ git commit -a -m \"Usuable stuff\"\n...\n?\n\nFirst, let\u0027s look at a straightforward commit-msg hook implementation:\n...\n    - id: codespell\n      name: codespell-commit-msg\n      verbose: true\n      always_run: true\n      stages: [commit-msg]\n...\ninstalled using:\n...\n$ pre-commit install -t commit-msg\n...\n\nWhen trying the commit, we get:\n...\n$ echo \"/* bla */\" \u003e\u003e gdb/gdb.c\n$ git commit -a -m \"Usuable stuff\"\nblack................................................(no files to check)Skipped\nflake8...............................................(no files to check)Skipped\nisort................................................(no files to check)Skipped\ncodespell............................................(no files to check)Skipped\ncheck-include-guards.................................(no files to check)Skipped\nblack................................................(no files to check)Skipped\nflake8...............................................(no files to check)Skipped\ncodespell............................................(no files to check)Skipped\ncodespell-commit-msg.....................................................Failed\n- hook id: codespell\n- duration: 0.06s\n- exit code: 65\n\n.git/COMMIT_EDITMSG:1: Usuable \u003d\u003d\u003e Usable\n\ncheck-include-guards.................................(no files to check)Skipped\n$\n...\n\nThe commit was aborted, but the commit message is still there:\n...\n$ cat .git/COMMIT_EDITMSG\nUsuable stuff\n...\n\nWe can retry and edit the commit message to clean up the typo:\n...\n$ git commit -e -F .git/COMMIT_EDITMSG -a\n...\nbut it\u0027s a bit cumbersome.\n\nFurthermore, say we fix a typo and want to document this in the commit log, and\ndo:\n...\n$ git commit -m \"Fixed typo: useable -\u003e usable\" -a\n...\n\nThis commit cannot succeed, unless we add a codespell ignore tag, which feels\nlike taking it too far.\n\nBoth these problems can be addressed by setting things up in such a way that\nthe commit always succeeds, and codespell output is shown as a hint.\n\nIdeally, we\u0027d tell to pre-commit to implement this using some setting, but\nthere doesn\u0027t seem to be one.\n\nSo we use some indirection.  Instead of using native codespell, use a local\nhook that calls a script gdb/contrib/codespell-log.sh, which calls pre-commit,\nwhich calls codespell.\n\nUsing this approach, we get:\n...\n$ echo \"/* bla */\" \u003e\u003e gdb/gdb.c\n$ git commit -a -m \"Usuable stuff\"\nblack................................................(no files to check)Skipped\nflake8...............................................(no files to check)Skipped\nisort................................................(no files to check)Skipped\ncodespell............................................(no files to check)Skipped\ncheck-include-guards.................................(no files to check)Skipped\nblack................................................(no files to check)Skipped\nflake8...............................................(no files to check)Skipped\ncodespell............................................(no files to check)Skipped\ncheck-include-guards.................................(no files to check)Skipped\ncodespell-log............................................................Passed\n- hook id: codespell-log\n- duration: 0.18s\n\ncodespell-log-internal...................................................Failed\n- hook id: codespell\n- exit code: 65\n\n.git/COMMIT_EDITMSG:1: Usuable \u003d\u003d\u003e Usable\n\n[codespell/codespell-log-2 d081bd25a40] Usuable stuff\n 1 file changed, 1 insertion(+)\n$\n...\n\nThis is obviously convoluted, but it works.  Perhaps we can propose a\npre-commit improvement (always_pass) and simplify this eventually.\n\nChecked new script codespell-log.sh with shell-check.\n\nApproved-By: Simon Marchi \u003csimon.marchi@efficios.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "b55685b5f70f46740d31df83bececf6e359a62c3",
      "old_mode": 33188,
      "old_path": ".pre-commit-config.yaml",
      "new_id": "7cb7008f2df7ea8407ac681cd4330f1e9b9e87e1",
      "new_mode": 33188,
      "new_path": ".pre-commit-config.yaml"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "10780f86c5f385966848f2c3ee91b0ef65d15607",
      "new_mode": 33261,
      "new_path": "gdb/contrib/codespell-log.sh"
    }
  ]
}
