threads / patch / 353

patchcg-export user the new tar-tree

Subject: [PATCH] cg-export user the new tar-tree

## tl;dr

One message between Apr 27, 2005 and Apr 27, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Joshua T. Corbin· Apr 27, 2005, 20:14 UTC · lore
If at first you don't succeed, try to fix it....failing that, dump kmail and cat | mail ;)
Okay, so this time around, there are REAL-LIVE tabs in this one...
And this time, there are no temporary files...
Signed-off-by: Joshua T. Corbin <jcorbin@wunjo.org>

--- 6ad600e20c89323c1d3049f75b8ca9b0a2d72167/cg-export (mode:100755 sha1:d39eb8e723c8cb74c96b64d510f49d1bfcd7d5f8) +++ 345e15e9173ca1d419a2ff2583696ff4166e5df3/cg-export (mode:100755 sha1:ff9aa02ff3426e20b09901a291d568bc2ce2b72a)

Show changes to diff +28 −8
@@ -8,15 +8,35 @@
 
 . cg-Xlib
 
-destdir=$1
+dest=$1
 id=$(tree-id $2)
 
-([ "$destdir" ] && [ "$id" ]) || die "usage: cg-export DESTDIR [TREE_ID]"
+([ "$dest" ] && [ "$id" ]) || die "usage: cg-export DESTDIR [TREE_ID]"
 
-[ -e "$destdir" ] && die "$destdir already exists."
+[ -e "$dest" ] && die "$dest already exists."
 
-mkdir -p $destdir || die "cannot create $destdir"
-export GIT_INDEX_FILE="$destdir/.git-index"
-read-tree $id
-checkout-cache "--prefix=$destdir/" -a
-rm $GIT_INDEX_FILE
+case $dest in
+	*.tar|*.tar.gz|*.tar.bz2|*.tgz)
+		base=${dest%.tar*};
+		base=${base%.tgz}
+		ext=${dest#$base}
+		case $ext in
+		.tar.gz|.tgz)
+			tar-tree $id "$base" | gzip -c9 $tar > $dest
+			;;
+		.tar.bz2)
+			tar-tree $id "$base" | bzip2 -c $tar > $dest
+			;;
+		.tar)
+			tar-tree $id "$base" > $dest
+			;;
+		esac
+		;;
+	*)
+		mkdir -p $dest || die "cannot create $dest"
+		export GIT_INDEX_FILE="$dest/.git-index"
+		read-tree $id
+		checkout-cache "--prefix=$dest/" -a
+		rm $GIT_INDEX_FILE
+	;;
+esac

← back to recent threads