Fix cg-log -f behavior
PATCH 1/1 Fix cg-log -f behavior
Hi Petr,
the attached patch fixes the wrong behavior when calling cg-log -f. The output format of git-diff-tree has changed and so we need to adapt to that to be able to show the file list again.
Regards
Marcel
cg-log (mode:100755) +1 -1
@@ -78,7 +78,7 @@ list_cmd="git-diff-tree -r $tree1 $tree2" fi echo - $list_cmd | while read modes type sha1s file; do + $list_cmd | while read mode1 mode2 sha1a sha1b status file; do echo -n "$sep" sep=", " if [ $(echo "$line$sep$file" | wc -c) -le 75 ]; then
Doesn't that still break one-tree case (i.e. [ -z $tree2 ])?
Hi Junio,
Quoted 1 line
Doesn't that still break one-tree case (i.e. [ -z $tree2 ])?
I am not sure, because I never tried it. Does it use a different format?
Regards
Marcel
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"MH" == Marcel Holtmann <[email protected]> writes:
MH> Hi Junio,
Quoted 1 line
Quoted 1 line
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.
Hi Junio,
Quoted 14 lines
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
Quoted 3 lines
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".
I assumed that both have the same output format.
Quoted 2 lines
This is why I asked Linus about a slight format change for git-ls-tree (and git-ls-files) this morning.
To what is it changing?
Regards
Marcel
PATCH 1/1 Make ls-* output consistent with diff-* output format.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"MH" == Marcel Holtmann <[email protected]> writes:
This is why I asked Linus about a slight format change for git-ls-tree (and git-ls-files) this morning.
MH> To what is it changing?
Linus, we await your decree ;-).
To save your time reading backissues of the thread, here is the summary of the problem this patch addresses:
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.
------------
Use SP as the column separator except the ones before path which uses TAB, to make the output format consistent across ls-* and diff-* commands.
---
ls-files.c | 2 ls-tree.c | 2 t/t0000-basic.sh | 46 ++++++++++---------- t/t1000-read-tree-m-3way.sh | 98 ++++++++++++++++++++++---------------------- t/t3100-ls-tree-restrict.sh | 40 ++++++++--------- 5 files changed, 94 insertions(+), 94 deletions(-)
ls-files.c +1 -1
@@ -262,7 +262,7 @@ static void show_files(void) tag_cached, ce->name, line_terminator); else - printf("%s%06o %s %d %s%c", + printf("%s%06o %s %d\t%s%c",ce_stage (ce) ? tag_unmerged : tag_cached, ntohl(ce->ce_mode),
ls-tree.c +1 -1
@@ -127,7 +127,7 @@ static void list_recursive(void *buffer,* print out the info */ if (!matches || (matched !=NULL && mtype ==0 )) { -printf ("%06o\t%s\t%s\t" , mode, +printf ("%06o %s %s\t" , mode,S_ISDIR (mode) ?"tree" :"blob" ,sha1_to_hex (sha1));print_path_prefix (&this_prefix);
t/t0000-basic.sh +23 -23
64 lines not on this page · raw message
t/t1000-read-tree-m-3way.sh +49 -49
109 lines not on this page · raw message
t/t3100-ls-tree-restrict.sh +20 -20
@@ -34,7 +34,7 @@ test_expect_success \ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" test_output () { - sed -e "s/ $_x40 / X /" <current >check + sed -e "s/ $_x40 / X /" <current >check diff -u expected check }
@@ -42,9 +42,9 @@ test_expect_success \ 'ls-tree plain' \ 'git-ls-tree $tree >current && cat >expected <<\EOF && -100644 blob X path0 -120000 blob X path1 -040000 tree X path2 +100644 blob X path0 +120000 blob X path1 +040000 tree X path2 EOF test_output'
@@ -52,13 +52,13 @@ test_expect_success \ 'ls-tree recursive' \ 'git-ls-tree -r $tree >current && cat >expected <<\EOF && -100644 blob X path0 -120000 blob X path1 -040000 tree X path2 -040000 tree X path2/baz -100644 blob X path2/baz/b -120000 blob X path2/bazbo -100644 blob X path2/foo +100644 blob X path0 +120000 blob X path1 +040000 tree X path2 +040000 tree X path2/baz +100644 blob X path2/baz/b +120000 blob X path2/bazbo +100644 blob X path2/foo EOF test_output'
@@ -74,8 +74,8 @@ test_expect_success \ 'ls-tree filtered' \ 'git-ls-tree $tree path1 path0 >current && cat >expected <<\EOF && -100644 blob X path0 -120000 blob X path1 +100644 blob X path0 +120000 blob X path1 EOF test_output'
@@ -83,11 +83,11 @@ test_expect_success \ 'ls-tree filtered' \ 'git-ls-tree $tree path2 >current && cat >expected <<\EOF && -040000 tree X path2 -040000 tree X path2/baz -100644 blob X path2/baz/b -120000 blob X path2/bazbo -100644 blob X path2/foo +040000 tree X path2 +040000 tree X path2/baz +100644 blob X path2/baz/b +120000 blob X path2/bazbo +100644 blob X path2/foo EOF test_output'
@@ -95,8 +95,8 @@ test_expect_success \ 'ls-tree filtered' \ 'git-ls-tree $tree path2/baz >current && cat >expected <<\EOF && -040000 tree X path2/baz -100644 blob X path2/baz/b +040000 tree X path2/baz +100644 blob X path2/baz/b EOF test_output'
------------------------------------------------
Quoted 5 lines · Junio C Hamano
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:
Yes, let's make it so.
Linus