From 3a66f25b253bf7790b45f5640d22298f0f00c70b Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Fri, 12 Apr 2019 14:55:13 -0500 Subject: [PATCH] Handle commit mergetags (at all) Previously bup would just crash (i.e. bup ls) if it encountered a commit with a mergetag header (apparently a new thing). For now, adjust git.parse_commit to accept and ignore them as long as they only appear as an optional, final header in the commit. That may or may not turn out to be sufficient, and it does mean that for now we won't be able to preserve mergetags (if we want to) whenever we rewrite commits via bup gc, get, etc. A mergetag example (indented two spaces): tree 1ebcecb7117725fd567de6e9652dc34b5b103f6d parent d3e6b8a251634ad673242aaa4a298edbb2e8ee39 parent 3a34412caae002accd0fc7a7fc0b718c2f34159b author Rob Browning 1498341839 -0500 committer Rob Browning 1498341839 -0500 mergetag object 3a34412caae002accd0fc7a7fc0b718c2f34159b type commit tag emacs-25.2 tagger Nicolas Petton 1492704766 +0200 Emacs 25.2 release -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJY+N4EAAoJECM1h6R8IHkQFeEH/2FlBZSzsxNnXcMLVNirG0Uu 8CBEAlme4LcViKs6Ae2uzPP4DrwN1g4LLNGnHBYQoL5nzwPtNOLDjaVtB2D7Q5Lj OgtiLix5kHNXh6j2GRnCHI5a6h52FY0yiaslefbstVu554S+1ttDbmqCgo5wtzFM eSPbxjLn1SrXSe9Mpfi/tBM2go7J4bihF6GyUktObwAkhOCz3ctJGTMltHzub1RC fZBku7bYjgbJocKJ+8MyfcgGz8sb1lV6jeJ9Yu+FuO6PIH9JtHZkjYbFhXqV8TxU vHfiCD8QK8w3SJ4RiMltfaFqhc0LFt1mUYOtHzwMbML8nqDV9SfozG7APN7f4OE= =oY2c -----END PGP SIGNATURE----- Merge upstream version 25.2 Signed-off-by: Rob Browning Tested-by: Rob Browning --- lib/bup/git.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/bup/git.py b/lib/bup/git.py index 23fadb3..3c88d74 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -76,17 +76,21 @@ _safe_str_rx = '(?:%s{1,2}|(?:%s%s*%s))' \ _start_end_char, _content_char, _start_end_char) _tz_rx = r'[-+]\d\d[0-5]\d' _parent_rx = r'(?:parent [abcdefABCDEF0123456789]{40}\n)' +# Assumes every following line starting with a space is part of the +# mergetag. Is there a formal commit blob spec? +_mergetag_rx = r'(?:\nmergetag object [abcdefABCDEF0123456789]{40}(?:\n [^\0\n]*)*)' _commit_rx = re.compile(r'''tree (?P[abcdefABCDEF0123456789]{40}) (?P%s*)author (?P%s) <(?P%s)> (?P\d+) (?P%s) -committer (?P%s) <(?P%s)> (?P\d+) (?P%s) +committer (?P%s) <(?P%s)> (?P\d+) (?P%s)(?P%s?) (?P(?:.|\n)*)''' % (_parent_rx, _safe_str_rx, _safe_str_rx, _tz_rx, - _safe_str_rx, _safe_str_rx, _tz_rx)) + _safe_str_rx, _safe_str_rx, _tz_rx, + _mergetag_rx)) _parent_hash_rx = re.compile(r'\s*parent ([abcdefABCDEF0123456789]{40})\s*') - -# Note that the author_sec and committer_sec values are (UTC) epoch seconds. +# Note that the author_sec and committer_sec values are (UTC) epoch +# seconds, and for now the mergetag is not included. CommitInfo = namedtuple('CommitInfo', ['tree', 'parents', 'author_name', 'author_mail', 'author_sec', 'author_offset', -- 2.39.2