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

Re: [PATCH v2] Remove useless uses of cat, and replace with filename arguments or redirection

From
Josh Triplett <josh@freedesktop.org>
Date
Jun 7, 2007, 02:23 UTC
Message-ID
<46676C35.60406@freedesktop.org>
In-Reply-To
<7vsl94sego.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 25 quoted lines
> Josh Triplett <josh@freedesktop.org> writes:
>> Replace all uses of cat that do nothing other than read a single file.  In the
>> case of git-quilt-import, this occurs once per patch.
>>
>> Signed-off-by: Josh Triplett <josh@freedesktop.org>
>> ---
>>
>> This revised version fixes a bug caught by Stephen Rothwell: the output of wc
>> -l changes when it has a filename on the command line.  The same bug occurred
>> in one other place as well.
> 
> Hmph...
> 
>> diff --git a/git-filter-branch.sh b/git-filter-branch.sh
>> index 0c8a7df..346cf3f 100644
>> --- a/git-filter-branch.sh
>> +++ b/git-filter-branch.sh
>> @@ -333,7 +333,7 @@ for commit in $unchanged; do
>>  done
>>  
>>  git-rev-list --reverse --topo-order $srcbranch --not $unchanged >../revs
>> -commits=$(cat ../revs | wc -l | tr -d " ")
>> +commits=$(wc -l ../revs | tr -d -c 0-9)
> 
> ... and left unfixed ;-)?

No, just fixed differently. :) Note the change to the tr invocation: delete everything other than digits.

- Josh Triplett
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 7 in “Remove useless uses of cat, and replace with filename arguments or redirection”
  1. Remove useless uses of cat, and replace with filename arguments or redirectionJosh Triplett, Jun 6, 2007
  2. Junio C HamanoJun 7, 2007
  3. Josh TriplettJun 7, 2007
  4. Junio C HamanoJun 7, 2007
  5. Johannes SchindelinJun 7, 2007
  6. Martin LanghoffJun 8, 2007
  7. Johannes SchindelinJun 8, 2007

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.