{"thread":{"id":"2414","subject":"Problems with binary patches (pull) and spaces in filenames (gitk)","startedAt":"2005-11-09T21:37:30Z","lastAt":"2005-11-09T23:33:00Z","messageCount":6,"participants":["Peter Eriksen","Junio C Hamano","Linus Torvalds","Jan Harkes"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"11407","messageId":"20051109213730.GA23052@ebar091.ebar.dtu.dk","threadId":"2414","inReplyTo":null,"subject":"Problems with binary patches (pull) and spaces in filenames (gitk)","fromName":"Peter Eriksen","fromEmail":"s022018@student.dtu.dk","sentAt":"2005-11-09T21:37:30Z","receivedAt":"2005-11-09T21:37:30Z","isPatch":false,"sender":{"key":"s022018@student.dtu.dk","avatar":null},"body":"Hello,\n\nI've got a nice project, where I am tracking both binary files and\nfilenames with spaces.  So, I've noticed two small cosmetic bugs:\n\n1) When pulling an updated binary files, I guess it still tries to \n   print this update summary by making and processing patches, and so\n   gives this error:\n\n       Updating from ab1c4033ba98c043e13da3446e7f244ac7f79942 to\n       c164231f6b59fd80171e95f31d762a80d884c708.\n       Fast forward\n       fatal: patch with only garbage at line 3249\n\n2) When there are spaces in filenames, gitk only shows the first part of\n   the name in the filelist at the buttom right.\n\n\nRegards,\n\nPeter\n"},{"id":"11412","messageId":"7vfyq5bhi2.fsf@assigned-by-dhcp.cox.net","threadId":"2414","inReplyTo":"20051109213730.GA23052@ebar091.ebar.dtu.dk","subject":"Re: Problems with binary patches (pull) and spaces in filenames (gitk)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-09T22:09:41Z","receivedAt":"2005-11-09T22:09:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Peter Eriksen\" <s022018@student.dtu.dk> writes:\n\n> 1) When pulling an updated binary files, I guess it still tries to \n>    print this update summary by making and processing patches, and so\n>    gives this error:\n>\n>        Updating from ab1c4033ba98c043e13da3446e7f244ac7f79942 to\n>        c164231f6b59fd80171e95f31d762a80d884c708.\n>        Fast forward\n>        fatal: patch with only garbage at line 3249\n\nHmm.  Perhaps a suboption to git-apply --stat to tell it not to\nbarf is helpful?  In the meantime, could you pull with -n flag?\n\n> 2) When there are spaces in filenames, gitk only shows the first part of\n>    the name in the filelist at the buttom right.\n\nAnother minor gitk gripe I have is that it does not look at\nsubdirectories of refs/{heads,tags}/ so I do not get labels to\nmy topic branch heads.\n"},{"id":"11413","messageId":"Pine.LNX.4.64.0511091404000.4627@g5.osdl.org","threadId":"2414","inReplyTo":"20051109213730.GA23052@ebar091.ebar.dtu.dk","subject":"Re: Problems with binary patches (pull) and spaces in filenames (gitk)","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-11-09T22:10:19Z","receivedAt":"2005-11-09T22:10:19Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 9 Nov 2005, Peter Eriksen wrote:\n> \n> 1) When pulling an updated binary files, I guess it still tries to \n>    print this update summary by making and processing patches, and so\n>    gives this error:\n> \n>        Updating from ab1c4033ba98c043e13da3446e7f244ac7f79942 to\n>        c164231f6b59fd80171e95f31d762a80d884c708.\n>        Fast forward\n>        fatal: patch with only garbage at line 3249\n\nYes, this is \"git-apply --stat\" being unhappy about an empty patch.\n\nMaybe we should only be unhappy when actually trying to apply (or check) \nthe patch.\n\nSo a patch like the appended may or may not be the right solution.\n\n> 2) When there are spaces in filenames, gitk only shows the first part of\n>    the name in the filelist at the buttom right.\n\nCan't help you there, that's more tcl/tk than I know. Paul?\n\n\t\tLinus\n\n---\ndiff --git a/apply.c b/apply.c\nindex 3e53b34..da1416a 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -890,7 +890,7 @@ static int parse_chunk(char *buffer, uns\n \n \tpatchsize = parse_single_patch(buffer + offset + hdrsize, size - offset - hdrsize, patch);\n \n-\tif (!patchsize && !metadata_changes(patch))\n+\tif ((check ||apply) && !patchsize && !metadata_changes(patch))\n \t\tdie(\"patch with only garbage at line %d\", linenr);\n \n \treturn offset + hdrsize + patchsize;\n"},{"id":"11418","messageId":"7v8xvxbg9y.fsf@assigned-by-dhcp.cox.net","threadId":"2414","inReplyTo":"7vfyq5bhi2.fsf@assigned-by-dhcp.cox.net","subject":"Re: Problems with binary patches (pull) and spaces in filenames (gitk)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-09T22:36:09Z","receivedAt":"2005-11-09T22:36:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Hmm.  Perhaps a suboption to git-apply --stat to tell it not to\n> barf is helpful?  In the meantime, could you pull with -n flag?\n\nWould this help?\n\n-- >8 -- cut here -- >8 --\n[PATCH] git-apply: do not barf on binary diff when not applying.\n\nInstead, just mark the patch as binary, and keep going when\ndoing --stat and --summary.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\ndiff --git a/apply.c b/apply.c\nindex 3e53b34..6d756f7 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -53,7 +53,7 @@ struct fragment {\n struct patch {\n \tchar *new_name, *old_name, *def_name;\n \tunsigned int old_mode, new_mode;\n-\tint is_rename, is_copy, is_new, is_delete;\n+\tint is_rename, is_copy, is_new, is_delete, is_binary;\n \tint lines_added, lines_deleted;\n \tint score;\n \tstruct fragment *fragments;\n@@ -890,8 +890,18 @@ static int parse_chunk(char *buffer, uns\n \n \tpatchsize = parse_single_patch(buffer + offset + hdrsize, size - offset - hdrsize, patch);\n \n-\tif (!patchsize && !metadata_changes(patch))\n-\t\tdie(\"patch with only garbage at line %d\", linenr);\n+\tif (!patchsize && !metadata_changes(patch)) {\n+\t\tstatic const char binhdr[] = \"Binary files \";\n+\n+\t\tif (sizeof(binhdr) - 1 < size - offset - hdrsize &&\n+\t\t    !memcmp(binhdr, buffer + hdrsize, sizeof(binhdr)-1))\n+\t\t\tpatch->is_binary = 1;\n+\n+\t\tif (patch->is_binary && !apply)\n+\t\t\t;\n+\t\telse\n+\t\t\tdie(\"patch with only garbage at line %d\", linenr);\n+\t}\n \n \treturn offset + hdrsize + patchsize;\n }\n@@ -949,9 +959,12 @@ static void show_stats(struct patch *pat\n \t\tadd = (add * max + max_change / 2) / max_change;\n \t\tdel = total - add;\n \t}\n-\tprintf(\" %s%-*s |%5d %.*s%.*s\\n\", prefix,\n-\t\tlen, name, patch->lines_added + patch->lines_deleted,\n-\t\tadd, pluses, del, minuses);\n+\tif (patch->is_binary)\n+\t\tprintf(\" %s%-*s |  Bin\\n\", prefix, len, name);\n+\telse\n+\t\tprintf(\" %s%-*s |%5d %.*s%.*s\\n\", prefix,\n+\t\t       len, name, patch->lines_added + patch->lines_deleted,\n+\t\t       add, pluses, del, minuses);\n \tif (qname)\n \t\tfree(qname);\n }\n"},{"id":"11421","messageId":"20051109230048.GH31850@delft.aura.cs.cmu.edu","threadId":"2414","inReplyTo":"7vfyq5bhi2.fsf@assigned-by-dhcp.cox.net","subject":"Re: Problems with binary patches (pull) and spaces in filenames (gitk)","fromName":"Jan Harkes","fromEmail":"jaharkes@cs.cmu.edu","sentAt":"2005-11-09T23:00:48Z","receivedAt":"2005-11-09T23:00:48Z","isPatch":false,"sender":{"key":"jaharkes@cs.cmu.edu","avatar":"https://gravatar.com/avatar/cf95aecd150ca8ef33d6edc337ac4bb9e13aa4246fc3679257d578c7fddc1633?d=mp&s=160"},"body":"On Wed, Nov 09, 2005 at 02:09:41PM -0800, Junio C Hamano wrote:\n> Another minor gitk gripe I have is that it does not look at\n> subdirectories of refs/{heads,tags}/ so I do not get labels to\n> my topic branch heads.\n\nI've been using the following gitk 'customization'. ISTR that it can be\ncleaned up a bit further and do everything in a single scan of the refs/\nsubtree. I'll take another look at that tonight.\n\nJan\n\ndiff --git a/gitk b/gitk\nindex a9d37d9..cd0b84f 100755\n--- a/gitk\n+++ b/gitk\n@@ -237,16 +237,27 @@ proc parsecommit {id contents listed old\n \t\t\t     $comname $comdate $comment]\n }\n \n+# recursively list all files in a directory\n+proc listTree {root} {\n+    set files [glob -nocomplain -directory $root -types f *]\n+    set nodes [glob -nocomplain -directory $root -types d *]\n+    foreach node $nodes {\n+\tset children [listTree $node]\n+\tset files [concat $files $children]\n+    }\n+    return $files\n+}\n+\n proc readrefs {} {\n     global tagids idtags headids idheads tagcontents\n \n-    set tags [glob -nocomplain -types f [gitdir]/refs/tags/*]\n+    set tags [listTree [gitdir]/refs/tags]\n     foreach f $tags {\n \tcatch {\n \t    set fd [open $f r]\n \t    set line [read $fd]\n \t    if {[regexp {^[0-9a-f]{40}} $line id]} {\n-\t\tset direct [file tail $f]\n+\t\tregexp {[gitdir]/refs/tags/(.*)} $f match direct\n \t\tset tagids($direct) $id\n \t\tlappend idtags($id) $direct\n \t\tset tagblob [exec git-cat-file tag $id]\n@@ -271,13 +282,13 @@ proc readrefs {} {\n \t    close $fd\n \t}\n     }\n-    set heads [glob -nocomplain -types f [gitdir]/refs/heads/*]\n+    set heads [listTree [gitdir]/refs/heads]\n     foreach f $heads {\n \tcatch {\n \t    set fd [open $f r]\n \t    set line [read $fd 40]\n \t    if {[regexp {^[0-9a-f]{40}} $line id]} {\n-\t\tset head [file tail $f]\n+\t\tregexp {[gitdir]/refs/heads/(.*)} $f match head\n \t\tset headids($head) $line\n \t\tlappend idheads($line) $head\n \t    }\n"},{"id":"11438","messageId":"20051109233300.GA23244@ebar091.ebar.dtu.dk","threadId":"2414","inReplyTo":"7v8xvxbg9y.fsf@assigned-by-dhcp.cox.net","subject":"Re: Problems with binary patches (pull) and spaces in filenames (gitk)","fromName":"Peter Eriksen","fromEmail":"s022018@student.dtu.dk","sentAt":"2005-11-09T23:33:00Z","receivedAt":"2005-11-09T23:33:00Z","isPatch":false,"sender":{"key":"s022018@student.dtu.dk","avatar":null},"body":"On Wed, Nov 09, 2005 at 02:36:09PM -0800, Junio C Hamano wrote:\n> Junio C Hamano <junkio@cox.net> writes:\n> \n> > Hmm.  Perhaps a suboption to git-apply --stat to tell it not to\n> > barf is helpful?  In the meantime, could you pull with -n flag?\n> \n> Would this help?\n> \n> -- >8 -- cut here -- >8 --\n> [PATCH] git-apply: do not barf on binary diff when not applying.\n\nYes, it seems to work.  With my example it now shows the diff stats and\nputs a \"Bin\" instead of the number of line changed.  It could show the\nchange in the size, but as it is, it's fine with me.  Please apply.\n\nPeter\n"}]}