Add documentation for formatting options objectsize:disk
and deltabase.
Signed-off-by: Olga Telezhnaia
---
Documentation/git-for-each-ref.txt | 21 -
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-for-each-ref.txt
Add new formatting option objectsize:disk to know
exact size that object takes up on disk.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 26 +-
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index
Add new formatting option: deltabase.
If the object is stored as a delta on-disk, this expands
to the 40-hex sha1 of the delta base object.
Otherwise, expands to the null sha1 (40 zeroes).
We have same option in cat-file command.
Hopefully, in the end I will remove formatting code from
cat-file
Test new formatting atom.
Signed-off-by: Olga Telezhnaia
---
t/t6300-for-each-ref.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 97bfbee6e8d69..097fdf21fe196 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@
Test new formatting option deltabase.
Signed-off-by: Olga Telezhnaia
---
t/t6300-for-each-ref.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 097fdf21fe196..0ffd63071392e 100755
--- a/t/t6300-for-each-ref.sh
+++
Release item->value.
Initialize item->value->s dynamically and then release its resources.
Release some local variables.
Final goal of this patch is to reduce number of memory leaks.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 96 +---
1
Release memory from used_atom variable for reducing number of memory
leaks.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 4
1 file changed, 4 insertions(+)
diff --git a/ref-filter.c b/ref-filter.c
index e1bcb4ca8a197..70f1d13ab3beb 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@
Use ref_array_clear() to release memory instead of UNLEAK macros.
Signed-off-by: Olga Telezhnaia
---
builtin/ls-remote.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 1a25df7ee15b4..6a0cdec30d2d7 100644
---
Use ref_array_clear() to release memory instead of UNLEAK macros.
Signed-off-by: Olga Telezhnaia
---
builtin/ls-remote.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 1a25df7ee15b4..6a0cdec30d2d7 100644
---
Release item->value.
Initialize item->value->s dynamically and then release its resources.
Release some local variables.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 95 +---
1 file changed, 53 insertions(+), 42 deletions(-)
diff --git
Release memory from used_atom variable.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ref-filter.c b/ref-filter.c
index e1bcb4ca8a197..1b71d08a43a84 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1996,6 +1996,9 @@ void
Use oid_object_info_extended() to get object info instead of
read_object_file().
It will help to handle some requests faster (e.g., we do not need to
parse whole object if we need to know %(objectsize)).
It could also help us to add new atoms such as %(objectsize:disk)
and %(deltabase).
Initialize variable `eaten` before its using. We may initialize it in
parse_object_buffer(), but there are cases when we do not reach this
invocation.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ref-filter.c
Add the source of object data to prevent parsing of unneeded data.
The goal is to improve performance by avoiding calling expensive
functions when we don't need the information they provide
or when we could get it by using a cheaper function.
It is stored in valid_atoms because it depends on the
Inline get_obj(): it would be easier to edit the code
without this split.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 36 +++-
1 file changed, 11 insertions(+), 25 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index 8db7ca95b12c0..2b401a17c4689
Atoms like "align" or "end" do not have string representation.
Earlier we had to go and parse whole object with a hope that we
could fill their string representations. It's easier to fill them
with an empty string before we start to work with whole object.
It is important to mention that we fill
Use oid_object_info_extended() to get object info instead of
read_object_file().
It will help to handle some requests faster (e.g., we do not need to
parse whole object if we need to know %(objectsize)).
It could also help us to add new atoms such as %(objectsize:disk)
and %(deltabase).
Add the source of object data to prevent parsing of unneeded data.
The goal is to improve performance by avoiding calling expensive
functions when we don't need the information they provide
or when we could get it by using a cheaper function.
It is stored in valid_atoms because it depends on the
Inline get_obj(): it would be easier to edit the code
without this split.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 36 +++-
1 file changed, 11 insertions(+), 25 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index 27733ef013bed..f04169f0ea0e3
Atoms like "align" or "end" do not have string representation.
Earlier we had to go and parse whole object with a hope that we
could fill their string representations. It's easier to fill them
with an empty string before we start to work with whole object.
It is important to mention that we fill
Use oid_object_info_extended() to get object info instead of
read_object_file().
It will help to handle some requests faster (e.g., we do not need to
parse whole object if we need to know %(objectsize)).
It could also help us to add new atoms such as %(objectsize:disk)
and %(deltabase).
Add the source of object data to prevent parsing of unneeded data.
The goal is to improve performance by avoiding calling expensive
functions when we don't need the information they provide
or when we could get it by using a cheaper function.
It is stored in valid_atoms because it depends on the
Inline get_obj(): it would be easier to edit the code
without this split.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 36 +++-
1 file changed, 11 insertions(+), 25 deletions(-)
diff --git a/ref-filter.c b/ref-filter.c
index 27733ef013bed..f04169f0ea0e3
Atoms like "align" or "end" do not have string representation.
Earlier we had to go and parse whole object with a hope that we
could fill their string representations. It's easier to fill them
with an empty string before we start to work with whole object.
Signed-off-by: Olga Telezhnaia
---
Start using oid_object_info_extended(). So, if info from this function
is enough, we do not need to get and parse whole object (as it was before).
It's good for 3 reasons:
1. Some Git commands potentially will work faster.
2. It's much easier to add support for objectsize:disk and deltabase.
(I
Add %(objectsize:disk) support. It is still not working for deref:
I am thinking how to support it in a more elegant way.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 21 -
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git
Add tests for %(objectsize:disk) atom.
Signed-off-by: Olga Telezhnaia
---
t/t6300-for-each-ref.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 295d1475bde01..570bb606045d7 100755
---
Add %(deltabase) support. It is still not working for deref:
I am thinking how to support it in a more elegant way.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 12
1 file changed, 12 insertions(+)
diff --git a/ref-filter.c b/ref-filter.c
index
Start using oid_object_info_extended(). So, if info from this function
is enough, we do not need to get and parse whole object (as it was before).
It's good for 3 reasons:
1. Some Git commands potentially will work faster.
2. It's much easier to add support for objectsize:disk and deltabase.
(I
Add function strbuf_addf_ret() that helps to save a few lines of code.
Function expands fmt with placeholders, append resulting message
to strbuf *sb, and return error code ret.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 13 +
1 file changed, 13
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of parse_ref_filter_atom() by adding
strbuf parameter for error message.
The function returns the position in the used_atom[] array
(as before) for the given atom, or
This is a first step in removing die() calls from ref-filter
formatting logic, so that it could be used by other commands
that do not want to die during formatting process.
die() calls related to bugs in code will not be touched in this patch.
Everything would be the same for
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of handlers by adding return value
and strbuf parameter for errors.
Return value equals 0 upon success and -1 upon failure.
Upon failure, error message is appended to
Finish removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of get_ref_atom_value() and underlying functions
by adding return value and strbuf parameter for error message.
Return value equals 0 upon success and -1 upon failure.
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of parsers by adding return value and
strbuf parameter for error message.
Return value equals 0 upon success and -1 upon failure.
Upon failure, error message is
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of parse_ref_filter_atom() by adding
strbuf parameter for error message.
The function returns the position in the used_atom[] array
(as before) for the given atom, or
This is a first step in removing die() calls from ref-filter
formatting logic, so that it could be used by other commands
that do not want to die during formatting process.
die() calls related to bugs in code will not be touched in this patch.
Everything would be the same for
Add function strbuf_error() that helps to save few lines of code.
Function expands fmt with placeholders, append resulting error message
to strbuf *err, and return error code ret.
Signed-off-by: Olga Telezhnaia
---
strbuf.h | 13 +
1 file changed, 13
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of parsers by adding return value and
strbuf parameter for error message.
Return value equals 0 upon success and -1 upon failure.
Upon failure, error message is
Finish removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of get_ref_atom_value() and underlying functions
by adding return value and strbuf parameter for error message.
Return value equals 0 upon success and -1 upon failure.
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of handlers by adding return value
and strbuf parameter for errors.
Return value equals 0 upon success and -1 upon failure.
Upon failure, error message is appended to
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of parsers by adding return value and
strbuf parameter for error message.
Return value equals 0 upon success and -1 upon failure (there
could be more error codes
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of handlers by adding return value
and strbuf parameter for errors.
Return value equals 0 upon success and -1 upon failure (there could be
more error codes further if
Finish removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of get_ref_atom_value() and underlying functions
by adding return value and strbuf parameter for error message.
Return value equals 0 upon success and -1 upon failure
This is a first step in removing die() calls from ref-filter
formatting logic, so that it could be used by other commands
that do not want to die during formatting process.
die() calls related to bugs in code will not be touched in this patch.
Everything would be the same for
Continue removing die() calls from ref-filter formatting logic,
so that it could be used by other commands.
Change the signature of parse_ref_filter_atom() by adding
strbuf parameter for error message.
The function returns the position in the used_atom[] array
(as before) for the given atom, or
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of parsers by adding return value and
strbuf parameter for error message.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 177
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of handlers by adding return value
and strbuf parameter for errors.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 71
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of parse_ref_filter_atom() by adding
strbuf parameter for error message.
Return value means the same except negative values: they indicate
errors (previous version could return
Finish removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of get_ref_atom_value() and underlying functions
by adding return value and strbuf parameter for error message.
Some die() calls are left; all of them are not for users, but for
This is a first step in removing any printing from
ref-filter formatting logic, so that it could be more general.
Everything would be the same for show_ref_array_item() users.
But, if you want to deal with errors by your own, you could invoke
format_ref_array_item(). It means that you need to
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of parsers by adding return value and
strbuf parameter for error message.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 177
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of handlers by adding return value
and strbuf parameter for errors.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 71
This is a first step in removing any printing from
ref-filter formatting logic, so that it could be more general.
Everything would be the same for show_ref_array_item() users.
But, if you want to deal with errors by your own, you could invoke
format_ref_array_item(). It means that you need to
Finish removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of get_ref_atom_value() and underlying functions
by adding return value and strbuf parameter for error message.
It's important to mention that grab_objectname() returned 1 if
it
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of parse_ref_filter_atom() by changing return value,
adding previous return value to function parameter and also adding
strbuf parameter for error message.
Signed-off-by: Olga
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of parsers by adding return value and
strbuf parameter for error message.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 177
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of parse_ref_filter_atom() by changing return value,
adding previous return value to function parameter and also adding
strbuf parameter for error message.
Signed-off-by: Olga
This is a first step in removing any printing from
ref-filter formatting logic, so that it could be more general.
Everything would be the same for show_ref_array_item() users.
But, if you want to deal with errors by your own, you could invoke
format_ref_array_item(). It means that you need to
Continue removing any printing from ref-filter formatting logic,
so that it could be more general.
Change the signature of handlers by adding return value
and strbuf parameter for errors.
Signed-off-by: Olga Telezhnaia
---
ref-filter.c | 71
Get rid of goto command in ref-filter for better readability.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Make one function from 2 duplicate pieces and invoke it twice.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 45 +
1 file
Get rid of goto command in ref-filter for better readability.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Make one function from 2 duplicate pieces and invoke it twice.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 45 +
1 file
Remove mark_atom_in_object_info() and create same logic
in terms of ref-filter style.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 45
Split expand_atom() into 2 different functions,
mark_atom_in_object_info() prepares variable for further filling,
(new) expand_atom() creates resulting string.
Need that for further reusing of formatting logic from ref-filter.
Both functions will be step-by-step removed by the end of this patch.
Add some tests for new formatting atoms from ref-filter.
Some of new atoms are supported automatically,
some of them are expanded into empty string
(because they are useless for some types of objects),
some of them could be supported later in other patches.
Signed-off-by: Olga Telezhnaia
Update the docs for cat-file command. Some new formatting atoms added
because of reusing ref-filter code.
We do not support cat-file atoms in general formatting logic
(there is just the support for cat-file), that is why some of the atoms
are still explained in cat-file docs.
We need to move these
Move logic related to getting object info from cat-file to ref-filter.
It will help to reuse whole formatting logic from ref-filter further.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
Delete all items related to split_on_whitespace from ref-filter
and add new function for handling the logic.
Now cat-file could invoke that function to implementing its logic.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
cat-file options are now filled by general logic.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 33 -
1 file changed, 16 insertions(+),
Stop using valid_cat_file_atom, making the code more general.
Further commits will contain some tests, docs and
support of new features.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
Make valid_atom as a function parameter,
there could be another variable further.
Need that for further reusing of formatting logic in cat-file.c.
We do not need to allow users to pass their own valid_atom variable in
global functions like verify_ref_format() because in the end we want to
have
Reuse code from ref-filter to print resulting message.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
builtin/cat-file.c | 51 ---
Need that for further reusing of formatting logic in cat-file.
Have plans to get rid of using expand_data in cat-file at all,
and use it only in ref-filter for collecting, formatting and printing
needed data.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Make function global for further using in cat-file.
In the end of patch series this function becomes internal again,
so this is a part of middle step. cat-file would use more general
functions further.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Add tests for new formatting atoms: rest, deltabase, objectsize:disk.
rest means nothing and we expand it into empty string.
We need this atom for cat-file command.
Have plans to support deltabase and objectsize:disk further
(as it is done in cat-file), now also expand it to empty string.
Add return flag to format_ref_array_item(), show_ref_array_item(),
get_ref_array_info() and populate_value() for further using.
Need it to handle situations when item is broken but we can not invoke
die() because we are in batch mode and all items need to be processed.
Signed-off-by: Olga
Move logic related to skip_object_info into ref-filter,
so that cat-file does not use that field at all.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
builtin/cat-file.c | 7 +--
Rename objectname field to oid in struct ref_array_item.
Next commit will add objectname field that will contain
string representation of object id.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
Moving from using expand_data to ref_array_item structure.
That helps us to reuse functions from ref-filter easier.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
builtin/cat-file.c |
Move mark_atom_in_object_info() from cat-file to ref-filter and
start using it in verify_ref_format().
It also means that we start reusing verify_ref_format() in cat-file.
Start from simple moving of mark_atom_in_object_info(),
it would be removed later by integrating all needed processes into
Remove connection between expand_data variable
in cat-file and in ref-filter.
It will help further to get rid of using expand_data in cat-file.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
Remove populate_value() from header file. We needed that
for interim step, now it could be returned back.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 2 +-
Continue migrating formatting logic from cat-file to ref-filter.
Reuse parse_ref_filter_atom() for unifying all processes in ref-filter
and further removing of mark_atom_in_object_info().
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Get rid of goto command in ref-filter for better readability.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 9 +
1 file changed, 5 insertions(+), 4
Start using ref_format struct instead of simple char*.
Need that for further reusing of formatting logic from ref-filter.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
Remove connection between expand_data variable
in cat-file and in ref-filter.
It will help further to get rid of using expand_data in cat-file.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
Add is_cat flag, further it helps to get rid of cat_file_data field
in ref_format.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
builtin/cat-file.c | 1 +
ref-filter.c | 8
Moving from using expand_data to ref_array_item structure.
That helps us to reuse functions from ref-filter easier.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
builtin/cat-file.c |
Add tests for new formatting atoms: rest, deltabase, objectsize:disk.
rest means nothing and we expand it into empty string.
We need this atom for cat-file command.
Have plans to support deltabase and objectsize:disk further
(as it is done in cat-file), now also expand it to empty string.
Move mark_atom_in_object_info() from cat-file to ref-filter and
start using it in verify_ref_format().
It also means that we start reusing verify_ref_format() in cat-file.
Start from simple moving of mark_atom_in_object_info(),
it would be removed later by integrating all needed processes into
cat-file options are now filled by general logic.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 31 ++-
1 file changed, 14 insertions(+),
Remove populate_value() from header file. We needed that
for interim step, now it could be returned back.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
ref-filter.c | 2 +-
Make valid_atom as a function parameter,
there could be another variable further.
Need that for further reusing of formatting logic in cat-file.c.
We do not need to allow users to pass their own valid_atom variable in
global functions like verify_ref_format() because in the end we want to
have
Delete all items related to split_on_whitespace from ref-filter
and add new function for handling the logic.
Now cat-file could invoke that function to implementing its logic.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Reuse code from ref-filter to print resulting message.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
builtin/cat-file.c | 51 ---
Stop using valid_cat_file_atom, making the code more general.
Further commits will contain some tests, docs and
support of new features.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
Mentored by: Jeff King
---
Update the docs for cat-file command. Some new formatting atoms added
because of reusing ref-filter code.
We do not support cat-file atoms in general formatting logic
(there is just the support for cat-file), that is why some of the atoms
are still explained in cat-file docs.
We need to move these
Make function global for further using in cat-file.
In the end of patch series this function becomes internal again,
so this is a part of middle step. cat-file would use more general
functions further.
Signed-off-by: Olga Telezhnaia
Mentored-by: Christian Couder
1 - 100 of 180 matches
Mail list logo