From: Konstantin Kharlamov <hi-angel@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 37395@debbugs.gnu.org
Subject: bug#37395: [PATCH] diff-mode.el: take into account patch separators
Date: Fri, 13 Sep 2019 09:58:27 +0300 [thread overview]
Message-ID: <1568357907.5095.0@yandex.ru> (raw)
In-Reply-To: <838sqs205w.fsf@gnu.org>
On Пт, сен 13, 2019 at 09:14, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
>> Date: Fri, 13 Sep 2019 00:34:45 +0300
>>
>> * lisp/vc/diff-mode.el (diff-goto-line-before-patch-separator): an
>> inline function to check if prev. line was git-format-patch
>> separator,
>> in which case go there.
>> (diff-end-of-hunk): make use of
>> (diff-goto-line-before-patch-separator)
>
> The descriptions of changes should start with a capital letter. Also,
> your lines in the commit log message are too long, they should not
> exceed 61 characters (because in the release tarball we create a
> ChangeLog file from them, which prepends a TAB character to each
> line).
>
>> +(defsubst diff-goto-line-before-patch-separator ()
>> + "Go to prev. line, then if it has patch separator as produced
>> +by git-format-patch, stay there. Otherwise go back."
>
> The first line of a doc string should be a complete sentence. I
> suggest to rephrase as follows:
>
> Return buffer position before patch separator produced by
> git-format-patch.
Thank you, I'll address the comments a bit later this day!
>> + (previous-line)
>> + (when (not (looking-at "-- "))
>> + (next-line))
>> + (point))
>
> Btw, Diff mode is more general than just Git-produced diffs. Is there
> any possibility that this change will misfire in diffs produced by
> other tools? If so, perhaps we should also verify the buffer is under
> Git control.
Oh, while writing this, I figured I should change the regexp from `-- `
to `^-- $`. Will do.
With that addressed: very unlikely. A miscalculation could happen if
all of the following holds true *simultaneously*:
* The diff removes a line with the exact text `- `, i.e. two
characters {dash,space}. That would result in {dash,dash,space} diff,
same as patch separator.
* The line was the last line removed in the hunk.
* The hunk has no context after the removed line
Note, these need to hold true simultaneously. Give the low probability
of this compared to git-format-patch that is used literally everywhere
(and that without this patch diff-mode can't handle it), I think this
is a reasonable trade-off.
next prev parent reply other threads:[~2019-09-13 6:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 21:33 bug#37395: Diff-mode doesn't take into account patch-separators as produced by git-format-patch Konstantin Kharlamov
2019-09-12 21:34 ` bug#37395: [PATCH] diff-mode.el: take into account patch separators Konstantin Kharlamov
2019-09-13 6:14 ` Eli Zaretskii
2019-09-13 6:58 ` Konstantin Kharlamov [this message]
2019-09-16 20:31 ` Konstantin Kharlamov
2019-09-13 9:19 ` bug#37395: [PATCH v2] " Konstantin Kharlamov
2019-09-16 20:26 ` bug#37395: [PATCH v3] " Konstantin Kharlamov
2019-10-07 4:39 ` Lars Ingebrigtsen
2019-10-07 23:04 ` Konstantin Kharlamov
2019-10-07 23:12 ` Konstantin Kharlamov
2019-10-08 15:59 ` Lars Ingebrigtsen
2019-10-08 20:08 ` Konstantin Kharlamov
2019-10-08 19:34 ` bug#37395: [PATCH v4] " Konstantin Kharlamov
2019-10-09 19:36 ` Lars Ingebrigtsen
2019-10-09 20:08 ` Konstantin Kharlamov
2019-10-09 20:07 ` bug#37395: [PATCH v5] " Konstantin Kharlamov
2019-10-13 3:53 ` Lars Ingebrigtsen
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: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1568357907.5095.0@yandex.ru \
--to=hi-angel@yandex.ru \
--cc=37395@debbugs.gnu.org \
--cc=eliz@gnu.org \
/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://git.savannah.gnu.org/cgit/emacs.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).