Package: git-stuff
Version: 19-1
Severity: normal
Tags: patch upstream

Please, find attached below a patch for using shell parameter expansion whenever is possible in the scripts shipped with git-stuff. This avoids calling of external commands (echo, basename, cut, and awk) and should improve the performance of the scripts.

Rafael Laboissière

-- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (650, 'testing'), (600, 'unstable'), (550, 'stable'), (500, 'experimental') Architecture: i386 (i686)

Kernel: Linux 3.10-rc7-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages git-stuff depends on: ii debconf [debconf-2.0] 1.5.52 ii git 1:1.8.5.1-1

Versions of packages git-stuff recommends: ii cron 3.0pl1-124 ii git-buildpackage 0.6.6 ii mr 1.16 ii myrepos [mr] 1.20130826 ii pristine-tar 1.30

Versions of packages git-stuff suggests: pn git-extras <none> pn gitstats <none> pn irker <none>

-- debconf information: * git-repack-repositories/enable: false * git-stuff/bash-profile: false git-repack-repositories/directories: /srv/git git-repack-repositories/cron: @monthly git-stuff/title: git-repack-repositories/title:





>From f2985d5be2b6baf46524d4ed711dc0ee19442cb8 Mon Sep 17 00:00:00 2001
From: Rafael Laboissiere <raf...@laboissiere.net>
Date: Thu, 21 Nov 2013 01:28:04 +0100
Subject: [PATCH] Use shell parameter expansion whenever it is possible

This changes avoid the calling of external commands (echo, basename,
cut, and awk) and should improve the performance of the scripts.
---
 scripts/git-amend-all         | 2 +-
 scripts/git-checkout-branches | 2 +-
 scripts/git-commit-lazy       | 2 +-
 scripts/git-debian-add        | 2 +-
 scripts/git-upstream-retag    | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/scripts/git-amend-all b/scripts/git-amend-all
index 74e00d3..5aa3fb8 100755
--- a/scripts/git-amend-all
+++ b/scripts/git-amend-all
@@ -12,7 +12,7 @@ set -e
 # User is not in git repository
 if ! git branch > /dev/null 2>&1
 then
-	echo "E: '$(basename ${PWD})' - Not a Git repository."
+	echo "E: '${PWD##*/}' - Not a Git repository."
 	exit 1
 fi
 
diff --git a/scripts/git-checkout-branches b/scripts/git-checkout-branches
index 5cc932b..93a5c8f 100755
--- a/scripts/git-checkout-branches
+++ b/scripts/git-checkout-branches
@@ -24,7 +24,7 @@ _CURRENT_BRANCH="$(git branch | awk '/^\* / { print $2 }')"
 # Checkout all remote branches
 for _REMOTE_BRANCH in $(git branch -r | awk '{ print $1 }')
 do
-	_BRANCH_NAME="$(echo ${_REMOTE_BRANCH} | cut -d/ -f 2-)"
+	_BRANCH_NAME="${_REMOTE_BRANCH##*/}"
 
 	if [ "${_BRANCH_NAME}" != "HEAD" ]
 	then
diff --git a/scripts/git-commit-lazy b/scripts/git-commit-lazy
index 6eae686..22102ad 100755
--- a/scripts/git-commit-lazy
+++ b/scripts/git-commit-lazy
@@ -12,7 +12,7 @@ set -e
 # User is not in git repository
 if ! git branch > /dev/null 2>&1
 then
-	echo "E: '$(basename ${PWD})' - Not a Git repository."
+	echo "E: '${PWD##*/}' - Not a Git repository."
 	exit 1
 fi
 
diff --git a/scripts/git-debian-add b/scripts/git-debian-add
index 6b7fd23..b653514 100755
--- a/scripts/git-debian-add
+++ b/scripts/git-debian-add
@@ -26,7 +26,7 @@ if [ ! -d .git ]
 then
 	if ls .git* > /dev/null 2>&1
 	then
-		echo "W: '$(basename ${PWD})' - Not a Git repository but contains Git meta data."
+		echo "W: '${PWD##*/}' - Not a Git repository but contains Git meta data."
 	fi
 
 	git init --shared
diff --git a/scripts/git-upstream-retag b/scripts/git-upstream-retag
index 7719dbd..be333d5 100755
--- a/scripts/git-upstream-retag
+++ b/scripts/git-upstream-retag
@@ -18,5 +18,5 @@ Tag ()
 
 for TAG in $(git tag | grep ^upstream)
 do
-	Tag $(echo ${TAG} | awk -F/ '{ print $2 }')
+	Tag ${TAG#*/}
 done
-- 
1.8.4.2

Reply via email to