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

Re: [PATCH] filter-branch: Fix renaming a directory in the tree-filter

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Mar 31, 2008, 08:47 UTC
Message-ID
<47F0A523.80906@viscovery.net>
In-Reply-To
<7v3aq7mgly.fsf@gitster.siamese.dyndns.org>
Junio C Hamano schrieb:
Show 28 quoted lines
> For example, if you make it the invariant that $T contains the tree that
> matches the contents of the "$tempdir/t" work tree left in the previous
> round of filter-tree (and obviously you would want to do this only
> filter_tree is in effect), the "checkout-index + clean" would become a
> proper "branch switching".
> 
> This is obviously untested, and you would need to prime $T with an empty
> tree before entering the loop (but you could cheat by initializing T with
> an empty string), but it might make the code a bit more readable than the
> current mess.  I dunno.
> 
> 	if [ "$filter_tree" ]; then
> -		git checkout-index -f -u -a ||
> -			die "Could not checkout the index"
> -		# files that $commit removed are now still in the working tree;
> -		# remove them, else they would be added again
> -		git clean -d -q -f -x
> +		git read-tree -m -u $T $commit
> 		eval "$filter_tree" < /dev/null ||
> 			die "tree filter failed: $filter_tree"
> 
> -		(
> -			git diff-index -r --name-only $commit
> -			git ls-files --others
> -		) |
> -		git update-index --add --replace --remove --stdin
> +		git add -u && git add . && T=$(git write-tree)
> 	fi

Yes. But, ... uhm ..., I'm not that deep into these plumbings; I leave it to Dscho to comment on this.

-- Hannes
Previous: Junio C HamanoNext: Johannes Schindelin
Message 7 of 9 in “[bug] filter-branch skipping removed files”
  1. Jean-François VeilletteMar 30, 2008
  2. Jean-François VeilletteMar 30, 2008
  3. filter-branch: Test renaming directories in a tree-filterJohannes Sixt, Mar 31, 2008
  4. filter-branch: Fix renaming a directory in the tree-filterJohannes Sixt, Mar 31, 2008
  5. Johannes SixtMar 31, 2008
  6. Junio C HamanoMar 31, 2008
  7. Johannes SixtMar 31, 2008
  8. Johannes SchindelinMar 31, 2008
  9. Jean-François VeilletteMar 31, 2008

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.