Issue:
Having a patchdescr.tmpl causes stg new to fail with a Python exception.
$ stg new test Error: Unhandled exception: Traceback (most recent call last): File "/Users/tyler/miniforge3/envs/memfault/lib/python3.6/site-packages/stgit/main.py", line 188, in _main ret = command.func(parser, options, args) File "/Users/tyler/miniforge3/envs/memfault/lib/python3.6/site-packages/stgit/commands/new.py", line 87, in func edit=(not options.save_template and options.message is None), File "/Users/tyler/miniforge3/envs/memfault/lib/python3.6/site-packages/stgit/commands/common.py", line 471, in update_commit_data cd = cd.set_message(cd.message + tmpl) TypeError: can't concat str to bytes
Current environment:
$ stg --version
Stacked GIT 0.23-45-gb4eb-dirty
git version 2.24.3 (Apple Git-128)
Python version 3.6.9 | packaged by conda-forge | (default, Mar 6 2020, 19:19:02)
[GCC Clang 9.0.1 ]
I've also re-produced this issue with brew install stgitwhich uses python@3.9, as well as on an older version of stgit 0.22.
Fix
The fix should just be to use cd.message_str instead of cd.message.
diff --git a/stgit/commands/common.py b/stgit/commands/common.py index 1fd50ce..b39f7a3 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -466,7 +466,7 @@ def update_commit_data(cd, message=None, author=None, sign_str=None, edit=False) if edit: tmpl = templates.get_template('patchdescr.tmpl') if tmpl: - cd = cd.set_message(cd.message + tmpl) + cd = cd.set_message(cd.message_str + tmpl) cd = cd.set_message(edit_bytes(cd.message, '.stgit-new.txt')) return cd
After patching this, using a template stored in .git/patchdescr.tmpl works again.
I apologize in advance for not putting up a fix myself.