[PATCH] git-filter-branch: avoid collisions with variables in eval'ed commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Elijah Newren <newren@xxxxxxxxx>

Avoid using simple variable names like 'i', since user commands are eval'ed
and may clash with and overwrite our values.

Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
---

I discovered this a few months ago, but apparently never got around to
sending it earlier.  Anyway, without this patch in a repository with a
file called 'world' I see the following behavior:

$ git filter-branch --tree-filter '
   for i in $(find . -type f); do
     if ( file $i | grep "\btext\b" > /dev/null ); then
       perl -i -ple "s/\\\$(Id|Date|Source|Header|CVSHeader|Author|Revision):[^\
\$]*\\$/\\$\1\\$/" $i;
     fi;
   done ' -- --all

Rewrite 7a78604e90b9debfaa6a755019b5d3df541abcba (1/6)/usr/bin/git-filter-branch
: line 249: ./world+1: syntax error: operand expected (error token is "./world+1
")


In case anyone is wondering: This isn't the right way to nuke CVS keywords.
It's a good start, but it'll miss a few files (particularly with older
versions of the 'file' program) due to some types such as 'FORTRAN program
source' not containing 'text'.  Also, it's incredibly slow to the point
that I dropped filter-branch entirely and wrote a 'git_fast_filter' helper
(serving as a pipe between fast-export and fast-import) that I'll soon be
making available.

 git-filter-branch.sh |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 20f6f51..5da63b1 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -272,10 +272,10 @@ test $commits -eq 0 && die "Found nothing to rewrite"
 
 # Rewrite the commits
 
-i=0
+git_filter_branch_count=0
 while read commit parents; do
-	i=$(($i+1))
-	printf "\rRewrite $commit ($i/$commits)"
+	git_filter_branch_count=$(($git_filter_branch_count+1))
+	printf "\rRewrite $commit ($git_filter_branch_count/$commits)"
 
 	case "$filter_subdir" in
 	"")
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux