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

Re: Make git-rev-tree obsolete

From
Linus Torvalds <torvalds@osdl.org>
Date
Aug 9, 2005, 02:09 UTC
Message-ID
<Pine.LNX.4.58.0508081858120.3258@g5.osdl.org>
In-Reply-To
<Pine.LNX.4.63.0508090222190.4076@wgmdd8.biozentrum.uni-wuerzburg.de>
On Tue, 9 Aug 2005, Johannes Schindelin wrote:
> 
> Junio remarked that Jeff's git-changes-script still uses git-rev-tree, and 
> therefore it should not be removed. This patch changes git-changes-script 
> over to git-rev-list:

It really should be totally rewritten, to take advantage of git-rev-list being able to terminate early. As it is, your conversion may work, and it may give the right results, but it will suck performance-wise for all the same reasons that git-rev-tree sucked: it will walk all the way down to the root of the tree(s).

Show 19 quoted lines
> --- git-changes-script.orig	Tue Aug  9 02:21:36 2005
> +++ git-changes-script	Tue Aug  9 02:20:53 2005
> @@ -85,14 +85,14 @@
>  	base=$(cat .git/HEAD) || exit 1
>  fi
>  
> -git-rev-tree $base | sort -rn  > ${tmpfile}.base
> +git-rev-list $base > ${tmpfile}.base
>  if [ -n "$remote" ]; then
>  	[ -d $remote/.git ] || exit 1
>  	if [ -z "$tobase" ]; then
>  		tobase=$(cat $remote/.git/HEAD) || exit 1
>  	fi
>  	pushd $remote > /dev/null
> -	git-rev-tree $tobase | sort -rn > ${tmpfile}.remote
> +	git-rev-list $tobase > ${tmpfile}.remote
>  	diff -u ${tmpfile}.base ${tmpfile}.remote | grep "^${diffsearch}[^${diffsearch}]" | cut -c 1- > ${tmpfile}.diff
>  	rm -f ${tmpfile}.base ${tmpfile}.remote
>  	mv ${tmpfile}.diff ${tmpfile}.base
It really should do something like
	#
	# Make sure we see objects in the remote directory
	#
	export GIT_ALTERNATE_OBJECT_DIRECTORIES=$remote/.git/objects
	#
	# Get the local SHA1
	#
	local_ref=$(git-rev-parse --verify $base^0) || exit
	#
	# Get the remote SHA1
	#
	remote_ref=$(GIT_DIR="$remote/.git" git-rev-parse --verify $tobase^0) || exit
	#
	# Ok, let it rip..
	#
	git log $remote_ref..$local_ref

to do a proper search of objects that are in $local but not in $remote, without having to traverse all the way down to the root for both.

		Linus
Previous: Johannes SchindelinNext: Junio C Hamano
Message 2 of 6 in “Make git-rev-tree obsolete”
  1. Johannes SchindelinAug 9, 2005
  2. Linus TorvaldsAug 9, 2005
  3. Junio C HamanoAug 9, 2005
  4. Jeff GarzikAug 9, 2005
  5. Johannes SchindelinAug 9, 2005
  6. Petr BaudisAug 11, 2005

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.