mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Pratyush Yadav <>
To: "J. Paul Reed" <>
Cc: "Kerry, Richard" <>,
	"" <>
Subject: Re: git-gui patch staging errors
Date: Mon, 25 May 2020 18:38:07 +0530	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>


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:
> 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

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

Pratyush Yadav

  reply	other threads:[~2020-05-25 13:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12  1:07 git-gui patch staging errors J. Paul Reed
2020-05-12 12:15 ` Pratyush Yadav
2020-05-12 14:27   ` Kerry, Richard
2020-05-12 19:00     ` Pratyush Yadav
2020-05-12 20:42     ` J. Paul Reed
2020-05-25 13:08       ` Pratyush Yadav [this message]
2020-07-26 22:15         ` J. Paul Reed

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:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* 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

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