* Bug in Git-Gui - Creates corrupt patch
@ 2009-02-25 15:03 4jxDQ6FQee2H
2009-02-25 15:26 ` 4jxDQ6FQee2H
2009-02-25 15:46 ` Johannes Sixt
0 siblings, 2 replies; 7+ messages in thread
From: 4jxDQ6FQee2H @ 2009-02-25 15:03 UTC (permalink / raw)
To: spearce; +Cc: git
Hi Shawn,
I have stumbled upon a bug in Git-GUi and am providing reproduction
steps:
1. Commit this file into a new git repository:
-----------------------------
<?php
class myclass {
public function funcAbc() {
echo "line 1";
echo "line 2";
echo "line 3";
echo "line 4";
echo "line 5";
}
public function funcBCD() {
echo "line 1-1";
echo "line 2-1";
echo "line 3-1";
echo "line 4-1";
echo "line 5-1";
}
}
?>
--------------
Here is the base64 encoded version:
PD9waHAKCmNsYXNzIG15Y2xhc3MgewoJcHVibGljIGZ1bmN0aW9uIGZ1bmNBYmMoKSB7CgkJZWNo
byAibGluZSAxIjsKCQllY2hvICJsaW5lIDIiOwoJCWVjaG8gImxpbmUgMyI7CgkJZWNobyAibGlu
ZSA0IjsKCQllY2hvICJsaW5lIDUiOwoJfQoJCglwdWJsaWMgZnVuY3Rpb24gZnVuY0JDRCgpIHsK
CQllY2hvICJsaW5lIDEtMSI7CgkJZWNobyAibGluZSAyLTEiOwoJCWVjaG8gImxpbmUgMy0xIjsK
CQllY2hvICJsaW5lIDQtMSI7CgkJZWNobyAibGluZSA1LTEiOwoJfQp9Cgo/Pg==
2. Now delete the last function in the class. Here's the resulting
file, it is not staged or commited yet.
----------------------------
<?php
class myclass {
public function funcAbc() {
echo "line 1";
echo "line 2";
echo "line 3";
echo "line 4";
echo "line 5";
}
}
?>
----------------------------
Here is the base64 encoded version:
PD9waHAKCmNsYXNzIG15Y2xhc3MgewoJcHVibGljIGZ1bmN0aW9uIGZ1bmNBYmMoKSB7CgkJZWNo
byAibGluZSAxIjsKCQllY2hvICJsaW5lIDIiOwoJCWVjaG8gImxpbmUgMyI7CgkJZWNobyAibGlu
ZSA0IjsKCQllY2hvICJsaW5lIDUiOwoJfQp9Cgo/Pg==
3. Using git-gui, try to stage *only* the last line marked for removal
(should be '- }').
I get 'fatal: corrupt patch at line 22'.
4. Now try the same task using git-add -p. Start 'git-add -p'. Enter
edit mode (e). Remove all the '-' lines except the last one (make
them ' ') so that only the last '-' will be removed. Save and exit.
On my system the patch is committed.
I'm running git version 1.6.0.6, 32bit linux, Gentoo OS
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Bug in Git-Gui - Creates corrupt patch
2009-02-25 15:03 Bug in Git-Gui - Creates corrupt patch 4jxDQ6FQee2H
@ 2009-02-25 15:26 ` 4jxDQ6FQee2H
2009-02-25 15:46 ` Johannes Sixt
1 sibling, 0 replies; 7+ messages in thread
From: 4jxDQ6FQee2H @ 2009-02-25 15:26 UTC (permalink / raw)
To: spearce; +Cc: git
Shawn,
I've added these lines to '/usr/share/git-gui/lib/diff.tcl' in the
'catch' block of apply_line():
----------------------------------------------
puts -nonewline stdout $p
puts -nonewline stdout $current_diff_header
puts -nonewline stdout $patch
----------------------------------------------
This produces the following patch that gets sent to git-apply:
---------------------------------------------
file7diff --git a/file b/file
--- a/file
+++ b/file
@@ -6,17 +6,16 @@
echo "line 2";
echo "line 3";
echo "line 4";
echo "line 5";
}
public function funcBCD() {
echo "line 1-1";
echo "line 2-1";
echo "line 3-1";
echo "line 4-1";
echo "line 5-1";
- }
}
?>
\ No newline at end of file
---------------------------------------------
Here's the base64 encoded version:
ZmlsZTdkaWZmIC0tZ2l0IGEvZmlsZSBiL2ZpbGUKLS0tIGEvZmlsZQorKysgYi9maWxlCkBAIC02
LDE3ICs2LDE2IEBACiAJCWVjaG8gImxpbmUgMiI7CiAJCWVjaG8gImxpbmUgMyI7CiAJCWVjaG8g
ImxpbmUgNCI7CiAJCWVjaG8gImxpbmUgNSI7CiAJfQogCQogCXB1YmxpYyBmdW5jdGlvbiBmdW5j
QkNEKCkgewogCQllY2hvICJsaW5lIDEtMSI7CiAJCWVjaG8gImxpbmUgMi0xIjsKIAkJZWNobyAi
bGluZSAzLTEiOwogCQllY2hvICJsaW5lIDQtMSI7CiAJCWVjaG8gImxpbmUgNS0xIjsKLQl9CiB9
CiAKID8+ClwgTm8gbmV3bGluZSBhdCBlbmQgb2YgZmlsZQo=
> From: <4jxDQ6FQee2H@dyweni.com>
> To: spearce@spearce.org
> Cc: git@vger.kernel.org
> Subject: Bug in Git-Gui - Creates corrupt patch
> Date: Wed, 25 Feb 2009 09:03:22 -0600
> Reply-To: 4jxDQ6FQee2H@dyweni.com
> Sender: git-owner@vger.kernel.org
> X-Mailer: Claws Mail 3.4.0 (GTK+ 2.12.11; i686-pc-linux-gnu)
>
> Hi Shawn,
>
> I have stumbled upon a bug in Git-GUi and am providing reproduction
> steps:
>
>
>
> 1. Commit this file into a new git repository:
>
> -----------------------------
> <?php
>
> class myclass {
> public function funcAbc() {
> echo "line 1";
> echo "line 2";
> echo "line 3";
> echo "line 4";
> echo "line 5";
> }
>
> public function funcBCD() {
> echo "line 1-1";
> echo "line 2-1";
> echo "line 3-1";
> echo "line 4-1";
> echo "line 5-1";
> }
> }
>
> ?>
> --------------
>
> Here is the base64 encoded version:
>
> PD9waHAKCmNsYXNzIG15Y2xhc3MgewoJcHVibGljIGZ1bmN0aW9uIGZ1bmNBYmMoKSB7CgkJZWNo
> byAibGluZSAxIjsKCQllY2hvICJsaW5lIDIiOwoJCWVjaG8gImxpbmUgMyI7CgkJZWNobyAibGlu
> ZSA0IjsKCQllY2hvICJsaW5lIDUiOwoJfQoJCglwdWJsaWMgZnVuY3Rpb24gZnVuY0JDRCgpIHsK
> CQllY2hvICJsaW5lIDEtMSI7CgkJZWNobyAibGluZSAyLTEiOwoJCWVjaG8gImxpbmUgMy0xIjsK
> CQllY2hvICJsaW5lIDQtMSI7CgkJZWNobyAibGluZSA1LTEiOwoJfQp9Cgo/Pg==
>
>
>
>
> 2. Now delete the last function in the class. Here's the resulting
> file, it is not staged or commited yet.
>
> ----------------------------
> <?php
>
> class myclass {
> public function funcAbc() {
> echo "line 1";
> echo "line 2";
> echo "line 3";
> echo "line 4";
> echo "line 5";
> }
> }
>
> ?>
> ----------------------------
>
>
> Here is the base64 encoded version:
>
> PD9waHAKCmNsYXNzIG15Y2xhc3MgewoJcHVibGljIGZ1bmN0aW9uIGZ1bmNBYmMoKSB7CgkJZWNo
> byAibGluZSAxIjsKCQllY2hvICJsaW5lIDIiOwoJCWVjaG8gImxpbmUgMyI7CgkJZWNobyAibGlu
> ZSA0IjsKCQllY2hvICJsaW5lIDUiOwoJfQp9Cgo/Pg==
>
>
>
>
> 3. Using git-gui, try to stage *only* the last line marked for removal
> (should be '- }').
>
> I get 'fatal: corrupt patch at line 22'.
>
>
>
>
> 4. Now try the same task using git-add -p. Start 'git-add -p'.
> Enter edit mode (e). Remove all the '-' lines except the last one
> (make them ' ') so that only the last '-' will be removed. Save and
> exit.
>
> On my system the patch is committed.
>
>
>
>
>
> I'm running git version 1.6.0.6, 32bit linux, Gentoo OS
>
>
>
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Bug in Git-Gui - Creates corrupt patch
2009-02-25 15:03 Bug in Git-Gui - Creates corrupt patch 4jxDQ6FQee2H
2009-02-25 15:26 ` 4jxDQ6FQee2H
@ 2009-02-25 15:46 ` Johannes Sixt
2009-02-25 16:10 ` 4jxDQ6FQee2H
2009-03-02 14:34 ` Grzegorz Kossakowski
1 sibling, 2 replies; 7+ messages in thread
From: Johannes Sixt @ 2009-02-25 15:46 UTC (permalink / raw)
To: 4jxDQ6FQee2H; +Cc: spearce, git
4jxDQ6FQee2H@dyweni.com schrieb:
> 3. Using git-gui, try to stage *only* the last line marked for removal
> (should be '- }').
>
> I get 'fatal: corrupt patch at line 22'.
"Stage/Unstage line" does not work for files that have
\ No newline at end of file
-- Hannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug in Git-Gui - Creates corrupt patch
2009-02-25 15:46 ` Johannes Sixt
@ 2009-02-25 16:10 ` 4jxDQ6FQee2H
2009-02-25 16:24 ` 4jxDQ6FQee2H
2009-03-02 14:34 ` Grzegorz Kossakowski
1 sibling, 1 reply; 7+ messages in thread
From: 4jxDQ6FQee2H @ 2009-02-25 16:10 UTC (permalink / raw)
To: Johannes Sixt; +Cc: git, spearce
Hannes / List,
Thank you for the advise on "\ No newline at end of file".
I have almost 4,000 files that are formatted with "\ No newline at end
of file". Does anyone know of an easy way to re-format my files so
that they have a newline at the end?
The files in question are PHP files that are dynamically included, so I
want to prevent arbitrary spaces from showing up in the rendered pages.
I'm running Linux. A bash or perl script would be preferable, but
anything will suffice.
Thanks!
> Johannes Sixt <j.sixt@viscovery.net> wrote:
>
> 4jxDQ6FQee2H@dyweni.com schrieb:
> > 3. Using git-gui, try to stage *only* the last line marked for
> > removal (should be '- }').
> >
> > I get 'fatal: corrupt patch at line 22'.
>
> "Stage/Unstage line" does not work for files that have
>
> \ No newline at end of file
>
> -- Hannes
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug in Git-Gui - Creates corrupt patch
2009-02-25 16:10 ` 4jxDQ6FQee2H
@ 2009-02-25 16:24 ` 4jxDQ6FQee2H
0 siblings, 0 replies; 7+ messages in thread
From: 4jxDQ6FQee2H @ 2009-02-25 16:24 UTC (permalink / raw)
To: git; +Cc: Johannes Sixt, spearce
In case anyone else is facing this same situation, a simple script like
this did the trick for me:
------------------------------------------------
#!/bin/bash
find ./ -type f | grep -v .git | while read filename
do
last=$(
tail -c 1 "$filename" |
od -x |
head -n 1 |
awk '{ print $2 }'
)
if [ "x$last" != "x000a" ]
then
echo >> "$filename"
fi
done
------------------------------------------------
> <4jxDQ6FQee2H@dyweni.com> wrote:
>
> Hannes / List,
>
> Thank you for the advise on "\ No newline at end of file".
>
> I have almost 4,000 files that are formatted with "\ No newline at end
> of file". Does anyone know of an easy way to re-format my files so
> that they have a newline at the end?
>
> The files in question are PHP files that are dynamically included, so
> I want to prevent arbitrary spaces from showing up in the rendered
> pages.
>
> I'm running Linux. A bash or perl script would be preferable, but
> anything will suffice.
>
> Thanks!
>
>
> > Johannes Sixt <j.sixt@viscovery.net> wrote:
> >
> > 4jxDQ6FQee2H@dyweni.com schrieb:
> > > 3. Using git-gui, try to stage *only* the last line marked for
> > > removal (should be '- }').
> > >
> > > I get 'fatal: corrupt patch at line 22'.
> >
> > "Stage/Unstage line" does not work for files that have
> >
> > \ No newline at end of file
> >
> > -- Hannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug in Git-Gui - Creates corrupt patch
2009-02-25 15:46 ` Johannes Sixt
2009-02-25 16:10 ` 4jxDQ6FQee2H
@ 2009-03-02 14:34 ` Grzegorz Kossakowski
2009-03-02 14:39 ` Johannes Sixt
1 sibling, 1 reply; 7+ messages in thread
From: Grzegorz Kossakowski @ 2009-03-02 14:34 UTC (permalink / raw)
To: Johannes Sixt; +Cc: 4jxDQ6FQee2H, spearce, git
Johannes Sixt pisze:
> 4jxDQ6FQee2H@dyweni.com schrieb:
>> 3. Using git-gui, try to stage *only* the last line marked for removal
>> (should be '- }').
>>
>> I get 'fatal: corrupt patch at line 22'.
>
> "Stage/Unstage line" does not work for files that have
>
> \ No newline at end of file
I've just stumpled across this problem. Does above imply that reported problem is not considered as a bug?
If so I believe that git gui should enforce new lines at the end of a file or at least provide more meaningful error msg.
--
Best regards,
Grzegorz Kossakowski
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Bug in Git-Gui - Creates corrupt patch
2009-03-02 14:34 ` Grzegorz Kossakowski
@ 2009-03-02 14:39 ` Johannes Sixt
0 siblings, 0 replies; 7+ messages in thread
From: Johannes Sixt @ 2009-03-02 14:39 UTC (permalink / raw)
To: Grzegorz Kossakowski; +Cc: 4jxDQ6FQee2H, spearce, git
Grzegorz Kossakowski schrieb:
> Johannes Sixt pisze:
>> 4jxDQ6FQee2H@dyweni.com schrieb:
>>> 3. Using git-gui, try to stage *only* the last line marked for removal
>>> (should be '- }').
>>>
>>> I get 'fatal: corrupt patch at line 22'.
>> "Stage/Unstage line" does not work for files that have
>>
>> \ No newline at end of file
>
> I've just stumpled across this problem. Does above imply that reported problem is not considered as a bug?
No, it means that I was too lazy to implement it. I tried to do that after
this report came in, but gave up because it is not trivial and I have too
little time to think it through. :-(
-- Hannes
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-03-02 14:41 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-25 15:03 Bug in Git-Gui - Creates corrupt patch 4jxDQ6FQee2H
2009-02-25 15:26 ` 4jxDQ6FQee2H
2009-02-25 15:46 ` Johannes Sixt
2009-02-25 16:10 ` 4jxDQ6FQee2H
2009-02-25 16:24 ` 4jxDQ6FQee2H
2009-03-02 14:34 ` Grzegorz Kossakowski
2009-03-02 14:39 ` Johannes Sixt
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 NNTP newsgroup(s).