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

Re: [PATCH v2 2/2] tree:<depth>: skip some trees even when collecting omits

From
Matthew DeVore <matvore@comcast.net>
Date
Jan 9, 2019, 00:29 UTC
Message-ID
<8cb0dd36-4c49-228e-17ad-538fb377ffe4@comcast.net>
In-Reply-To
<20190108020034.23648-1-jonathantanmy@google.com>
Thank you for the review :) See below.
On 2019/01/07 18:00, Jonathan Tan wrote:
Show 21 quoted lines
>> -static void filter_trees_update_omits(
>> +static int filter_trees_update_omits(
>>   	struct object *obj,
>>   	struct filter_trees_depth_data *filter_data,
>>   	int include_it)
>>   {
>>   	if (!filter_data->omits)
>> -		return;
>> +		return 1;
>>   
>>   	if (include_it)
>> -		oidset_remove(filter_data->omits, &obj->oid);
>> +		return oidset_remove(filter_data->omits, &obj->oid);
>>   	else
>> -		oidset_insert(filter_data->omits, &obj->oid);
>> +		return oidset_insert(filter_data->omits, &obj->oid);
>>   }
> I think this function is getting too magical - if filter_data->omits is
> not set, we pretend that we have omitted the tree, because we want the
> same behavior when not needing omits and when the tree is omitted. Could
> this be done another way?

Yes, returning a manipulative lie when omits is NULL is rather confusing. So I changed it to this (interdiff):

+/* Returns 1 if the oid was in the omits set before it was invoked. */
  static int filter_trees_update_omits(
      struct object *obj,
      struct filter_trees_depth_data *filter_data,
      int include_it)
  {
      if (!filter_data->omits)
-        return 1;
+        return 0;
      if (include_it)
          return oidset_remove(filter_data->omits, &obj->oid);
@@ -177,7 +178,7 @@ static enum list_objects_filter_result 
filter_trees_depth(

              if (include_it)
                  filter_res = LOFR_DO_SHOW;
-            else if (!been_omitted)
+            else if (filter_data->omits && !been_omitted)
                  /*
                   * Must update omit information of children
                   * recursively; they have not been omitted yet.
Previous: MATTHEW DEVORENext: Junio C Hamano
Message 14 of 24 in “support for filtering trees and blobs based on depth”
  1. 0/2 support for filtering trees and blobs based on depthMatthew DeVore, Dec 10, 2018
  2. 1/2 list-objects-filter: teach tree:# how to handle >0Matthew DeVore, Dec 10, 2018
  3. Jonathan TanJan 8, 2019
  4. Matthew DeVoreJan 8, 2019
  5. Jonathan TanJan 8, 2019
  6. Junio C HamanoJan 8, 2019
  7. Jonathan TanJan 8, 2019
  8. Junio C HamanoJan 8, 2019
  9. MATTHEW DEVOREJan 9, 2019
  10. 2/2 tree:<depth>: skip some trees even when collecting omitsMatthew DeVore, Dec 10, 2018
  11. Jonathan TanJan 8, 2019
  12. Jonathan TanJan 8, 2019
  13. MATTHEW DEVOREJan 9, 2019
  14. Matthew DeVoreJan 9, 2019
  15. Junio C HamanoDec 11, 2018
  16. Matthew DeVoreJan 8, 2019
  17. 0/2 support for filtering trees and blobs based on depthMatthew DeVore, Jan 9, 2019
  18. 1/2 list-objects-filter: teach tree:# how to handle >0Matthew DeVore, Jan 9, 2019
  19. 2/2 tree:<depth>: skip some trees even when collecting omitsMatthew DeVore, Jan 9, 2019
  20. Jonathan TanJan 9, 2019
  21. Junio C HamanoJan 15, 2019
  22. Junio C HamanoJan 15, 2019
  23. Matthew DeVoreJan 17, 2019
  24. Junio C HamanoJan 17, 2019

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.