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

Re: [script] ge: export commits as patches

From
IMIngo Molnar <mingo@elte.hu>
Date
Apr 19, 2005, 18:56 UTC
Message-ID
<20050419185607.GA26756@elte.hu>
In-Reply-To
<20050419170320.GG12757@pasky.ji.cz>
* Petr Baudis <pasky@ucw.cz> wrote:
Show 21 quoted lines
> Dear diary, on Tue, Apr 19, 2005 at 03:48:43PM CEST, I got a letter
> where Ingo Molnar <mingo@elte.hu> told me that...
> > 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.
> 
> Nice idea. I will add it, probably as 'git patch'.
> 
> > 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
> 
> commit-id and parent-id tools might be useful. ;-)
find a cleaned up 'ge' script below.

and please fix gitXnormid.sh to simply echo nothing and return with a -1 exit value when a nonsensical ID is passed to it. Right now the output is quite ugly if you do 'ge blah'.

	Ingo
#!/bin/bash
usage ()
{
 echo 'usage: ge <commit-ID>'
 exit -1
}
if [ $# != 1 ]; then
 usage
fi

ME= $(commit-id $1); [ "$ME" = "" ] && usage PARENT=$(parent-id $ME); [ "$PARENT" = "" ] && usage TREE1= $(tree-id $ME); [ "$TREE1" = "" ] && usage TREE2= $(tree-id $PARENT); [ "$TREE2" = "" ] && usage

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

Previous: Petr BaudisNext: Petr Baudis
Message 3 of 8 in “[script] ge: export commits as patches”
  1. Ingo MolnarApr 19, 2005
  2. Petr BaudisApr 19, 2005
  3. Ingo MolnarApr 19, 2005
  4. Petr BaudisApr 19, 2005
  5. David A. WheelerApr 20, 2005
  6. Greg KHApr 19, 2005
  7. David A. WheelerApr 19, 2005
  8. Zlatko CalusicApr 20, 2005

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.