Comments (15)
It's because there's a mix of unix and DOS newlines. Pretty easy to fix... I think.
*edit: or perhaps not.
from magit.
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.
from magit.
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.
from magit.
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.
from magit.
Steps to reproduce:
- git init
- echo hello > hello.txt
- git add hello.txt
- git commit -a -m 'hello'
- unix2dos hello.txt
- emacs
- M-x magit-status RET
- try to hit "v" at the hunk
Expected results:
8) hunk is reverted
Actual results:
8) magit says "git failed"
More info:
- Remarkably the problem stops occuring if I run
strace -p $(pidof emacs) -o emacs.strace -f -s4096
and then hit "v" again. Can you reproduce this?
from magit.
If I strace only git I see
15060 read(0, "diff --git a/hello.txt b/hello.txt\n", 8192) = 35
15060 read(0, "index ce01362..ef0493b 100644\n", 12277) = 30
15060 read(0, "--- a/hello.txt\n", 12247) = 16
15060 read(0, "+++ b/hello.txt\n", 12231) = 16
15060 read(0, "@@ -1 +1 @@\n", 12215) = 12
15060 read(0, "-hello\n", 12203) = 7
15060 read(0, "+hello\n", 12196) = 7
15060 read(0, "\n", 12189) = 1
15060 read(0, "", 12188)
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
15279 read(0, "", 12188)
which includes the "\r".
from magit.
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?
from magit.
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
from magit.
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!
from magit.
Thanks for your work, chaps.
from magit.
Is there any ETA on this patch being merged?
from magit.
Sorry to keep harping on this. Any ETA on merging?
from magit.
I've applied lindi's patch. Thanks again.
from magit.
Oh frabjous day! Callooh! Callay! Makes me so happy!
from magit.
Good job, thank you!
from magit.
Related Issues (20)
- Magit displays warning about transient version, even though I'm using the latest. HOT 5
- magit-log-mode-hook Does Not Work
- Magit commit fails with `safe.barerepository=explicit`. HOT 13
- Hunk refinement does not work for unmerged files HOT 1
- magit-blame shows CommitDate instead of AuthorDate
- Stage hunk in tramp session result in infinity loop HOT 2
- When doing worktree diff with a commit, apply/reverse doesn't work in the diff buffer HOT 3
- Setting `safe.bareRepository=explicit` breaks magit commit HOT 1
- magit-diff-paths output is not washed HOT 1
- Error in `magit-repolist-column-version` function: (wrong-type-argument integer-or-marker-p nil) HOT 1
- `magit-log` with `--author=` argument hangs with `vertico-mode` when `transient-default-level` is 7 HOT 2
- Magit should always specify --git-dir or GIT_DIR when cd-ing to a gitdir to run some Git subcommand. HOT 19
- Binding C-<tab> conflicts with Emacs' tab-bar-mode HOT 1
- Non-existing tramp function advised in magit-process.el HOT 1
- Confirm commit message when running emacs as client HOT 5
- Trying to visit files in `magit-diff-paths` output leads to wrong path
- large git merges make magit-process buffer grow quickly
- `Filter! diff.ignoreSubmodules=untracked` on top of magit buffer is confusing
- Unable to recursively init submodules HOT 1
- submodule update with universal argument still prompts for submodule selection when there is only one submodule HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magit.