git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Pratyush Yadav <me@yadavpratyush.com>
To: "J. Paul Reed" <preed@sigkill.com>
Cc: "Kerry, Richard" <richard.kerry@atos.net>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git-gui patch staging errors
Date: Mon, 25 May 2020 18:38:07 +0530	[thread overview]
Message-ID: <20200525130807.4ydporgaeva27del@yadavpratyush.com> (raw)
In-Reply-To: <20200512204233.GA31807@sigkill.com>

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

  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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20200525130807.4ydporgaeva27del@yadavpratyush.com \
    --to=me@yadavpratyush.com \
    --cc=git@vger.kernel.org \
    --cc=preed@sigkill.com \
    --cc=richard.kerry@atos.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://80x24.org/mirrors/git.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).