{"thread":{"id":"870","subject":"[PATCH] git-merge-one-file-script cleanups from Cogito","startedAt":"2005-06-08T23:38:20Z","lastAt":"2005-06-08T23:56:34Z","messageCount":2,"participants":["Petr Baudis","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4734","messageId":"20050608233820.GB9782@pasky.ji.cz","threadId":"870","inReplyTo":null,"subject":"[PATCH] git-merge-one-file-script cleanups from Cogito","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-06-08T23:38:20Z","receivedAt":"2005-06-08T23:38:20Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Chain the resolving sequences (e.g. git-cat-file - chmod -\ngit-update-cache) through &&s so we stop right away in case one of the\ncommand fails, and report the error code to the script caller.\n\nAlso add a copyright notice, some blank lines, ;; on a separate line,\nand nicer error messages.\n\nSigned-off-by: Petr Baudis <pasky@ucw.cz>\n\n---\ncommit 99169278864b1adba5494d34f86c00d08ec0aff2\ntree 5b9129ffe38c4286f65a6ddf97a0674bfc8942e3\nparent c7773b6b3ab4f03a4e64084c0dc67045b283bc34\nauthor Petr Baudis <pasky@ucw.cz> Thu, 09 Jun 2005 01:03:14 +0200\ncommitter Petr Baudis <xpasky@machine.sinus.cz> Thu, 09 Jun 2005 01:03:14 +0200\n\n git-merge-one-file-script |   44 +++++++++++++++++++++++++++++---------------\n 1 files changed, 29 insertions(+), 15 deletions(-)\n\ndiff --git a/git-merge-one-file-script b/git-merge-one-file-script\n--- a/git-merge-one-file-script\n+++ b/git-merge-one-file-script\n@@ -1,6 +1,8 @@\n #!/bin/sh\n #\n-# This is the git merge script, called with\n+# Copyright (c) Linus Torvalds, 2005\n+#\n+# This is the git per-file merge script, called with\n #\n #   $1 - original file SHA1 (or empty)\n #   $2 - file in branch1 SHA1 (or empty)\n@@ -12,7 +14,7 @@\n #\n # Handle some trivial cases.. The _really_ trivial cases have\n # been handled already by git-read-tree, but that one doesn't\n-# do any merges that migth change the tree layout.\n+# do any merges that might change the tree layout.\n \n case \"${1:-.}${2:-.}${3:-.}\" in\n #\n@@ -21,23 +23,29 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \"$1..\")\n \techo \"WARNING: $4 is removed in both branches.\"\n \techo \"WARNING: This is a potential rename conflict.\"\n-\texec git-update-cache --remove -- \"$4\" ;;\n+\texec git-update-cache --remove -- \"$4\"\n+\t;;\n+\n #\n # Deleted in one and unchanged in the other.\n #\n-\"$1..\" | \"$1.$1\" | \"$1$1.\")\n+\"$1.$1\" | \"$1$1.\")\n \techo \"Removing $4\"\n-\trm -f -- \"$4\"\n-\texec git-update-cache --remove -- \"$4\" ;;\n+\texec rm -f -- \"$4\" &&\n+\t\tgit-update-cache --remove -- \"$4\"\n+\t;;\n+\n #\n # Added in one.\n #\n \".$2.\" | \"..$3\" )\n \tcase \"$6$7\" in *7??) mode=+x;; *) mode=-x;; esac\n \techo \"Adding $4 with perm $mode.\"\n-\tgit-cat-file blob \"$2$3\" > \"$4\"\n-\tchmod $mode -- \"$4\"\n-\texec git-update-cache --add -- \"$4\" ;;\n+\texec git-cat-file blob \"$2$3\" >\"$4\" &&\n+\t\tchmod $mode -- \"$4\" &&\n+\t\tgit-update-cache --add -- \"$4\"\n+\t;;\n+\n #\n # Added in both (check for same permissions).\n #\n@@ -49,9 +57,11 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \tfi\n \tcase \"$6\" in *7??) mode=+x;; *) mode=-x;; esac\n \techo \"Adding $4 with perm $mode\"\n-\tgit-cat-file blob \"$2\" > \"$4\"\n-\tchmod $mode -- \"$4\"\n-\texec git-update-cache --add -- \"$4\" ;;\n+\texec git-cat-file blob \"$2\" >\"$4\" &&\n+\t\tchmod $mode -- \"$4\" &&\n+\t\tgit-update-cache --add -- \"$4\"\n+\t;;\n+\n #\n # Modified in both, but differently.\n #\n@@ -60,12 +70,13 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \torig=`git-unpack-file $1`\n \tsrc1=`git-unpack-file $2`\n \tsrc2=`git-unpack-file $3`\n+\n \tmerge -p \"$src1\" \"$orig\" \"$src2\" > \"$4\"\n \tret=$?\n \trm -f -- \"$orig\" \"$src1\" \"$src2\"\n \n \tif [ \"$6\" != \"$7\" ]; then\n-\t\techo \"ERROR: Permissions $5->$6->$7 don't match.\"\n+\t\techo \"ERROR: Permissions conflict: $5->$6,$7.\"\n \t\tret=1\n \tfi\n \tcase \"$6\" in *7??) mode=+x;; *) mode=-x;; esac\n@@ -78,8 +89,11 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \t\techo \"ERROR: Merge conflict in $4.\"\n \t\texit 1\n \tfi\n-\texec git-update-cache --add -- \"$4\" ;;\n+\texec git-update-cache --add -- \"$4\"\n+\t;;\n+\n *)\n-\techo \"ERROR: Not handling case $4: $1 -> $2 -> $3\" ;;\n+\techo \"ERROR: $4: Not handling case $1 -> $2 -> $3\"\n+\t;;\n esac\n exit 1\n\n|\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\n<Espy> be careful, some twit might quote you out of context..\n"},{"id":"4739","messageId":"Pine.LNX.4.58.0506081655580.2286@ppc970.osdl.org","threadId":"870","inReplyTo":"20050608233820.GB9782@pasky.ji.cz","subject":"Re: [PATCH] git-merge-one-file-script cleanups from Cogito","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-06-08T23:56:34Z","receivedAt":"2005-06-08T23:56:34Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 9 Jun 2005, Petr Baudis wrote:\n>\n> Chain the resolving sequences (e.g. git-cat-file - chmod -\n> git-update-cache) through &&s so we stop right away in case one of the\n> command fails, and report the error code to the script caller.\n\nHeh. This patch wouldn't apply, so I tried the new merge functionality on \nit. Seems to work. Goodie.\n\n\t\tLinus\n"}]}