{"thread":{"id":"14736","subject":"git-attic","startedAt":"2008-07-29T11:57:38Z","lastAt":"2008-07-29T16:51:30Z","messageCount":2,"participants":["Paul Gideon Dann","Eric Raible"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"85453","messageId":"488F05B2.6060209@gmail.com","threadId":"14736","inReplyTo":null,"subject":"git-attic","fromName":"Paul Gideon Dann","fromEmail":"pdgiddie@googlemail.com","sentAt":"2008-07-29T11:57:38Z","receivedAt":"2008-07-29T11:57:38Z","isPatch":false,"sender":{"key":"pdgiddie@googlemail.com","avatar":null},"body":"Hello all,\n\nI looked around everywhere for a script that could make it easy for me \nto store stale branches in refs/attic for possible later retrieval.  I \ndon't like such branches lying around in refs/heads and used to tag them \nto clear them out of the way, but then that makes \"git push origin \n--tags\" unusable, since I don't want to push my stale branches out...\n\nAnyway, I wrote my own little script in the end and thought it might be \nuseful to others.\n\nPlease Cc pdgiddie@gmail.com in replies,\nPaul Gideon Dann\n\n\nUsage: git-attic\n       git-attic store <ref> [<commit>]\n       git-attic remove <ref>\n\n\n#!/bin/bash\n###\n# Original Author: Paul Gideon Dann <pdgiddie@gmail.com>\n###\n\nshowUsage() {\n  echo \"Usage: git-attic\"\n  echo \"       git-attic store <ref> [<commit>]\"\n  echo \"       git-attic remove <ref>\"\n}\n\ncase $1 in\n  \"store\")\n    if [[ ! $2 ]]; then\n      showUsage\n      exit 1\n    fi\n    if [[ $3 ]]; then\n      OBJECT_SHA1=`git-rev-parse --revs-only $3`\n      if [[ ! $OBJECT_SHA1 ]]; then\n        echo \"$3 is not a recognisable commit object.\"\n        exit 1\n      fi\n    else\n      OBJECT_SHA1=`git show-ref -h HEAD | awk '{print $1}'`\n    fi\n    git update-ref refs/attic/$2 $OBJECT_SHA1\n    echo \"$2 stored in attic.\"\n    ;;\n\n  \"remove\")\n    if [[ ! $2 ]]; then\n      showUsage\n      exit 1\n    fi\n    OBJECT_SHA1=`git show-ref attic/$2 | awk '{print $1}'`\n    if [[ ! $OBJECT_SHA1 ]]; then\n      echo \"$2 does not exist in the attic!\"\n      exit 1\n    fi\n    git update-ref -d refs/attic/$2 $OBJECT_SHA1\n    echo \"$2 removed from attic.\"\n    ;;\n\n  *)\n    if [[ $1 ]]; then\n      showUsage\n    else\n      # display contents of attic\n      git for-each-ref --format=\"%(refname)\" refs/attic | awk -F / \n'{print $3}'\n    fi\n    ;;\nesac\n"},{"id":"85490","messageId":"loom.20080729T164914-281@post.gmane.org","threadId":"14736","inReplyTo":"488F05B2.6060209@gmail.com","subject":"Re: git-attic","fromName":"Eric Raible","fromEmail":"raible@gmail.com","sentAt":"2008-07-29T16:51:30Z","receivedAt":"2008-07-29T16:51:30Z","isPatch":false,"sender":{"key":"raible@gmail.com","avatar":null},"body":"Paul Gideon Dann <pdgiddie <at> googlemail.com> writes:\n\n>       OBJECT_SHA1=`git show-ref -h HEAD | awk '{print $1}'`\n\nOBJECT_SHA1=`git show-ref --hash --head HEAD`\n"}]}