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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:36

Jeff King [off-list ref] writes:
I wish we could also get rid of the temporary index. It exists solely
for the side effect of removing the existing entries (otherwise, you get
both "foo" and "newsubdir/foo" in the resulting history). It would be
nice if there was some flag to update-index to say "before you do
anything, clear the existing index" (or I guess, "don't bother reading
the existing index"). And then result could look like:

  git filter-branch --index-filter '
    git ls-files -sz |
    perl -0pe "s{\t}{\tnewsubdir/}" |
    git update-index --from-scratch -z --index-info
  ' HEAD

which is IMHO much easier to read and understand.
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

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

From: Jeff King <hidden>
Date: 2016-06-15 22:53:36

On Mon, Apr 16, 2012 at 10:03:03AM -0700, Junio C Hamano wrote:
quoted
  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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help