-
-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOS line endings break hunk operations #20
Comments
It's because there's a mix of unix and DOS newlines. Pretty easy to fix... I think. *edit: or perhaps not. |
I'm going to try to take a look at it tonight if I have time. I'm assuming it's just some sort of escaping issue, but I only looked at the code for about 30 seconds. |
I tried to figure this out but couldn't. I tried using shell-quote-argument in magit-insert-current-line but that had no effect. I had difficulty following the flow of the program so that may not be where the problem is. It's seriously driving me insane though. |
Someone tagged this as "windows" It's not a windows problem. I'm having this problem on Linux where the original files were created in Windows with dos line endings. |
Steps to reproduce:
Expected results: Actual results: More info:
strace -p $(pidof emacs) -o emacs.strace -f -s4096 and then hit "v" again. Can you reproduce this? |
If I strace only git I see 15060 read(0, "diff --git a/hello.txt b/hello.txt\n", 8192) = 35 which obviously lacks the \r. If I strace both emacs and git I see 15279 read(0, "diff --git a/hello.txt b/hello.txt\nindex ce01362..ef0493b 100644\n--- a/hello.txt\n+++ b/hello.txt\n@@ -1 +1 @@\n-hello\n+hello\r\n", 8192) = 124 which includes the "\r". |
The issue seems to be that the git subprocess has a terminal and stty -F /dev/pts/10 -a shows that "icrnl" is set. This means that \r gets converted to \n. Why is git run in a terminal? |
You can pull a proposed fix from the issue-20 branch at http://iki.fi/lindi/git/magit.git From d8c938a812748b638e4ba6c30f7058e3920287b4 Mon Sep 17 00:00:00 2001 From: Timo Juhani Lindfors Date: Tue, 14 Sep 2010 22:33:02 +0300 Subject: [PATCH] Don't use a pty with git processes that take input from magit since that would set the terminal option icrnl which would modify the input. In particular \r would get converted to \n (issue #20). --- magit.el | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/magit.el b/magit.el index 057c9c8..5f271fa 100644 --- a/magit.el +++ b/magit.el @@ -1465,7 +1465,10 @@ FUNC should leave point at the end of the modified region" (with-current-buffer input (setq default-directory dir) (setq magit-process - (apply 'magit-start-process cmd buf cmd args)) + ;; Don't use a pty, because it would set icrnl + ;; which would modify the input (issue #20). + (let ((process-connection-type nil)) + (apply 'magit-start-process cmd buf cmd args))) (set-process-filter magit-process 'magit-process-filter) (process-send-region magit-process (point-min) (point-max)) -- 1.7.1 |
Tested and works great! So awesome. This has been driving me crazy for months but I haven't been able to get around to trying to figure it out. Hope this gets integrated into the mainline soon! |
Thanks for your work, chaps. |
Is there any ETA on this patch being merged? |
Sorry to keep harping on this. Any ETA on merging? |
I've applied lindi's patch. Thanks again. |
Oh frabjous day! Callooh! Callay! Makes me so happy! |
Good job, thank you! |
that would set the terminal option icrnl which would modify the input. In particular \r would get converted to \n (issue magit#20).
`git-commit-skip-magit-header-regexp` is nil before Magit is loaded. If Git Commit Mode was loaded first, the variable would be added as `nil` into the font lock keywords, thus breaking fontification.
`git-commit-skip-magit-header-regexp` is nil before Magit is loaded. If Git Commit Mode was loaded first, the variable would be added as `nil` into the font lock keywords, thus breaking fontification.
When a file with DOS line endings is changed, operations on hunks no longer work.
Steps to reproduce:
create a git repo
add a file with dos line endings (I did this by creating a file and then using unix2dos to change the line endings)
commit the file
edit the file
try to remove edited hunk (not all edits on the file!)
The text was updated successfully, but these errors were encountered: