Hi, Sorry for the late reply. On 12/05/20 01:42PM, J. Paul Reed wrote: > > Hey Richard, You replied to the wrong person ;-) > Using your test case, I still get the error (which is, specifically an > error dialog saying: > > Failed to stage selected line. > > error: patch failed: glacierupload.sh:55 > error:glacierupload.sh: patch does not apply > > Note that I'm highlighting the change in the source code, then > right-clicking it and selecting "Stage lines for commit." ("Stage hunk for > commit" also results in the error.) > > If I stage the entire file by clicking on it in the upper-lefthand pane, > things work fine. > > This is a Gentoo box, so I wonder I happened to build Tcl without the > appropriate unicode support (that one would find in most package-based > distros)? > > In briefly digging a bit more, it would seem that git gui is foisting the > work onto "git apply" to create a patch and stage it? (If I'm reading the > source correctly, It looks like the error dialog title is from > https://github.com/prati0100/git-gui/blob/master/lib/diff.tcl#L700 You are close, but not quite there. We don't use "git apply" to _create_ a patch. We create the patch ourselves, and then pass it to git apply to stage/unstage the lines selected. I suspect it is some encoding mismatch. Can you apply this patch below and send what the output is? -- 8< -- diff --git a/lib/diff.tcl b/lib/diff.tcl index 871ad48..6226a89 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -851,8 +851,13 @@ proc apply_or_revert_range_or_line {x y revert} { set first_l [$ui_diff index "$next_l + 1 lines"] } + puts "Diff we will send to git-apply:" + puts -nonewline "$current_diff_header" + puts -nonewline "$wholepatch" + if {[catch { set enc [get_path_encoding $current_diff_path] + puts "\nEncoding: $enc" set p [eval git_write $apply_cmd] fconfigure $p -translation binary -encoding $enc puts -nonewline $p $current_diff_header -- >8 -- > and then the error strings that populate the dialog are bubbled up from git > apply. > > Any ideas on what would make "git apply" potentially choke? I wonder if it > has to do with a mixed file encoding? git-gui not preparing the patch text properly would be a prime candidate. > I tried setting both: > > core.checkRoundTripEncoding true > gui.encoding utf-8 > > on that repo; git gui still errored out in the same way. > > I also tried changing gui.encoding to utf-16; no dice... > > To reiterate, git add -i worked fine... -- Regards, Pratyush Yadav