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

Re: Filter-branch's "move tree to subdirectory" example fails with BSD sed?

From
Jeff King <peff@peff.net>
Date
Apr 16, 2012, 17:13 UTC
Message-ID
<20120416171307.GA11221@sigill.intra.peff.net>
In-Reply-To
<7vr4vnwqwo.fsf@alter.siamese.dyndns.org>
On Mon, Apr 16, 2012 at 10:03:03AM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> >   git filter-branch --index-filter '
> >     git ls-files -sz |
> >     perl -0pe "s{\t}{\tnewsubdir/}" |
> >     git update-index --from-scratch -z --index-info
> >   ' HEAD
> 
> Wouldn't "git read-tree --prefix=newsubdir/" suffice without the pipeline?
> I.e.
> 
>         git filter-branch --index-filter '
> 		rm -f "$GIT_INDEX_FILE"
>                 git read-tree --prefix=newsubdir/ "$GIT_COMMIT"
> 	' HEAD

Yeah, I think it does (at least it makes sense to me, and worked on a simple test case). I think I might use "git read-tree --empty" instead of "rm", as it is a little more obvious what is going on. But other than that, it is much more readable.

It is a slight shame not to show an "ls-files | update-index" example, because that is the most general form. But since this form is quite often cut-and-paste by people, I think simple is better here. If we want to show a more complex example, then we should add it separately.

-Peff
Previous: Junio C Hamano
Message 9 of 9 in “Filter-branch's "move tree to subdirectory" example fails with BSD sed?”
  1. Christopher TiwaldApr 14, 2012
  2. Johannes SixtApr 14, 2012
  3. Jeff KingApr 16, 2012
  4. 1/2 update-index: add --clear optionJeff King, Apr 16, 2012
  5. Christopher TiwaldApr 16, 2012
  6. Christopher TiwaldApr 17, 2012
  7. 2/2 docs/filter-branch: clean up newsubdir exampleJeff King, Apr 16, 2012
  8. Junio C HamanoApr 16, 2012
  9. Jeff KingApr 16, 2012

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.