git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Petr Baudis <pasky@suse.cz>
Date
Mar 25, 2009, 21:24 UTC
Message-ID
<20090325212403.GU8940@machine.or.cz>
In-Reply-To
<1238015581-12801-1-git-send-email-newren@gmail.com>
On Wed, Mar 25, 2009 at 03:13:01PM -0600, newren@gmail.com wrote:
Show 6 quoted lines
> From: Elijah Newren <newren@gmail.com>
> 
> 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@gmail.com>
Almost-acked-by: Petr Baudis <pasky@suse.cz>
But:
>-i=0
>+git_filter_branch_count=0
Why branch_count? It counts commits, not branches, doesn't it?
> 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:
Some hints:
> $ git filter-branch --tree-filter '
>    for i in $(find . -type f); do
This won't work right if your filenames contain $IFS.
>      if ( file $i | grep "\btext\b" > /dev/null ); then

if [[ "$(file $i)" == *text* ]] might run noticeably faster (though is slightly less precise). Having a filename-keyed cache of file types even more so.

>        perl -i -ple "s/\\\$(Id|Date|Source|Header|CVSHeader|Author|Revision):[^\
> \$]*\\$/\\$\1\\$/" $i;

Using '\'' instead of " could save you quite a few backslashes in net count.

>      fi;
>    done ' -- --all
-- 
				Petr "Pasky" Baudis
The average, healthy, well-adjusted adult gets up at seven-thirty
in the morning feeling just terrible. -- Jean Kerr
Previous: newren@gmail.comNext: Elijah Newren
Message 2 of 6 in “git-filter-branch: avoid collisions with variables in eval'ed commands”
  1. git-filter-branch: avoid collisions with variables in eval'ed commandsnewren@gmail.com, Mar 25, 2009
  2. Petr BaudisMar 25, 2009
  3. Elijah NewrenMar 25, 2009
  4. newren@gmail.comMar 25, 2009
  5. Petr BaudisMar 25, 2009
  6. Junio C HamanoMar 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.