{"thread":{"id":"469","subject":"[PATCH] Making cg-seek more robust","startedAt":"2005-05-04T00:08:32Z","lastAt":"2005-05-04T00:08:32Z","messageCount":1,"participants":["Pavel Roskin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2552","messageId":"1115165312.22116.8.camel@dv.roinet.com","threadId":"469","inReplyTo":null,"subject":"[PATCH] Making cg-seek more robust","fromName":"Pavel Roskin","fromEmail":"proski@gnu.org","sentAt":"2005-05-04T00:08:32Z","receivedAt":"2005-05-04T00:08:32Z","isPatch":true,"sender":{"key":"proski@gnu.org","avatar":null},"body":"Hello!\n\nThis patch does following:\n\nIf .git/HEAD is not a link, it's detected early, so that basename is not\ncalled without arguments.\n\n.git/HEAD is not deleted until validity of the branch is verified.\n\n.git/blocked is deleted by \"rm -f\" to suppress unneeded error message if\nit's missing.\n\nSigned-off-by: Pavel Roskin <proski@gnu.org>\n\n--- aa6233be6d1b8bf42797c409a7c23b50593afc99/cg-seek  (mode:100755 sha1:111f7842e5ec20a1e0714e162ca221da5e06ce33)\n+++ uncommitted/cg-seek  (mode:100755)\n@@ -29,18 +29,23 @@\n if [ -s .git/blocked ]; then\n \tbranch=$(grep '^seeked from ' .git/blocked | sed 's/^seeked from //')\n else\n-\tbranch=$(basename $(readlink .git/HEAD)) || die \"HEAD is not on branch\"\n+\ttmp=$(readlink .git/HEAD)\n+\t[ \"$tmp\" ] || die \"HEAD is not on branch\"\n+\tbranch=$(basename \"$tmp\")\n fi\n \n curcommit=$(commit-id)\n \n-rm .git/HEAD\n if [ ! \"$dstcommit\" ] || [ \"$dstcommit\" = \"$branch\" ]; then\n+\trm .git/HEAD\n \tln -s \"refs/heads/$branch\" .git/HEAD\n-\trm .git/blocked\n+\trm -f .git/blocked\n \tdstcommit=$(commit-id)\n else\n-\techo $(commit-id \"$dstcommit\") >.git/HEAD\n+\ttmp=$(commit-id \"$dstcommit\")\n+\t[ \"$tmp\" ] || die \"branch $dstcommit not found\"\n+\trm .git/HEAD\n+\techo \"$tmp\" >.git/HEAD\n \t[ -s .git/blocked ] || echo \"seeked from $branch\" >.git/blocked\n fi\n \n\n\n-- \nRegards,\nPavel Roskin\n\n"}]}