{"thread":{"id":"8743","subject":"post-update script to update wc - version 2","startedAt":"2007-06-27T02:05:18Z","lastAt":"2007-06-27T23:53:39Z","messageCount":9,"participants":["Sam Vilain","Steven Grimm","Alex Riesen","Junio C Hamano","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"45877","messageId":"E1I3MuE-0005eO-00@www.watts.utsl.gen.nz","threadId":"8743","inReplyTo":null,"subject":"post-update script to update wc - version 2","fromName":"Sam Vilain","fromEmail":"samv@utsl.gen.nz","sentAt":"2007-06-27T02:05:18Z","receivedAt":"2007-06-27T02:05:18Z","isPatch":false,"sender":{"key":"samv@utsl.gen.nz","avatar":null},"body":"#!/bin/sh\n#\n# An example hook script to prepare a packed repository for use over\n# dumb transports.\n#\n# To enable this hook, make this file executable by \"chmod +x post-update\".\n\ngit-update-server-info\n\nexport GIT_DIR=`cd $GIT_DIR; pwd`\n[ `expr \"$GIT_DIR\" : '.*/\\.git'` = 0 ] && exit 0\n\ntree_in_revlog() {\n    ref=$1\n    tree=$2\n    found=$(\n    tail logs/$ref | while read commit rubbish\n    do\n        this_tree=`git-cat-file commit $commit | awk '/^tree/ { print $2; exit }'`\n\tif [ \"$this_tree\" = \"$tree\" ]\n        then\n\t    echo $commit\n        fi\n    done\n    )\n    [ -n \"$found\" ] && true\n}\n\nfor ref\ndo\nactive=`git-symbolic-ref HEAD`\nif [ \"$ref\" = \"$active\" ]\nthen\n  echo \"Pushing to checked out branch - updating working copy\" >&2\n  success=\n  if ! (cd ..; git-diff-files) | grep -q .\n  then\n    # save the current index just in case\n    current_tree=`git-write-tree`\n    if tree_in_revlog $ref $current_tree\n    then\n      cd ..\n      if git-diff-index -R --name-status HEAD >&2 &&\n         git-diff-index -z --name-only --diff-filter=A HEAD | xargs -0r rm &&\n         git-reset --hard HEAD\n      then\n         success=1\n      else\n        echo \"E:unexpected error during update\" >&2\n      fi\n    else\n      echo \"E:uncommitted, staged changes found\" >&2\n    fi\n  else\n    echo \"E:unstaged changes found\" >&2\n  fi\n\n  if [ -z \"$success\" ]\n  then\n    (\n    echo \"Non-bare repository checkout is not clean - not updating it\"\n    echo \"However I AM going to update the index.  Any half-staged commit\"\n    echo \"in that checkout will be thrown away, but on the bright side\"\n    echo \"this is probably the least confusing thing for us to do and at\"\n    echo \"least we're not throwing any files somebody has changed away\"\n    git-reset --mixed HEAD\n    echo \n    echo \"This is the new status of the upstream working copy:\"\n    git-status\n    ) >&2\n  fi\nfi\ndone\n"},{"id":"45878","messageId":"4681C640.6060408@vilain.net","threadId":"8743","inReplyTo":"E1I3MuE-0005eO-00@www.watts.utsl.gen.nz","subject":"Re: post-update script to update wc - version 2","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2007-06-27T02:06:56Z","receivedAt":"2007-06-27T02:06:56Z","isPatch":false,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Sam Vilain wrote:\n>         this_tree=`git-cat-file commit $commit | awk '/^tree/ { print $2; exit }'`\n\nOf course on newer git, `git-rev-parse $commit:` will do that.\n\nSam.\n"},{"id":"45896","messageId":"468217B4.3030708@midwinter.com","threadId":"8743","inReplyTo":"E1I3MuE-0005eO-00@www.watts.utsl.gen.nz","subject":"Re: post-update script to update wc - version 2","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-06-27T07:54:28Z","receivedAt":"2007-06-27T07:54:28Z","isPatch":false,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"Sam Vilain wrote:\n> # An example hook script to prepare a packed repository for use over\n> # dumb transports.\n>   \nMaybe this comment isn't quite accurate any more?\n\n-Steve\n"},{"id":"45899","messageId":"81b0412b0706270221y40bac0a7gf6b73eda9f1e4bb0@mail.gmail.com","threadId":"8743","inReplyTo":"4681C640.6060408@vilain.net","subject":"Re: post-update script to update wc - version 2","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-27T09:21:45Z","receivedAt":"2007-06-27T09:21:45Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 6/27/07, Sam Vilain <sam@vilain.net> wrote:\n> Sam Vilain wrote:\n> >         this_tree=`git-cat-file commit $commit | awk '/^tree/ { print $2; exit }'`\n>\n> Of course on newer git, `git-rev-parse $commit:` will do that.\n>\n\nAre you sure? Maybe you mean git-rev-parse \"$commit\"^{tree}?\n"},{"id":"45901","messageId":"7vved9pv2h.fsf@assigned-by-dhcp.pobox.com","threadId":"8743","inReplyTo":"81b0412b0706270221y40bac0a7gf6b73eda9f1e4bb0@mail.gmail.com","subject":"Re: post-update script to update wc - version 2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-27T10:09:58Z","receivedAt":"2007-06-27T10:09:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n> On 6/27/07, Sam Vilain <sam@vilain.net> wrote:\n>> Sam Vilain wrote:\n>> >         this_tree=`git-cat-file commit $commit | awk '/^tree/ { print $2; exit }'`\n>>\n>> Of course on newer git, `git-rev-parse $commit:` will do that.\n>\n> Are you sure? Maybe you mean git-rev-parse \"$commit\"^{tree}?\n\nI had the same \"Huh?\"  moment as you had, but what Sam said is\ncorrect.  He is being too clever to confuse us ;-).\n\nWhen \"$commit\" is a tree-ish,\n\n\t$commit:$path\n\nis the name of the tree or blob object at that $path, and as \nvery strange special case, an empty $path is the whole tree.\n\nIt's been this way since early this year (before v1.5.0-rc1),\nthanks to Jeff King.\n"},{"id":"45903","messageId":"Pine.LNX.4.64.0706271136150.4438@racer.site","threadId":"8743","inReplyTo":"E1I3MuE-0005eO-00@www.watts.utsl.gen.nz","subject":"Re: post-update script to update wc - version 2","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-06-27T10:36:29Z","receivedAt":"2007-06-27T10:36:29Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 27 Jun 2007, Sam Vilain wrote:\n\n> # An example hook script to prepare a packed repository for use over\n> # dumb transports.\n\n???\n\nCiao,\nDscho\n"},{"id":"45906","messageId":"81b0412b0706270543s7dd37e3ds1acfe671f647617@mail.gmail.com","threadId":"8743","inReplyTo":"7vved9pv2h.fsf@assigned-by-dhcp.pobox.com","subject":"Re: post-update script to update wc - version 2","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-27T12:43:46Z","receivedAt":"2007-06-27T12:43:46Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 6/27/07, Junio C Hamano <gitster@pobox.com> wrote:\n> \"Alex Riesen\" <raa.lkml@gmail.com> writes:\n> > On 6/27/07, Sam Vilain <sam@vilain.net> wrote:\n> >> Sam Vilain wrote:\n> >> >         this_tree=`git-cat-file commit $commit | awk '/^tree/ { print $2; exit }'`\n> >>\n> >> Of course on newer git, `git-rev-parse $commit:` will do that.\n> >\n> > Are you sure? Maybe you mean git-rev-parse \"$commit\"^{tree}?\n>\n> I had the same \"Huh?\"  moment as you had, but what Sam said is\n> correct.  He is being too clever to confuse us ;-).\n>\n> When \"$commit\" is a tree-ish,\n>\n>         $commit:$path\n>\n> is the name of the tree or blob object at that $path, and as\n> very strange special case, an empty $path is the whole tree.\n\nI didn't even see the colon. That's GMail, they obviously have\nno idea what font should be used for the mail of a technical user.\n"},{"id":"45937","messageId":"4682E8A0.8050205@vilain.net","threadId":"8743","inReplyTo":"81b0412b0706270221y40bac0a7gf6b73eda9f1e4bb0@mail.gmail.com","subject":"Re: post-update script to update wc - version 2","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2007-06-27T22:45:52Z","receivedAt":"2007-06-27T22:45:52Z","isPatch":false,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Alex Riesen wrote:\n> On 6/27/07, Sam Vilain <sam@vilain.net> wrote:\n>> Sam Vilain wrote:\n>>>         this_tree=`git-cat-file commit $commit | awk '/^tree/ { print $2; exit }'`\n>> Of course on newer git, `git-rev-parse $commit:` will do that.\n> Are you sure? Maybe you mean git-rev-parse \"$commit\"^{tree}?\n\nAh, I missed that on the git-rev-parse man page.  Much better!\n\nSam.\n"},{"id":"45939","messageId":"4682F883.4030609@vilain.net","threadId":"8743","inReplyTo":"468217B4.3030708@midwinter.com","subject":"Re: post-update script to update wc - version 2","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2007-06-27T23:53:39Z","receivedAt":"2007-06-27T23:53:39Z","isPatch":false,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Steven Grimm wrote:\n> Sam Vilain wrote:\n>> # An example hook script to prepare a packed repository for use over\n>> # dumb transports.\n>>   \n> Maybe this comment isn't quite accurate any more?\n\nOk that should read something like\n\n# This hook does two things:\n#\n#  1. update the \"info\" files that allow the list of references to be\n#     queries over dumb transports such as http\n#\n#  2. if this repository looks like it is a non-bare repository, and\n#     the checked-out branch is pushed to, then update the working copy.\n#     This makes \"push\" and \"pull\" symmetric operations as in darcs and\n#     bzr.\n\nSam.\n"}]}