git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [script] ge: export commits as patches
@ 2005-04-19 13:48 Ingo Molnar
  2005-04-19 17:03 ` Petr Baudis
  2005-04-20 17:21 ` Zlatko Calusic
  0 siblings, 2 replies; 8+ messages in thread
From: Ingo Molnar @ 2005-04-19 13:48 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git


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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [script] ge: export commits as patches
  2005-04-19 13:48 [script] ge: export commits as patches Ingo Molnar
@ 2005-04-19 17:03 ` Petr Baudis
  2005-04-19 18:56   ` Ingo Molnar
                     ` (2 more replies)
  2005-04-20 17:21 ` Zlatko Calusic
  1 sibling, 3 replies; 8+ messages in thread
From: Petr Baudis @ 2005-04-19 17:03 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: git

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. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [script] ge: export commits as patches
  2005-04-19 17:03 ` Petr Baudis
@ 2005-04-19 18:56   ` Ingo Molnar
  2005-04-19 19:41     ` Petr Baudis
  2005-04-19 19:11   ` Greg KH
  2005-04-19 22:56   ` David A. Wheeler
  2 siblings, 1 reply; 8+ messages in thread
From: Ingo Molnar @ 2005-04-19 18:56 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git


* Petr Baudis <pasky@ucw.cz> wrote:

> 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [script] ge: export commits as patches
  2005-04-19 17:03 ` Petr Baudis
  2005-04-19 18:56   ` Ingo Molnar
@ 2005-04-19 19:11   ` Greg KH
  2005-04-19 22:56   ` David A. Wheeler
  2 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2005-04-19 19:11 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Ingo Molnar, git

On Tue, Apr 19, 2005 at 07:03:20PM +0200, Petr Baudis wrote:
> 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'.

Ah, thanks for doing this.  'git patch' works great (but you might want
to mention in the 'help' that you can give the commit id for the patch,
if you don't want to see the HEAD patch.)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [script] ge: export commits as patches
  2005-04-19 18:56   ` Ingo Molnar
@ 2005-04-19 19:41     ` Petr Baudis
  2005-04-20  2:34       ` David A. Wheeler
  0 siblings, 1 reply; 8+ messages in thread
From: Petr Baudis @ 2005-04-19 19:41 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: git

Dear diary, on Tue, Apr 19, 2005 at 08:56:07PM CEST, I got a letter
where Ingo Molnar <mingo@elte.hu> told me that...
> 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'.

That's a feature; you can do || exit 1. Put its stderr to /dev/null if
you want your own error reporting.

BTW, I still think my gitpatch.sh is nicer. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [script] ge: export commits as patches
  2005-04-19 17:03 ` Petr Baudis
  2005-04-19 18:56   ` Ingo Molnar
  2005-04-19 19:11   ` Greg KH
@ 2005-04-19 22:56   ` David A. Wheeler
  2 siblings, 0 replies; 8+ messages in thread
From: David A. Wheeler @ 2005-04-19 22:56 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Ingo Molnar, git

Petr Baudis wrote:

>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?
>>    
>>
>
>Nice idea. I will add it, probably as 'git patch'.
>
>  
>
Eek!

It's a nice idea, and it'd be great as a subcommand.  But PLEASE
don't name it "patch".  I already know what "patch" does, "patch"
ACCEPTS a patch... it doesn't create one ;-).

How about naming it "aspatch" or "asdiff" instead?  Or something else
(good names, anyone?).

<soapbox_to_choir>Good externally-viewed names are critical... good
command names that are similar to what people "already know"
can really help make the tool a joy to use.</soapbox_to_choir>

--- David A. Wheeler



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [script] ge: export commits as patches
  2005-04-19 19:41     ` Petr Baudis
@ 2005-04-20  2:34       ` David A. Wheeler
  0 siblings, 0 replies; 8+ messages in thread
From: David A. Wheeler @ 2005-04-20  2:34 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Ingo Molnar, git

Forget my earlier "aspatch" proposal, that's a lousy name.

How about "mkpatch"?  Seems like a reasonable name for
a command that makes a patch.  GNU Arch uses that command name.
CVS & Subversion basically do this as part of "diff"
(which is another possibility).

--- David A. Wheeler

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [script] ge: export commits as patches
  2005-04-19 13:48 [script] ge: export commits as patches Ingo Molnar
  2005-04-19 17:03 ` Petr Baudis
@ 2005-04-20 17:21 ` Zlatko Calusic
  1 sibling, 0 replies; 8+ messages in thread
From: Zlatko Calusic @ 2005-04-20 17:21 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Petr Baudis, git

Ingo Molnar <mingo@elte.hu> writes:

> TREE1=$(cat-file commit 2>/dev/null $1 | head -4 | grep ^tree | cut -d' ' -f2)
                                         --------------------------------------

And to make it easier on your eyes, you can always rewrite stuff like
that (mentioned everywhere these days :)) like:

TREE1=$(cat-file commit 2>/dev/null $1 | awk '/^tree/ {print $2}'
                                         ------------------------

No, I'm definitely not trying to save some CPU cycles, CPU cycles are
cheap, eyes are expensive! :)
-- 
Zlatko

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-04-20 17:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-19 13:48 [script] ge: export commits as patches Ingo Molnar
2005-04-19 17:03 ` Petr Baudis
2005-04-19 18:56   ` Ingo Molnar
2005-04-19 19:41     ` Petr Baudis
2005-04-20  2:34       ` David A. Wheeler
2005-04-19 19:11   ` Greg KH
2005-04-19 22:56   ` David A. Wheeler
2005-04-20 17:21 ` Zlatko Calusic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).