{"thread":{"id":"265","subject":"[PATCH] make file merging respect permissions","startedAt":"2005-04-23T18:22:50Z","lastAt":"2005-04-24T12:46:07Z","messageCount":14,"participants":["James Bottomley","Linus Torvalds","Petr Baudis","Andreas Gal"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1381","messageId":"1114280570.5068.5.camel@mulgrave","threadId":"265","inReplyTo":null,"subject":"[PATCH] make file merging respect permissions","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-23T18:22:50Z","receivedAt":"2005-04-23T18:22:50Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"I noticed when playing about with merging that executable scripts lose\ntheir permissions after a merge.  This was because unpack-file just\nunpacks to whatever the current umask is.\n\nI also noticed that the merge-one-file-script thinks that if the file\nhas been removed in both branches, then it should simply be removed.\nThis isn't correct.  The file could have been renamed to something\ndifferent in both branches, in which case we have an unflagged rename\nconflict.\n\nThe attached fixes both issues\n\nJames\n\n--- a/git-merge-one-file-script\n+++ b/git-merge-one-file-script\n@@ -20,23 +20,47 @@ mkdir -p \"$dir\"\n \n case \"${1:-.}${2:-.}${3:-.}\" in\n #\n-# deleted in both, or deleted in one and unchanged in the other\n+# deleted in both\n+#\n+\"$1..\")\n+\techo \"ERROR: $4 is removed in both branches\"\n+\techo \"ERROR: This is a potential rename conflict\"\n+\texit 1;;\n+#\n+# deleted in one and unchanged in the other\n #\n \"$1..\" | \"$1.$1\" | \"$1$1.\")\n \trm -f -- \"$4\"\n+\techo \"Removing $4\"\n \tupdate-cache --remove -- \"$4\"\n \texit 0\n \t;;\n \n #\n-# added in one, or added identically in both\n+# added in one\n #\n-\".$2.\" | \"..$3\" | \".$2$2\")\n-\tmv $(unpack-file \"${2:-$3}\") $4\n+\".$2.\" | \"..$3\" )\n+\techo \"Adding $4 with perm $6$7\"\n+\tmv $(unpack-file \"$2$3\") $4\n+\tchmod \"$6$7\" $4\n \tupdate-cache --add -- $4\n \texit 0\n \t;;\n-\n+#\n+# Added in both (check for same permissions)\n+#\n+\".$2$2\")\n+\tif [ \"$6\" != \"$7\" ]; then\n+\t\techo \"ERROR:\"\n+\t\techo \"ERROR: File $4 added in both branches, permissions conflict $6->$7\"\n+\t\techo \"ERROR:\"\n+\t\texit 1\n+\tfi\n+\techo \"Adding $4 with perm $6\"\n+\tmv $(unpack-file \"$2\") $4\n+\tchmod \"$6\" $4\n+\tupdate-cache --add -- $4\n+\texit 0;;\n #\n # Modified in both, but differently ;(\n #\n@@ -46,12 +70,21 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \tsrc1=$(unpack-file $2)\n \tsrc2=$(unpack-file $3)\n \tmerge \"$src2\" \"$orig\" \"$src1\"\n-\tif [ $? -ne 0 ]; then\n-\t\techo Leaving conflict merge in $src2\n+\tret=$?\n+\tif [ \"$6\" != \"$7\" ]; then\n+\t\techo \"ERROR: Permissions $5->$6->$7\" don't match merging $src2\"\n+\t\tif [ $ret -ne 0 ]; then\n+\t\t\techo \"ERROR: Leaving conflict merge in $src2\"\n+\t\tfi\n+\t\texit 1\n+\tfi\n+\tchmod -- \"$6\" \"$src2\"\n+\tif [ $ -ne 0 ]; then\n+\t\techo \"ERROR: Leaving conflict merge in $src2\"\n \t\texit 1\n \tfi\n-\tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n+\tcp -- \"$src2\" \"$4\" && chmod -- \"$6\" \"$4\" &&  update-cache --add -- \"$4\" && exit 0\n \t;;\n \n *)\n--- a/merge-cache.c\n+++ b/merge-cache.c\n@@ -4,7 +4,7 @@\n #include \"cache.h\"\n \n static const char *pgm = NULL;\n-static const char *arguments[5];\n+static const char *arguments[8];\n \n static void run_program(void)\n {\n@@ -18,6 +18,9 @@ static void run_program(void)\n \t\t\t    arguments[2],\n \t\t\t    arguments[3],\n \t\t\t    arguments[4],\n+\t\t\t    arguments[5],\n+\t\t\t    arguments[6],\n+\t\t\t    arguments[7],\n \t\t\t    NULL);\n \t\tdie(\"unable to execute '%s'\", pgm);\n \t}\n@@ -36,9 +39,13 @@ static int merge_entry(int pos, const ch\n \targuments[2] = \"\";\n \targuments[3] = \"\";\n \targuments[4] = path;\n+\targuments[5] = \"\";\n+\targuments[6] = \"\";\n+\targuments[7] = \"\";\n \tfound = 0;\n \tdo {\n \t\tstatic char hexbuf[4][60];\n+\t\tstatic char ownbuf[4][60];\n \t\tstruct cache_entry *ce = active_cache[pos];\n \t\tint stage = ce_stage(ce);\n \n@@ -46,7 +53,9 @@ static int merge_entry(int pos, const ch\n \t\t\tbreak;\n \t\tfound++;\n \t\tstrcpy(hexbuf[stage], sha1_to_hex(ce->sha1));\n+\t\tsprintf(ownbuf[stage], \"%o\", ntohl(ce->ce_mode) & (~S_IFMT));\n \t\targuments[stage] = hexbuf[stage];\n+\t\targuments[stage + 4] = ownbuf[stage];\n \t} while (++pos < active_nr);\n \tif (!found)\n \t\tdie(\"merge-cache: %s not in the cache\", path);\n\n\n"},{"id":"1407","messageId":"Pine.LNX.4.58.0504231311300.2344@ppc970.osdl.org","threadId":"265","inReplyTo":"1114280570.5068.5.camel@mulgrave","subject":"Re: [PATCH] make file merging respect permissions","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-23T20:17:11Z","receivedAt":"2005-04-23T20:17:11Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 23 Apr 2005, James Bottomley wrote:\n>\n> The attached fixes both issues\n\nThe attached patch was seriously corrupt. Did you edit it by hand? The \nsecond chunk of the git-merge-one-file-script patch claims to have 12 \nsource lines, but only has 11, causing patch no end of confusion.\n\nI fixed up the line counts by hand, and the end result looked almost sane,\nbut when looking closer, I noticed the\n\n\t+       if [ $ -ne 0 ]; then\n\t+               echo \"ERROR: Leaving conflict merge in $src2\"\n\t                exit 1\n\nwhich just can't be right either (\"$\" never equals 0, so the above will \nalways report an error), so I assume that whatever editing you did was \nreally quite corrupt. Yeah, yeah, you obviously meant \"$?\", but the fact \nis, your patch is bogus, and I don't trust it. Can you re-send a valid one \n(and sign off on it).\n\n\t\tLinus\n"},{"id":"1414","messageId":"1114288622.5228.1.camel@mulgrave","threadId":"265","inReplyTo":"Pine.LNX.4.58.0504231311300.2344@ppc970.osdl.org","subject":"Re: [PATCH] make file merging respect permissions","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-23T20:37:02Z","receivedAt":"2005-04-23T20:37:02Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"On Sat, 2005-04-23 at 13:17 -0700, Linus Torvalds wrote:\n> The attached patch was seriously corrupt. Did you edit it by hand? The \n> second chunk of the git-merge-one-file-script patch claims to have 12 \n> source lines, but only has 11, causing patch no end of confusion.\n\nOK ... yes I admit it ... the shame ... I noticed a problem after I\ngenerated it and then edited it in source\n\n> I fixed up the line counts by hand, and the end result looked almost sane,\n> but when looking closer, I noticed the\n> \n> \t+       if [ $ -ne 0 ]; then\n> \t+               echo \"ERROR: Leaving conflict merge in $src2\"\n> \t                exit 1\n> \n> which just can't be right either (\"$\" never equals 0, so the above will \n> always report an error), so I assume that whatever editing you did was \n> really quite corrupt. Yeah, yeah, you obviously meant \"$?\", but the fact \n> is, your patch is bogus, and I don't trust it. Can you re-send a valid one \n> (and sign off on it).\n\nYes boss ... Just getting on a 'plane now.  Should be able to send it\nout in an hour or so.\n\nJames\n\n\n"},{"id":"1422","messageId":"1114292680.4799.4.camel@mulgrave","threadId":"265","inReplyTo":"Pine.LNX.4.58.0504231311300.2344@ppc970.osdl.org","subject":"Re: [PATCH] make file merging respect permissions","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-23T21:44:40Z","receivedAt":"2005-04-23T21:44:40Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"On Sat, 2005-04-23 at 13:17 -0700, Linus Torvalds wrote:\n> Yeah, yeah, you obviously meant \"$?\", but the fact \n> is, your patch is bogus, and I don't trust it. Can you re-send a valid\n> one \n> (and sign off on it).]\n\nOK, here it is  .. I have an excuse, honest ... and a note from my mum.\n\n---\n\nThis patch fixes two problems\n\n1) permissions aren't respected in the merge script (primarily because\nthey're never passed in to it in the first place).  Fix that and also\ncheck for permission conflicts in the merge\n\n2) the delete of a file in both branches may indeed be just that, but it\ncould also be the indicator of a rename conflict (file moved to\ndifferent locations in both branches), so error out and ask the\ncommitter for guidance.\n\nSigned-off-by: James Bottomley <James.Bottomley@SteelEye.com>\n\n--- a/git-merge-one-file-script\n+++ b/git-merge-one-file-script\n@@ -20,23 +20,47 @@ mkdir -p \"$dir\"\n \n case \"${1:-.}${2:-.}${3:-.}\" in\n #\n-# deleted in both, or deleted in one and unchanged in the other\n+# deleted in both\n+#\n+\"$1..\")\n+\techo \"ERROR: $4 is removed in both branches\"\n+\techo \"ERROR: This is a potential rename conflict\"\n+\texit 1;;\n+#\n+# deleted in one and unchanged in the other\n #\n \"$1..\" | \"$1.$1\" | \"$1$1.\")\n \trm -f -- \"$4\"\n+\techo \"Removing $4\"\n \tupdate-cache --remove -- \"$4\"\n \texit 0\n \t;;\n \n #\n-# added in one, or added identically in both\n+# added in one\n #\n-\".$2.\" | \"..$3\" | \".$2$2\")\n-\tmv $(unpack-file \"${2:-$3}\") $4\n+\".$2.\" | \"..$3\" )\n+\techo \"Adding $4 with perm $6$7\"\n+\tmv $(unpack-file \"$2$3\") $4\n+\tchmod \"$6$7\" $4\n \tupdate-cache --add -- $4\n \texit 0\n \t;;\n-\n+#\n+# Added in both (check for same permissions)\n+#\n+\".$2$2\")\n+\tif [ \"$6\" != \"$7\" ]; then\n+\t\techo \"ERROR:\"\n+\t\techo \"ERROR: File $4 added in both branches, permissions conflict $6->$7\"\n+\t\techo \"ERROR:\"\n+\t\texit 1\n+\tfi\n+\techo \"Adding $4 with perm $6\"\n+\tmv $(unpack-file \"$2\") $4\n+\tchmod \"$6\" $4\n+\tupdate-cache --add -- $4\n+\texit 0;;\n #\n # Modified in both, but differently ;(\n #\n@@ -46,12 +70,21 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \tsrc1=$(unpack-file $2)\n \tsrc2=$(unpack-file $3)\n \tmerge \"$src2\" \"$orig\" \"$src1\"\n-\tif [ $? -ne 0 ]; then\n-\t\techo Leaving conflict merge in $src2\n+\tret=$?\n+\tif [ \"$6\" != \"$7\" ]; then\n+\t\techo \"ERROR: Permissions $5->$6->$7 don't match merging $src2\"\n+\t\tif [ $ret -ne 0 ]; then\n+\t\t\techo \"ERROR: Leaving conflict merge in $src2\"\n+\t\tfi\n+\t\texit 1\n+\tfi\n+\tchmod -- \"$6\" \"$src2\"\n+\tif [ $ -ne 0 ]; then\n+\t\techo \"ERROR: Leaving conflict merge in $src2\"\n \t\texit 1\n \tfi\n-\tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n+\tcp -- \"$src2\" \"$4\" && chmod -- \"$6\" \"$4\" &&  update-cache --add -- \"$4\" && exit 0\n \t;;\n \n *)\n--- a/merge-cache.c\n+++ b/merge-cache.c\n@@ -4,7 +4,7 @@\n #include \"cache.h\"\n \n static const char *pgm = NULL;\n-static const char *arguments[5];\n+static const char *arguments[8];\n \n static void run_program(void)\n {\n@@ -18,6 +18,9 @@ static void run_program(void)\n \t\t\t    arguments[2],\n \t\t\t    arguments[3],\n \t\t\t    arguments[4],\n+\t\t\t    arguments[5],\n+\t\t\t    arguments[6],\n+\t\t\t    arguments[7],\n \t\t\t    NULL);\n \t\tdie(\"unable to execute '%s'\", pgm);\n \t}\n@@ -36,9 +39,13 @@ static int merge_entry(int pos, const ch\n \targuments[2] = \"\";\n \targuments[3] = \"\";\n \targuments[4] = path;\n+\targuments[5] = \"\";\n+\targuments[6] = \"\";\n+\targuments[7] = \"\";\n \tfound = 0;\n \tdo {\n \t\tstatic char hexbuf[4][60];\n+\t\tstatic char ownbuf[4][60];\n \t\tstruct cache_entry *ce = active_cache[pos];\n \t\tint stage = ce_stage(ce);\n \n@@ -46,7 +53,9 @@ static int merge_entry(int pos, const ch\n \t\t\tbreak;\n \t\tfound++;\n \t\tstrcpy(hexbuf[stage], sha1_to_hex(ce->sha1));\n+\t\tsprintf(ownbuf[stage], \"%o\", ntohl(ce->ce_mode) & (~S_IFMT));\n \t\targuments[stage] = hexbuf[stage];\n+\t\targuments[stage + 4] = ownbuf[stage];\n \t} while (++pos < active_nr);\n \tif (!found)\n \t\tdie(\"merge-cache: %s not in the cache\", path);\n\n\n"},{"id":"1424","messageId":"20050423230238.GD13222@pasky.ji.cz","threadId":"265","inReplyTo":"1114292680.4799.4.camel@mulgrave","subject":"Re: [PATCH] make file merging respect permissions","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-23T23:02:38Z","receivedAt":"2005-04-23T23:02:38Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sat, Apr 23, 2005 at 11:44:40PM CEST, I got a letter\nwhere James Bottomley <James.Bottomley@SteelEye.com> told me that...\n> On Sat, 2005-04-23 at 13:17 -0700, Linus Torvalds wrote:\n> > Yeah, yeah, you obviously meant \"$?\", but the fact \n> > is, your patch is bogus, and I don't trust it. Can you re-send a valid\n> > one \n> > (and sign off on it).]\n> \n> OK, here it is  .. I have an excuse, honest ... and a note from my mum.\n> \n> +\tret=$?\n> +\tif [ \"$6\" != \"$7\" ]; then\n> +\t\techo \"ERROR: Permissions $5->$6->$7 don't match merging $src2\"\n> +\t\tif [ $ret -ne 0 ]; then\n> +\t\t\techo \"ERROR: Leaving conflict merge in $src2\"\n> +\t\tfi\n> +\t\texit 1\n> +\tfi\n> +\tchmod -- \"$6\" \"$src2\"\n> +\tif [ $ -ne 0 ]; then\n\n*cough*\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":"1425","messageId":"1114297749.5264.3.camel@mulgrave","threadId":"265","inReplyTo":"20050423230238.GD13222@pasky.ji.cz","subject":"Re: [PATCH] make file merging respect permissions","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-23T23:09:09Z","receivedAt":"2005-04-23T23:09:09Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"On Sun, 2005-04-24 at 01:02 +0200, Petr Baudis wrote:\n> > +\tif [ $ -ne 0 ]; then\n> \n> *cough*\n\nYou're kidding me?\n\nWell ... it's correct in my repository ... I'll investigate my diff\nscript\n\nJames\n\n\n"},{"id":"1431","messageId":"1114298490.5264.10.camel@mulgrave","threadId":"265","inReplyTo":"20050423230238.GD13222@pasky.ji.cz","subject":"Re: [PATCH] make file merging respect permissions","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-23T23:21:30Z","receivedAt":"2005-04-23T23:21:30Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"On Sun, 2005-04-24 at 01:02 +0200, Petr Baudis wrote:\n> *cough*\n\nOK, dirty file in the local tree, sorry.\n\nThis is the actual diff\n\n---\n\n1) permissions aren't respected in the merge script (primarily because\nthey're never passed in to it in the first place).  Fix that and also\ncheck for permission conflicts in the merge\n\n2) the delete of a file in both branches may indeed be just that, but it\ncould also be the indicator of a rename conflict (file moved to\ndifferent locations in both branches), so error out and ask the\ncommitter for guidance.\n\nSigned-off-by: James Bottomley <James.Bottomley@SteelEye.com>\n\n--- a/git-merge-one-file-script\n+++ b/git-merge-one-file-script\n@@ -20,23 +20,45 @@ mkdir -p \"$dir\"\n \n case \"${1:-.}${2:-.}${3:-.}\" in\n #\n-# deleted in both, or deleted in one and unchanged in the other\n+# deleted in both\n+#\n+\"$1..\")\n+\techo \"ERROR: $4 is removed in both branches\"\n+\techo \"ERROR: This is a potential rename conflict\"\n+\texit 1;;\n+#\n+# deleted in one and unchanged in the other\n #\n \"$1..\" | \"$1.$1\" | \"$1$1.\")\n \trm -f -- \"$4\"\n+\techo \"Removing $4\"\n \tupdate-cache --remove -- \"$4\"\n \texit 0\n \t;;\n \n #\n-# added in one, or added identically in both\n+# added in one\n #\n-\".$2.\" | \"..$3\" | \".$2$2\")\n-\tmv $(unpack-file \"${2:-$3}\") $4\n+\".$2.\" | \"..$3\" )\n+\techo \"Adding $4 with perm $6$7\"\n+\tmv $(unpack-file \"$2$3\") $4\n+\tchmod \"$6$7\" $4\n \tupdate-cache --add -- $4\n \texit 0\n \t;;\n-\n+#\n+# Added in both (check for same permissions)\n+#\n+\".$2$2\")\n+\tif [ \"$6\" != \"$7\" ]; then\n+\t\techo \"ERROR: File $4 added in both branches, permissions conflict $6->$7\"\n+\t\texit 1\n+\tfi\n+\techo \"Adding $4 with perm $6\"\n+\tmv $(unpack-file \"$2\") $4\n+\tchmod \"$6\" $4\n+\tupdate-cache --add -- $4\n+\texit 0;;\n #\n # Modified in both, but differently ;(\n #\n@@ -46,12 +68,21 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \tsrc1=$(unpack-file $2)\n \tsrc2=$(unpack-file $3)\n \tmerge \"$src2\" \"$orig\" \"$src1\"\n-\tif [ $? -ne 0 ]; then\n-\t\techo Leaving conflict merge in $src2\n+\tret=$?\n+\tif [ \"$6\" != \"$7\" ]; then\n+\t\techo \"ERROR: Permissions $5->$6->$7 don't match merging $src2\"\n+\t\tif [ $ret -ne 0 ]; then\n+\t\t\techo \"ERROR: Leaving conflict merge in $src2\"\n+\t\tfi\n+\t\texit 1\n+\tfi\n+\tchmod -- \"$6\" \"$src2\"\n+\tif [ $ret -ne 0 ]; then\n+\t\techo \"ERROR: Leaving conflict merge in $src2\"\n \t\texit 1\n \tfi\n-\tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n+\tcp -- \"$src2\" \"$4\" && chmod -- \"$6\" \"$4\" &&  update-cache --add -- \"$4\" && exit 0\n \t;;\n \n *)\n--- a/merge-cache.c\n+++ b/merge-cache.c\n@@ -4,7 +4,7 @@\n #include \"cache.h\"\n \n static const char *pgm = NULL;\n-static const char *arguments[5];\n+static const char *arguments[8];\n \n static void run_program(void)\n {\n@@ -18,6 +18,9 @@ static void run_program(void)\n \t\t\t    arguments[2],\n \t\t\t    arguments[3],\n \t\t\t    arguments[4],\n+\t\t\t    arguments[5],\n+\t\t\t    arguments[6],\n+\t\t\t    arguments[7],\n \t\t\t    NULL);\n \t\tdie(\"unable to execute '%s'\", pgm);\n \t}\n@@ -36,9 +39,13 @@ static int merge_entry(int pos, const ch\n \targuments[2] = \"\";\n \targuments[3] = \"\";\n \targuments[4] = path;\n+\targuments[5] = \"\";\n+\targuments[6] = \"\";\n+\targuments[7] = \"\";\n \tfound = 0;\n \tdo {\n \t\tstatic char hexbuf[4][60];\n+\t\tstatic char ownbuf[4][60];\n \t\tstruct cache_entry *ce = active_cache[pos];\n \t\tint stage = ce_stage(ce);\n \n@@ -46,7 +53,9 @@ static int merge_entry(int pos, const ch\n \t\t\tbreak;\n \t\tfound++;\n \t\tstrcpy(hexbuf[stage], sha1_to_hex(ce->sha1));\n+\t\tsprintf(ownbuf[stage], \"%o\", ntohl(ce->ce_mode) & (~S_IFMT));\n \t\targuments[stage] = hexbuf[stage];\n+\t\targuments[stage + 4] = ownbuf[stage];\n \t} while (++pos < active_nr);\n \tif (!found)\n \t\tdie(\"merge-cache: %s not in the cache\", path);\n\n\n"},{"id":"1454","messageId":"Pine.LNX.4.58.0504231759010.2344@ppc970.osdl.org","threadId":"265","inReplyTo":"1114298490.5264.10.camel@mulgrave","subject":"Re: [PATCH] make file merging respect permissions","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-24T01:01:48Z","receivedAt":"2005-04-24T01:01:48Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 23 Apr 2005, James Bottomley wrote:\n> \n> This is the actual diff\n\nThis is _still_ corrupted. \n\nAre you editing your diffs by hand without understanding how the diffs \nwork?\n\nThe second chunk of the \"git-merge-one-file\" diff _still_ claims to change \ntwelve lines, and that diff _still_ only changes eleven lines. My \"patch\" \nisn't happy, and I can count the lines in the diff myself and verify that \nit's not patch that is wrong, it's your diff.\n\nPlease please _please_ don't edit diffs by hand if you don't know what \nyou're doing. Generate the diff from a clean source instead. Or ask me to \nfix it up, I'm so used to editing diffs that I can do it in my sleep.\n\n\t\tLinus\n"},{"id":"1483","messageId":"1114317771.4980.7.camel@mulgrave","threadId":"265","inReplyTo":"Pine.LNX.4.58.0504231759010.2344@ppc970.osdl.org","subject":"Re: [PATCH] make file merging respect permissions","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-24T04:42:51Z","receivedAt":"2005-04-24T04:42:51Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"On Sat, 2005-04-23 at 18:01 -0700, Linus Torvalds wrote:\n> \n> On Sat, 23 Apr 2005, James Bottomley wrote:\n> > \n> > This is the actual diff\n> \n> This is _still_ corrupted. \n> \n> Are you editing your diffs by hand without understanding how the diffs \n> work?\n\nSort of: I'm taking a diff between my tree and yours but stripping out\nthe extraneous pieces (which are whole file diffs, nothing in the actual\ndiffs I send you).\n\n> The second chunk of the \"git-merge-one-file\" diff _still_ claims to change \n> twelve lines, and that diff _still_ only changes eleven lines. My \"patch\" \n> isn't happy, and I can count the lines in the diff myself and verify that \n> it's not patch that is wrong, it's your diff.\n> \n> Please please _please_ don't edit diffs by hand if you don't know what \n> you're doing. Generate the diff from a clean source instead. Or ask me to \n> fix it up, I'm so used to editing diffs that I can do it in my sleep.\n\nOK ... this is done by reapplying to the top of your git tree and then\ndoing a show-diff.  I've checked that it actually applies without\nrejections to a pristine git tree.\n\nJames\n\ngit-merge-one-file-script: b2adc5fc4583e6089f4b38a47e1a73caad183f20\n--- a/git-merge-one-file-script\n+++ b/git-merge-one-file-script\n@@ -20,23 +20,45 @@ mkdir -p \"$dir\"\n \n case \"${1:-.}${2:-.}${3:-.}\" in\n #\n-# deleted in both, or deleted in one and unchanged in the other\n+# deleted in both\n+#\n+\"$1..\")\n+\techo \"ERROR: $4 is removed in both branches\"\n+\techo \"ERROR: This is a potential rename conflict\"\n+\texit 1;;\n+#\n+# deleted in one and unchanged in the other\n #\n \"$1..\" | \"$1.$1\" | \"$1$1.\")\n \trm -f -- \"$4\"\n+\techo \"Removing $4\"\n \tupdate-cache --remove -- \"$4\"\n \texit 0\n \t;;\n \n #\n-# added in one, or added identically in both\n+# added in one\n #\n-\".$2.\" | \"..$3\" | \".$2$2\")\n-\tmv $(unpack-file \"${2:-$3}\") $4\n+\".$2.\" | \"..$3\" )\n+\techo \"Adding $4 with perm $6$7\"\n+\tmv $(unpack-file \"$2$3\") $4\n+\tchmod \"$6$7\" $4\n \tupdate-cache --add -- $4\n \texit 0\n \t;;\n-\n+#\n+# Added in both (check for same permissions)\n+#\n+\".$2$2\")\n+\tif [ \"$6\" != \"$7\" ]; then\n+\t\techo \"ERROR: File $4 added in both branches, permissions conflict $6->$7\"\n+\t\texit 1\n+\tfi\n+\techo \"Adding $4 with perm $6\"\n+\tmv $(unpack-file \"$2\") $4\n+\tchmod \"$6\" $4\n+\tupdate-cache --add -- $4\n+\texit 0;;\n #\n # Modified in both, but differently ;(\n #\n@@ -46,11 +68,20 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \tsrc1=$(unpack-file $2)\n \tsrc2=$(unpack-file $3)\n \tmerge \"$src2\" \"$orig\" \"$src1\"\n-\tif [ $? -ne 0 ]; then\n-\t\techo Leaving conflict merge in $src2\n+\tret=$?\n+\tif [ \"$6\" != \"$7\" ]; then\n+\t\techo \"ERROR: Permissions $5->$6->$7 don't match merging $src2\"\n+\t\tif [ $ret -ne 0 ]; then\n+\t\t\techo \"ERROR: Leaving conflict merge in $src2\"\n+\t\tfi\n+\t\texit 1\n+\tfi\n+\tchmod -- \"$6\" \"$src2\"\n+\tif [ $ret -ne 0 ]; then\n+\t\techo \"ERROR: Leaving conflict merge in $src2\"\n \t\texit 1\n \tfi\n-\tcp \"$src2\" \"$4\" && update-cache --add -- \"$4\" && exit 0\n+\tcp -- \"$src2\" \"$4\" && chmod -- \"$6\" \"$4\" &&  update-cache --add -- \"$4\" && exit 0\n \t;;\n \n *)\nmerge-cache.c: 68ac4ab2d926005a5a729017c1bcb70a30634bd8\n--- a/merge-cache.c\n+++ b/merge-cache.c\n@@ -4,7 +4,7 @@\n #include \"cache.h\"\n \n static const char *pgm = NULL;\n-static const char *arguments[5];\n+static const char *arguments[8];\n \n static void run_program(void)\n {\n@@ -18,6 +18,9 @@ static void run_program(void)\n \t\t\t    arguments[2],\n \t\t\t    arguments[3],\n \t\t\t    arguments[4],\n+\t\t\t    arguments[5],\n+\t\t\t    arguments[6],\n+\t\t\t    arguments[7],\n \t\t\t    NULL);\n \t\tdie(\"unable to execute '%s'\", pgm);\n \t}\n@@ -36,9 +39,13 @@ static int merge_entry(int pos, const ch\n \targuments[2] = \"\";\n \targuments[3] = \"\";\n \targuments[4] = path;\n+\targuments[5] = \"\";\n+\targuments[6] = \"\";\n+\targuments[7] = \"\";\n \tfound = 0;\n \tdo {\n \t\tstatic char hexbuf[4][60];\n+\t\tstatic char ownbuf[4][60];\n \t\tstruct cache_entry *ce = active_cache[pos];\n \t\tint stage = ce_stage(ce);\n \n@@ -46,7 +53,9 @@ static int merge_entry(int pos, const ch\n \t\t\tbreak;\n \t\tfound++;\n \t\tstrcpy(hexbuf[stage], sha1_to_hex(ce->sha1));\n+\t\tsprintf(ownbuf[stage], \"%o\", ntohl(ce->ce_mode) & (~S_IFMT));\n \t\targuments[stage] = hexbuf[stage];\n+\t\targuments[stage + 4] = ownbuf[stage];\n \t} while (++pos < active_nr);\n \tif (!found)\n \t\tdie(\"merge-cache: %s not in the cache\", path);\n\n\n"},{"id":"1485","messageId":"Pine.LNX.4.58.0504232153500.15879@ppc970.osdl.org","threadId":"265","inReplyTo":"1114317771.4980.7.camel@mulgrave","subject":"Re: [PATCH] make file merging respect permissions","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-24T04:55:21Z","receivedAt":"2005-04-24T04:55:21Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 23 Apr 2005, James Bottomley wrote:\n> \n> OK ... this is done by reapplying to the top of your git tree and then\n> doing a show-diff.  I've checked that it actually applies without\n> rejections to a pristine git tree.\n\nWell, I actually ended up editing the line numbers manually and already \npushed out the previous one, so you might want to double-check that my \ncurrent tree matches yours.\n\n\t\tLinus\n"},{"id":"1489","messageId":"1114318981.4980.14.camel@mulgrave","threadId":"265","inReplyTo":"Pine.LNX.4.58.0504232153500.15879@ppc970.osdl.org","subject":"Re: [PATCH] make file merging respect permissions","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-24T05:03:01Z","receivedAt":"2005-04-24T05:03:01Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"On Sat, 2005-04-23 at 21:55 -0700, Linus Torvalds wrote:\n> Well, I actually ended up editing the line numbers manually and already \n> pushed out the previous one, so you might want to double-check that my \n> current tree matches yours.\n\nYes, the sha1 of my changed file and the one you merged match, so\neverything looks sane.\n\nSorry for the confusion,\n\nJames\n\n\n"},{"id":"1490","messageId":"Pine.LNX.4.58.0504232202380.7195@sam.ics.uci.edu","threadId":"265","inReplyTo":"Pine.LNX.4.58.0504232153500.15879@ppc970.osdl.org","subject":"[PATH] fix segfault in fsck-cache","fromName":"Andreas Gal","fromEmail":"gal@uci.edu","sentAt":"2005-04-24T05:05:44Z","receivedAt":"2005-04-24T05:05:44Z","isPatch":false,"sender":{"key":"gal@uci.edu","avatar":null},"body":"\nI somehow got some corrupted object files in my repository that zlib \nrefuses to decompress. This patch makes sure we abort early before the \nmemcpy a few lines downtream segfaults (due to total_out == 0).\n\nAndreas\n\nSigned-off-by: Andreas Gal <gal@uci.edu>\n\n--- 66308ede85c2dad6b184fb74a7215b06a173d8f7/sha1_file.c\n+++ sha1_file.c\n@@ -155,6 +155,8 @@\n \n \tinflateInit(&stream);\n \tret = inflate(&stream, 0);\n+\tif (ret != Z_OK)\n+\t\treturn NULL;\n \tif (sscanf(buffer, \"%10s %lu\", type, size) != 2)\n \t\treturn NULL;\n \n\n"},{"id":"1496","messageId":"Pine.LNX.4.58.0504232223570.8755@sam.ics.uci.edu","threadId":"265","inReplyTo":"Pine.LNX.4.58.0504232202380.7195@sam.ics.uci.edu","subject":"Re: [PATH] fix segfault in fsck-cache","fromName":"Andreas Gal","fromEmail":"gal@uci.edu","sentAt":"2005-04-24T05:24:29Z","receivedAt":"2005-04-24T05:24:29Z","isPatch":false,"sender":{"key":"gal@uci.edu","avatar":null},"body":"\nThis isn't working right either, depending on your ZLIB version. Do not \napply. \n\nAndreas\n\nOn Sat, 23 Apr 2005, Andreas Gal wrote:\n\n> \n> I somehow got some corrupted object files in my repository that zlib \n> refuses to decompress. This patch makes sure we abort early before the \n> memcpy a few lines downtream segfaults (due to total_out == 0).\n> \n> Andreas\n> \n> Signed-off-by: Andreas Gal <gal@uci.edu>\n> \n> --- 66308ede85c2dad6b184fb74a7215b06a173d8f7/sha1_file.c\n> +++ sha1_file.c\n> @@ -155,6 +155,8 @@\n>  \n>  \tinflateInit(&stream);\n>  \tret = inflate(&stream, 0);\n> +\tif (ret != Z_OK)\n> +\t\treturn NULL;\n>  \tif (sscanf(buffer, \"%10s %lu\", type, size) != 2)\n>  \t\treturn NULL;\n>  \n> \n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n"},{"id":"1514","messageId":"1114346767.4997.2.camel@mulgrave","threadId":"265","inReplyTo":"Pine.LNX.4.58.0504232153500.15879@ppc970.osdl.org","subject":"Re: [PATCH] make file merging respect permissions","fromName":"James Bottomley","fromEmail":"james.bottomley@steeleye.com","sentAt":"2005-04-24T12:46:07Z","receivedAt":"2005-04-24T12:46:07Z","isPatch":true,"sender":{"key":"james.bottomley@steeleye.com","avatar":null},"body":"On Sat, 2005-04-23 at 21:55 -0700, Linus Torvalds wrote:\n> Well, I actually ended up editing the line numbers manually and already \n> pushed out the previous one, so you might want to double-check that my \n> current tree matches yours.\n\nJust to get closure on this, I went over all the parts of patch\ngeneration, and the culprit turns out to be emacs.  Apparently its diff\nmode (which I never thought to investigate how to use) does these re-\nwrites ... no idea why, but the problem goes away if I strip out the\nextraneous pieces in fundamental-mode.  It's never given me this trouble\nbefore ... I think the diff I'm producing must be confusing it somehow.\n\nJames\n\n\n"}]}