git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] make cg-export use tar-tree
       [not found] <200504261928.44538.jcorbin@wunjo.org>
@ 2005-04-27  1:16 ` Rene Scharfe
  0 siblings, 0 replies; only message in thread
From: Rene Scharfe @ 2005-04-27  1:16 UTC (permalink / raw)
  To: Joshua T. Corbin; +Cc: git, Petr Baudis

Joshua T. Corbin schrieb:
> Here it is (this time with real tabs instead of two spaces ;) ), requires 
> Rene's tar-tree patch. Works quite speedily too I might add.

Maybe it's just Thunderbird, but I see single spaces instead of tabs
there.

> +  tar=$(mktemp -t cg-export.tar.XXXXXX)
> +  tar-tree $id "$base" > $tar
> +  case $ext in
> +  .tar.gz|.tgz)
> +   gzip -c9 $tar > $dest
> +   rm -f $tar
> +   ;;
> +  .tar.bz2)
> +   bzip2 -c $tar > $dest
> +   rm -f $tar
> +   ;;
> +  .tar)
> +   mv $tar $dest
> +   ;;
> +  esac

You don't need to create a temporary file using tar-tree.  The above can
be done like this:

  case $ext in
  .tar.gz|.tgz)
      tar-tree $id "$base" | gzip -9
      ;;
  .tar.bz2)
      tar-tree $id "$base" | bzip2
      ;;
  .tar)
      tar-tree $id "$base"
      ;;
  esac > $dest

This is both shorter and (a bit) faster.  More easily readable, too,
IMO.  Don't fear the pipe. ;-)  And I don't think we need to avoid
the triplication of tar-tree calls.

Thanks,
Rene

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-04-27  1:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200504261928.44538.jcorbin@wunjo.org>
2005-04-27  1:16 ` [PATCH] make cg-export use tar-tree Rene Scharfe

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