summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-06-19 08:41:17 +0200
committerJens Axboe <jens.axboe@oracle.com>2007-06-19 08:41:17 +0200
commit1316e194e67dffead93388e6dcd6d86fbfe9054c (patch)
tree79fc7086eddf1f98f39395d4ea262ff5949d467e
parent888eabc93ad92e53c075d57e53d551d0ed020db1 (diff)
downloadag-1316e194e67dffead93388e6dcd6d86fbfe9054c.tar.gz
ag-1316e194e67dffead93388e6dcd6d86fbfe9054c.tar.bz2
Add script for copying remote branch to local
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rwxr-xr-xag-remote-cp26
1 files changed, 26 insertions, 0 deletions
diff --git a/ag-remote-cp b/ag-remote-cp
new file mode 100755
index 0000000..1727ddd
--- /dev/null
+++ b/ag-remote-cp
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+if [ ! -d .git ]; then
+ echo Does not appear to be a git tree
+ exit 1
+fi
+
+if [ "$1"x == x ]; then
+ echo Need remote branch
+ exit 1
+fi
+
+SRC=$1
+
+if [ ! -f .git/refs/remotes/origin/$SRC ]; then
+ echo Remote branch $SRC does not exist
+ exit 2
+fi
+
+if [ "$2"x != x ]; then
+ DST=$2
+else
+ DST=$SRC
+fi
+
+cp .git/refs/remotes/origin/$SRC .git/refs/heads/$DST