From eb6941e65438f56bb42767fbb3f69412acddc976 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 1 Jul 2009 14:39:26 +0200 Subject: pkg: vcs_*: It's better to cd when working with git --- bin/pkg | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/bin/pkg b/bin/pkg index e6a2cff..8c40603 100755 --- a/bin/pkg +++ b/bin/pkg @@ -221,12 +221,10 @@ function progress { ## VCS Wrappers function vcs_setup { - export GIT_WORK_TREE=$PKG_DIR/$1 - export GIT_DIR=$GIT_WORK_TREE/.git - export GIT_CONFIG=$GIT_DIR/config + cd GIT_WORK_TREE=$PKG_DIR/$1 } -function vcs_to_list { +function vcs_to_list ( vcs_setup $1 if [[ -d $PKG_DIR/$1/.git ]] { echo -n "$1 git " @@ -234,9 +232,9 @@ function vcs_to_list { } else { warn "No git repository found: $1\n" } -} +) -function vcs_add { +function vcs_add ( if [[ $(list_type $1) == git ]] { git clone "$PKG_ROOT/$1" vcs_setup $1 @@ -244,14 +242,14 @@ function vcs_add { } else { die "$1: Cannot handle repository format '$(list_type $1)'\n" } -} +) -function vcs_log { +function vcs_log ( vcs_setup $1 git log -} +) -function vcs_branch_is_master { +function vcs_branch_is_master ( vcs_setup $1 typeset IFS=$'\n' branch line for line in $(git branch); { @@ -263,9 +261,9 @@ function vcs_branch_is_master { " -> skipping repo, please fix manually\n" return 1 } -} +) -function vcs_pull { +function vcs_pull ( vcs_setup $1 if ((GIT_USE_ORIGIN)) { # the package might be newly created and not have an origin yet @@ -274,9 +272,9 @@ function vcs_pull { } else { vcs_branch_is_master $1 && git pull $PKG_ROOT/${PWD:t} master } -} +) -function vcs_push { +function vcs_push ( vcs_setup $1 if ((GIT_USE_ORIGIN)) { # see above @@ -285,20 +283,20 @@ function vcs_push { } else { vcs_branch_is_master $1 && git push $PKG_ROOT/${PWD:t} master } -} +) -function vcs_status { +function vcs_status ( vcs_setup $1 git status -} +) -function vcs_fix_origin { +function vcs_fix_origin ( vcs_setup $1 if [[ ! -r $GIT_DIR/remotes/origin && ! -r $GIT_DIR/refs/remotes/origin/HEAD ]] { fgrep -q '[remote "origin"]' $GIT_DIR/config || git remote add origin $PKG_ROOT/$1 } -} +) ## List stuff -- cgit v1.2.3