mackyle/topgit

Include "git notes" when doing "tg export --collapse"

Closed this issue · 5 comments

When running tg export --collapse, it would be great if there was a way to include "git-notes" into the commit messages from .topmsg.

The workflow here is that I am working on a v2 of a patchset and typically the changelog is added as a git-note to the patch. It would be nice if I could track the changelog in .topmsg and it then gets automatically added to the patches when exporting and collapsing.

An example would be helpful. Notes are attached to individual object hash id values. I'm unclear on which notes you're wanting to pick up? The .topmsg file can be edited as you go along to add things as the version from the tip of the branch is used when creating the patch.

But since notes are attached to specific commits (usually, they can actually be attached to any object) which commit would TopGit get notes from, or are you wanting all the notes from some portion of the commit graph and if so which portion?

I think an example would be most helpful in clarifying what you're looking for.

Let me try to clarify:

I would like the .topmsg to include the git-note so that tg export --collapse can pick the git-note from there. E.g., the .topmsg file could look like:

From: Christoph Paasch <...>
Subject: [PATCH v2] ..
...

Signed-off-by: Christoph Paasch <...>

---
v2: * Fix comments

Then when I export, topgit would put the v2: * Fix comments as a git-note to the commit.

But since notes are attached to specific commits (usually, they can actually be attached to any object) which commit would TopGit get notes from, or are you wanting all the notes from some portion of the commit graph and if so which portion?

The note should come from the .topmsg and get attached to the exported commit.

Does that clarify things? Thanks!

Okay, thanks, I understand what you want now.

It looks like the "note portion" is already being stripped off of the commit message for the collapsed commit courtesy of git mailinfo even though the man page for that command neglects to mention that it does that.

This is alluded to in the git am help, but it's not fully detailed. The rule apparently is that the separator line must match /^---[ \t]*$/ in order to be recognized. (The git am` help fails to mention that optional whitespace is allowed before the end-of-line.)

TopGit, however, needs to document this behavior regarding the .topmsg file! :)

Obviously any new option should work for both --collapse and --linearize (the "note" is already preserved in --quilt output).

I will ponder adding support for this. It seems reasonable, but needs to be done cleanly so that:

  1. the notes ref can be specified (refs/notes/commits should not be forced but can be the default)
  2. which notes ref to use can be set as a preference
  3. always attaching the notes can be set as a preference (possibly combined with 2)

Cool! Let me know if there is a branch I can test out.

This has been included in he topgit-0.19.13 release. Both tg export and tg import got a new --notes option (check the help for details). While I have performed some testing and verified that notes can now round-trip -- tg export --notes puts them in a git notes item and tg import --notes grabs them and sticks them in the imported .topmsg after a 3-dashes (---) separator -- it's possible there are still areas for improvement. Please file an issue if you find any problems.