From: "Michael S. Tsirkin" <mst@redhat.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: bug? illegal text in commit log
Date: Tue, 4 Feb 2020 01:14:48 -0500 [thread overview]
Message-ID: <20200204010524-mutt-send-email-mst@kernel.org> (raw)
It seems that it's not too hard to make commits such that
the standard way of git format-patch -> email -> git am
fails.
For example:
[mst@tuck ~]$ mkdir gittest
[mst@tuck ~]$ cd gittest/
[mst@tuck gittest]$ git init
Initialized empty Git repository in /home/mst/gittest/.git/
[mst@tuck gittest]$ echo AA > a.txt
[mst@tuck gittest]$ git add a.txt
[mst@tuck gittest]$ git commit
[master (root-commit) 46e2cd1] original
1 file changed, 1 insertion(+)
create mode 100644 a.txt
[mst@tuck gittest]$ echo AA > b.txt
[mst@tuck gittest]$ echo BB > c.txt
[mst@tuck gittest]$ diff -u b.txt c.txt > bc.diff
[mst@tuck gittest]$ echo "this change" > commitlog.txt
[mst@tuck gittest]$ echo >> commitlog.txt
[mst@tuck gittest]$ cat bc.diff >> commitlog.txt
[mst@tuck gittest]$ echo BB >> a.txt
[mst@tuck gittest]$ git commit -a -F commitlog.txt
[master c5f40b2] this change
1 file changed, 1 insertion(+)
[mst@tuck gittest]$ git format-patch HEAD~1..
0001-this-change.patch
[mst@tuck gittest]$ git reset --hard HEAD~1
HEAD is now at 46e2cd1 original
[mst@tuck gittest]$ git am 0001-this-change.patch
Applying: this change
error: sha1 information is lacking or useless (c.txt).
error: could not build fake ancestor
Patch failed at 0001 this change
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
A work around is "don't do it" - avoid putting anything that looks like
a unified diff in the commit log.
However:
- Users don't know what other restrictions exist
- User sending the patch has no way to detect failure,
it's only visible to user receiving the patch
Ideas:
- validate commit log and warn users?
- find a way to escape text in git format-patch, and unescape in git am?
Thanks,
--
MST
next reply other threads:[~2020-02-04 6:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-04 6:14 Michael S. Tsirkin [this message]
2020-02-04 21:10 ` bug? illegal text in commit log René Scharfe
2020-02-04 21:25 ` Junio C Hamano
2020-02-06 6:34 ` Michael S. Tsirkin
2020-02-06 16:17 ` Junio C Hamano
2020-02-06 16:45 ` Junio C Hamano
2020-02-06 17:30 ` René Scharfe
2020-02-07 5:40 ` Junio C Hamano
2020-02-07 20:30 ` René Scharfe
2020-02-12 2:24 ` Jeff King
2020-02-06 23:56 ` Michael S. Tsirkin
2020-02-07 11:02 ` Pratyush Yadav
2020-02-07 20:31 ` René Scharfe
2020-02-07 21:12 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200204010524-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).