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.