{"thread":{"id":"32","subject":"[patch pasky 1/2] fix various issues in gitapply.sh (basically did not handle add/del/cm at all)","startedAt":"2005-04-15T09:28:38Z","lastAt":"2005-04-15T20:30:11Z","messageCount":4,"participants":["Martin Schlemmer","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"197","messageId":"1113557318.23299.165.camel@nosferatu.lan","threadId":"32","inReplyTo":null,"subject":"[patch pasky 1/2] fix various issues in gitapply.sh (basically did not handle add/del/cm at all)","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-15T09:28:38Z","receivedAt":"2005-04-15T09:28:38Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"Hi,\n\nThe egrep regex should not escape the '{' and '}', and also add a check\nfor ' \\t' so that we do not pickup stuff like '+----', etc.  Fix typo in\nassignment.  Check if file exists in new tree before adding/removing\n(might add support for this lowlevel to increase speed?).  Fix typo in\nline removing temp files.\n\nSigned-off-by: Martin Schlemmer <azarah@gentoo.org>\n\ngitapply.sh:  47b9346d2679b1bf34220fe4502f15c7d0737b0c\n--- 47b9346d2679b1bf34220fe4502f15c7d0737b0c/gitapply.sh\n+++ uncommitted/gitapply.sh\n@@ -19,15 +19,22 @@\n # just handle it all ourselves.\n patch -p1 -N <$patchfifo &\n\n-tee $patchfifo | egrep '^[+-]\\{3\\}' | {\n+exits_in_cache() {\n+       for x in $(ls-tree \"$1\"); do\n+               [ \"$x\" = \"$2\" ] && return 0\n+       done\n+       return 1\n+}\n+\n+tee $patchfifo | egrep '^[+-]{3}[ \\t]' | {\n        victim=\n        origmode=\n\n        while read sign file attrs; do\n-               echo $sign $file $attrs ... >&2\n+#              echo $sign $file $attrs ... >&2\n                case $sign in\n                \"---\")\n-                       victim=file\n+                       victim=$file\n                        mode=$(echo $attrs | sed 's/.*mode:[0-7]*\\([0-7]\\{3\\}\\).*/\\1/')\n                        origmode=\n                        [ \"$mode\" != \"$attrs\" ] && origmode=$mode\n@@ -35,14 +42,19 @@\n                \"+++\")\n                        if [ \"$file\" = \"/dev/null\" ]; then\n                                torm=$(echo \"$victim\" | sed 's/[^\\/]*\\///') #-p1\n-                               echo -ne \"rm\\0$torm\\0\"\n+                               tree=$(echo $attrs | sed 's/.*tree:\\([0-9a-f]\\{40\\}\\).*/\\1/')\n+                               exits_in_cache \"$tree\" \"$torm\" && echo -ne \"rm\\0$torm\\0\"\n                                continue\n                        elif [ \"$victim\" = \"/dev/null\" ]; then\n-                               echo -ne \"add\\0$file\\0\"\n+                               toadd=$(echo \"$file\" | sed 's/[^\\/]*\\///') #-p1\n+                               tree=$(echo \"$file\" | sed -e 's/\\([^\\/]*\\)\\/.*/\\1/')\n+                               exits_in_cache \"$tree\" \"$toadd\" || echo -ne \"add\\0$toadd\\0\"\n                        fi\n                        mode=$(echo $attrs | sed 's/.*mode:[0-7]*\\([0-7]\\{3\\}\\).*/\\1/')\n                        if [ \"$mode\" ] && [ \"$mode\" != \"$attrs\" ] && [ \"$origmode\" != \"$mode\" ]; then\n-                               echo -ne \"cm\\0$mode\\0$file\\0\"\n+                               tochmod=$(echo \"$file\" | sed 's/[^\\/]*\\///') #-p1\n+                               # need a space else numbers gets converted\n+                               echo -ne \"cm\\0 $mode\\0$tochmod\\0\"\n                        fi\n                        ;;\n                *)\n@@ -74,4 +86,4 @@\n done\n ' padding\n\n-rm $pathfifo $todo $gonefile\n+rm $patchfifo $todo $gonefile\n\n\n-- \nMartin Schlemmer\n\n\n\ngitapply.sh:  47b9346d2679b1bf34220fe4502f15c7d0737b0c\n--- 47b9346d2679b1bf34220fe4502f15c7d0737b0c/gitapply.sh\n+++ uncommitted/gitapply.sh\n@@ -19,15 +19,22 @@\n # just handle it all ourselves.\n patch -p1 -N <$patchfifo &\n \n-tee $patchfifo | egrep '^[+-]\\{3\\}' | {\n+exits_in_cache() {\n+\tfor x in $(ls-tree \"$1\"); do\n+\t\t[ \"$x\" = \"$2\" ] && return 0\n+\tdone\n+\treturn 1\n+}\n+\n+tee $patchfifo | egrep '^[+-]{3}[ \\t]' | {\n \tvictim=\n \torigmode=\n \n \twhile read sign file attrs; do\n-\t\techo $sign $file $attrs ... >&2\n+#\t\techo $sign $file $attrs ... >&2\n \t\tcase $sign in\n \t\t\"---\")\n-\t\t\tvictim=file\n+\t\t\tvictim=$file\n \t\t\tmode=$(echo $attrs | sed 's/.*mode:[0-7]*\\([0-7]\\{3\\}\\).*/\\1/')\n \t\t\torigmode=\n \t\t\t[ \"$mode\" != \"$attrs\" ] && origmode=$mode\n@@ -35,14 +42,19 @@\n \t\t\"+++\")\n \t\t\tif [ \"$file\" = \"/dev/null\" ]; then\n \t\t\t\ttorm=$(echo \"$victim\" | sed 's/[^\\/]*\\///') #-p1\n-\t\t\t\techo -ne \"rm\\0$torm\\0\"\n+\t\t\t\ttree=$(echo $attrs | sed 's/.*tree:\\([0-9a-f]\\{40\\}\\).*/\\1/')\n+\t\t\t\texits_in_cache \"$tree\" \"$torm\" && echo -ne \"rm\\0$torm\\0\"\n \t\t\t\tcontinue\n \t\t\telif [ \"$victim\" = \"/dev/null\" ]; then\n-\t\t\t\techo -ne \"add\\0$file\\0\"\n+\t\t\t\ttoadd=$(echo \"$file\" | sed 's/[^\\/]*\\///') #-p1\n+\t\t\t\ttree=$(echo \"$file\" | sed -e 's/\\([^\\/]*\\)\\/.*/\\1/')\n+\t\t\t\texits_in_cache \"$tree\" \"$toadd\" || echo -ne \"add\\0$toadd\\0\"\n \t\t\tfi\n \t\t\tmode=$(echo $attrs | sed 's/.*mode:[0-7]*\\([0-7]\\{3\\}\\).*/\\1/')\n \t\t\tif [ \"$mode\" ] && [ \"$mode\" != \"$attrs\" ] && [ \"$origmode\" != \"$mode\" ]; then\n-\t\t\t\techo -ne \"cm\\0$mode\\0$file\\0\"\n+\t\t\t\ttochmod=$(echo \"$file\" | sed 's/[^\\/]*\\///') #-p1\n+\t\t\t\t# need a space else numbers gets converted\n+\t\t\t\techo -ne \"cm\\0 $mode\\0$tochmod\\0\"\n \t\t\tfi\n \t\t\t;;\n \t\t*)\n@@ -74,4 +86,4 @@\n done\n ' padding\n \n-rm $pathfifo $todo $gonefile\n+rm $patchfifo $todo $gonefile\n"},{"id":"198","messageId":"1113557498.23299.167.camel@nosferatu.lan","threadId":"32","inReplyTo":"1113557318.23299.165.camel@nosferatu.lan","subject":"Re: [patch pasky 1/2] fix various issues in gitapply.sh (basically did not handle add/del/cm at all)","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-15T09:31:38Z","receivedAt":"2005-04-15T09:31:38Z","isPatch":true,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"PS: forget the '1/2' in the topic, i did it slightly different which\nrequired changes to gettrack.sh, etc, but to got getmerge.sh, and saw my\nshort sightedness.\n\nOn Fri, 2005-04-15 at 11:28 +0200, Martin Schlemmer wrote:\n> Hi,\n> \n> The egrep regex should not escape the '{' and '}', and also add a check\n> for ' \\t' so that we do not pickup stuff like '+----', etc.  Fix typo in\n> assignment.  Check if file exists in new tree before adding/removing\n> (might add support for this lowlevel to increase speed?).  Fix typo in\n> line removing temp files.\n> \n> Signed-off-by: Martin Schlemmer <azarah@gentoo.org>\n> \n> gitapply.sh:  47b9346d2679b1bf34220fe4502f15c7d0737b0c\n> --- 47b9346d2679b1bf34220fe4502f15c7d0737b0c/gitapply.sh\n> +++ uncommitted/gitapply.sh\n> @@ -19,15 +19,22 @@\n>  # just handle it all ourselves.\n>  patch -p1 -N <$patchfifo &\n> \n> -tee $patchfifo | egrep '^[+-]\\{3\\}' | {\n> +exits_in_cache() {\n> +       for x in $(ls-tree \"$1\"); do\n> +               [ \"$x\" = \"$2\" ] && return 0\n> +       done\n> +       return 1\n> +}\n> +\n> +tee $patchfifo | egrep '^[+-]{3}[ \\t]' | {\n>         victim=\n>         origmode=\n> \n>         while read sign file attrs; do\n> -               echo $sign $file $attrs ... >&2\n> +#              echo $sign $file $attrs ... >&2\n>                 case $sign in\n>                 \"---\")\n> -                       victim=file\n> +                       victim=$file\n>                         mode=$(echo $attrs | sed 's/.*mode:[0-7]*\\([0-7]\\{3\\}\\).*/\\1/')\n>                         origmode=\n>                         [ \"$mode\" != \"$attrs\" ] && origmode=$mode\n> @@ -35,14 +42,19 @@\n>                 \"+++\")\n>                         if [ \"$file\" = \"/dev/null\" ]; then\n>                                 torm=$(echo \"$victim\" | sed 's/[^\\/]*\\///') #-p1\n> -                               echo -ne \"rm\\0$torm\\0\"\n> +                               tree=$(echo $attrs | sed 's/.*tree:\\([0-9a-f]\\{40\\}\\).*/\\1/')\n> +                               exits_in_cache \"$tree\" \"$torm\" && echo -ne \"rm\\0$torm\\0\"\n>                                 continue\n>                         elif [ \"$victim\" = \"/dev/null\" ]; then\n> -                               echo -ne \"add\\0$file\\0\"\n> +                               toadd=$(echo \"$file\" | sed 's/[^\\/]*\\///') #-p1\n> +                               tree=$(echo \"$file\" | sed -e 's/\\([^\\/]*\\)\\/.*/\\1/')\n> +                               exits_in_cache \"$tree\" \"$toadd\" || echo -ne \"add\\0$toadd\\0\"\n>                         fi\n>                         mode=$(echo $attrs | sed 's/.*mode:[0-7]*\\([0-7]\\{3\\}\\).*/\\1/')\n>                         if [ \"$mode\" ] && [ \"$mode\" != \"$attrs\" ] && [ \"$origmode\" != \"$mode\" ]; then\n> -                               echo -ne \"cm\\0$mode\\0$file\\0\"\n> +                               tochmod=$(echo \"$file\" | sed 's/[^\\/]*\\///') #-p1\n> +                               # need a space else numbers gets converted\n> +                               echo -ne \"cm\\0 $mode\\0$tochmod\\0\"\n>                         fi\n>                         ;;\n>                 *)\n> @@ -74,4 +86,4 @@\n>  done\n>  ' padding\n> \n> -rm $pathfifo $todo $gonefile\n> +rm $patchfifo $todo $gonefile\n> \n> \n-- \nMartin Schlemmer\n\n"},{"id":"227","messageId":"20050415181526.GA7417@pasky.ji.cz","threadId":"32","inReplyTo":"1113557318.23299.165.camel@nosferatu.lan","subject":"Re: fix various issues in gitapply.sh (basically did not handle add/del/cm at all)","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-15T18:15:26Z","receivedAt":"2005-04-15T18:15:26Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Apr 15, 2005 at 11:28:38AM CEST, I got a letter\nwhere Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> Hi,\n> \n> The egrep regex should not escape the '{' and '}', and also add a check\n> for ' \\t' so that we do not pickup stuff like '+----', etc.  Fix typo in\n> assignment.  Check if file exists in new tree before adding/removing\n> (might add support for this lowlevel to increase speed?).  Fix typo in\n> line removing temp files.\n> \n> Signed-off-by: Martin Schlemmer <azarah@gentoo.org>\n\nThanks for the merge and typo fixes. I can't imagine how, but it really\nappeared to work for me that time!\n\nI'm confused however what does the exits_in_cache() (what exits? exists?)\ngives us, apart of horribly-looking code. What bug does it fix?\n\nThanks,\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"244","messageId":"1113597012.8582.10.camel@nosferatu.lan","threadId":"32","inReplyTo":"20050415181526.GA7417@pasky.ji.cz","subject":"Re: fix various issues in gitapply.sh (basically did not handle add/del/cm at all)","fromName":"Martin Schlemmer","fromEmail":"azarah@nosferatu.za.org","sentAt":"2005-04-15T20:30:11Z","receivedAt":"2005-04-15T20:30:11Z","isPatch":false,"sender":{"key":"azarah@nosferatu.za.org","avatar":null},"body":"On Fri, 2005-04-15 at 20:15 +0200, Petr Baudis wrote:\n> Dear diary, on Fri, Apr 15, 2005 at 11:28:38AM CEST, I got a letter\n> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...\n> > Hi,\n> > \n> > The egrep regex should not escape the '{' and '}', and also add a check\n> > for ' \\t' so that we do not pickup stuff like '+----', etc.  Fix typo in\n> > assignment.  Check if file exists in new tree before adding/removing\n> > (might add support for this lowlevel to increase speed?).  Fix typo in\n> > line removing temp files.\n> > \n> > Signed-off-by: Martin Schlemmer <azarah@gentoo.org>\n> \n> Thanks for the merge and typo fixes. I can't imagine how, but it really\n> appeared to work for me that time!\n> \n> I'm confused however what does the exits_in_cache() (what exits? exists?)\n> gives us, apart of horribly-looking code. What bug does it fix?\n> \n\nMy typo it seems - should be exists.  Basically (especially for\ngittrack.sh) it will add all files changed between the trees to either\nthe add or remove queue if this is not done.  This is because it will\njust add (say git track linus; git track pasky) the git*.sh files that\nis missing in the linus tree (or gitrm.sh if in reverse) although they\nare already present there.  So we need to check if the file exists in\nthe destination tree before we git{add,rm}.sh it - if it do exists, then\nits ok to gitrm.sh it, if it does not, it is ok to gitadd.sh it.\n\nThe other problem is also that if you keep switching, it will add each\nfile multiple times to the add/rm queue.  This is a bug with\ngit{add,rm}.sh which do not check the queue if the file is already\nthere, and it also add a file even if it is already in the cache - so it\nprobably need the same type of fix.  I will send a patch when we get how\nwe check if a file is already in the cache resolved.\n\nLike I said in the patch, it might be better to add support low-level\nside (don't know if we can have ls-tree return true/false on file basis,\nelse add a new tool?).\n\n\nThanks,\n\n-- \nMartin Schlemmer\n\n"}]}