Subject: [script] ge: export commits as patches

From: Ingo Molnar <[email-masked]>
Date: Tue, 19 Apr 2005 15:48:43 +0200

is there any 'export commit as patch' support in git-pasky? I didnt find 
any such command (maybe it got added meanwhile), so i'm using the 'ge' 
hack below.

e.g. i typically look at commits via 'git log', and then when i see 
something interesting, i look at the commit via the 'ge' script. E.g.  
"ge 834f6209b22af2941a8640f1e32b0f123c833061" done in the kernel tree 
will output a particular commit's header and the patch.

	Ingo

#!/bin/bash

if [ $# != 1 ]; then
 echo 'ge <commit-ID>'
 exit -1
fi
TREE1=$(cat-file commit 2>/dev/null $1 | head -4 | grep ^tree | cut -d' ' -f2)
if [ "$TREE1" = "" ]; then echo 'ge <commit-ID>'; exit -1; fi
PARENT=$(cat-file commit 2>/dev/null $1 | head -4 | grep ^parent | cut -d' ' -f2)
if [ "$PARENT" = "" ]; then echo 'ge <commit-ID>'; exit -1; fi
TREE2=$(cat-file commit 2>/dev/null $PARENT | head -4 | grep ^tree | cut -d' ' -f2)
if [ "$TREE2" = "" ]; then echo 'ge <commit-ID>'; exit -1; fi

cat-file commit $1
echo
git diff -r $TREE2:$TREE1