unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#68377: Cannot commit parts of *vc-diff* on Microsoft Windows
@ 2024-01-11  2:07 Sam Steingold
  2024-01-11 12:28 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Sam Steingold @ 2024-01-11  2:07 UTC (permalink / raw)
  To: 68377

https://emacs.stackexchange.com/q/80039/795

Emacs has a beautiful feature: in the `*vc-diff*` buffer (generated by [`vc-diff`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Old-Revisions.html) either by <kbd>C-x v =</kbd> in a file buffer or by <kbd>=</kbd> in a `*vc-dir*` buffer), kill unwanted hunks with <kbd>k</kbd> (i.e., [`diff-hunk-kill`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Diff-Mode.html)) and then commit the remaining hunks with <kbd>C-x v v</kbd> (i.e., [`vc-next-action`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Basic-VC-Editing.html)). If you don't know about it -- try it, it is incredibly useful!

Alas, it does _not_ work for me on windows: after <kbd>C-c C-c</kbd> (i.e., [`log-edit-done`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Log-Buffer.html)) in `*vc-log*`, I get 
> vc-do-command: Failed (status 1): c:/Users/ssteingold/AppData/Local/Git/bin/git.exe --no-pager apply --cached c:/msys64/tmp/git-patchPbbWgJ

and `*vc*` buffer is
```
error: patch failed: fxpy/model.py:1071
error: fxpy/model.py: patch does not apply
```

***Additionally***: 

1. Software:
   * [`GNU Emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-08-02`](https://ftp.gnu.org/gnu/emacs/windows/emacs-29/)
   * [`git version 2.42.0.windows.2`](https://gitforwindows.org/)
1. *normal* commits work just **fine**, using `vc-next-action` from either file buffer or `*vc-dir*`.
1. All my files have unix line terminators (`LF`) as indicated in the mode line as `(Unix)`
1. I set `autocrlf` to `false` globally
1. I have `(prefer-coding-system 'utf-8-unix)` in `.emacs`
1. `vc-coding-system-inherit-eol` is `t`, I did not touch it
1. When I add `"-v"` to `git apply` invocation in `vc-git-checkin` (`vc-git.el`), `*vc*` buffer contains `error: while searching for:.....` and every line in `.....` is terminated with `?` - which seems to indicate line-ending problems... (!!!)

***Q***: how do I fix this?
(This is a work box, I cannot send email from Emacs, so I cannot even file an Emacs bug report!)

# work-around 1

Add 
```
(setq coding-system-for-write 'utf-8-unix)
```
inside `(with-temp-file patch-file ...)` in `vc-git-checkin`

# work-around 2

Add
```
;; replace `undecided`:
(setf (cadr (assoc "" file-coding-system-alist)) 'utf-8-unix)
```
to `.emacs`

# Emacs bug

`vc-git-checkin` should respect `vc-coding-system-inherit-eol` and set [`coding-system-for-write`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Specifying-Coding-Systems.html) when writing the patch.

Also, it does not seem reasonable that [`prefer-coding-system`](https://www.gnu.org/software/emacs/manual/html_node/emacs/Output-Coding.html) does not affect [`file-coding-system-alist`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Default-Coding-Systems.html).






^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-02-10 11:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-11  2:07 bug#68377: Cannot commit parts of *vc-diff* on Microsoft Windows Sam Steingold
2024-01-11 12:28 ` Eli Zaretskii
2024-01-11 12:44   ` Eli Zaretskii
2024-01-11 12:54     ` Eli Zaretskii
2024-01-11 13:19   ` Dmitry Gutov
2024-01-11 14:47     ` Eli Zaretskii
2024-01-11 15:07       ` Dmitry Gutov
2024-01-14 16:42         ` Eli Zaretskii
2024-01-27  9:11           ` Eli Zaretskii
2024-02-10  8:06             ` Eli Zaretskii
2024-02-10 11:44               ` Dmitry Gutov

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).