git/list[1] front-page[2] threads[3] people[4] search[5] about
 

post-update script to update wc - suggestions welcome

From
SVSam Vilain <samv@utsl.gen.nz>
Date
Jun 20, 2007, 06:21 UTC
Message-ID
<E1I0tZY-0001Uz-00@www.watts.utsl.gen.nz>

#!/bin/sh # # An example hook script to prepare a packed repository for use over # dumb transports. # # To enable this hook, make this file executable by "chmod +x post-update".

git-update-server-info
ref=$1
active=`git-symbolic-ref HEAD`
if [ "$ref" = "$active" ]
then
  echo "Pushing to checked out branch - updating working copy" >&2
  export GIT_DIR=`cd $GIT_DIR; pwd`
  cd ..
  success=
  if git-diff-files
  then
    git-diff-index -z -R --name-status HEAD | perl -n0 -le \
	'if ($z^=1) {
		$status=$_;
	 }
	 else {
        	$filename=$_;
		printf STDERR "$status\t$filename\n";
		if($status eq "D"){
			unlink($filename)
				or die("unlink($filename) failed; $!")
		}
         }' &&
    git-reset --hard HEAD && success=1
  fi
  if [ -z "$success" ]
  then
    (
    echo "Non-bare repository checkout is not clean - not updating it"
    echo "However I AM going to update the index.  Any in-progress commit"
    echo "happening in that checkout will be thrown away, but on the bright"
    echo "side this is probably the least confusing thing for us to do and"
    echo "at least we're not throwing any files somebody has changed away"
    git-reset --mixed HEAD
    echo 
    echo "This is the new status of the upstream working copy:"
    git-status
    ) >&2
  fi
fi
Next: Sam Vilain
Message 1 of 6 in “post-update script to update wc - suggestions welcome”
  1. Sam VilainJun 20, 2007
  2. Sam VilainJun 20, 2007
  3. Junio C HamanoJun 20, 2007
  4. Sam VilainJun 20, 2007
  5. Junio C HamanoJun 20, 2007
  6. Sam VilainJun 20, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.