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

Re: [PATCH Cogito] Fix cg-log -f behavior

From
Junio C Hamano <junkio@cox.net>
Date
May 26, 2005, 21:11 UTC
Message-ID
<7voeaxae0r.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1117139740.12036.59.camel@pegasus>
>>>>> "MH" == Marcel Holtmann <marcel@holtmann.org> writes:
MH> Hi Junio,
>> Doesn't that still break one-tree case (i.e. [ -z $tree2 ])?
MH> I am not sure, because I never tried it. Does it use a different format?

I am not a Cogito user, but I am a bit wondering if you have read what is around what you are modifying.

	# List all files for for the initial commit
	if [ -z $tree2 ]; then
		list_cmd="git-ls-tree $tree1"
	else
		list_cmd="git-diff-tree -r $tree1 $tree2"
	fi
	echo
	$list_cmd | while read modes type sha1s file; do

The code you changed is fed by either git-ls-tree or git-diff-tree, depending on whether you are talking about initial commit. git-ls-tree gives "mode type sha1 file".

This is why I asked Linus about a slight format change for git-ls-tree (and git-ls-files) this morning.

Currently, there are three incompatible format floating around.
  - diff-* brothers show the metadata (separated internally with
    SP), TAB, and path.  If it is a rename diff, another TAB and
    path follow them.
  - ls-tree gives everything with TAB separated.
  - ls-files gives everything with SP separated.

The suggestion I made this morning is to make ls-tree and ls-files use SP inside metadata and TAB before path. If we can agree on that is the way to go, then the output from these commands would become:

  - diff-* brothers:
    mode SP mode SP sha1 SP sha1 SP status TAB path [ TAB path ]
  - ls-tree:
    mode SP kind SP sha1 TAB path
  - ls-files --stage :
    mode SP sha1 SP stage TAB path

What this means is the above piece of code can now be rewritten to parse with something like this, and it does not matter what command you have upstream:

	echo
	# List all files for for the initial commit
	if [ -z $tree2 ]; then
        	git-ls-tree "$tree1"
	else
		git-diff-tree -r "$tree1" "$tree2"
	fi |
        cut -f2 |
	while read file; do
            ...

Note that the above code is totally untested. I do not use "cut" myself and I am writing this in my e-mail buffer.

Previous: Marcel HoltmannNext: Marcel Holtmann
Message 4 of 7 in “Fix cg-log -f behavior”
  1. Fix cg-log -f behaviorMarcel Holtmann, May 26, 2005
  2. Junio C HamanoMay 26, 2005
  3. Marcel HoltmannMay 26, 2005
  4. Junio C HamanoMay 26, 2005
  5. Marcel HoltmannMay 26, 2005
  6. Make ls-* output consistent with diff-* output format.Junio C Hamano, May 26, 2005
  7. Linus TorvaldsMay 26, 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.