Re: [PATCH 08/13] list-objects: add traverse_commit_list_filtered method

2017-10-25 Thread Jeff Hostetler



On 10/25/2017 12:24 AM, Jonathan Tan wrote:

On Tue, Oct 24, 2017 at 11:53 AM, Jeff Hostetler  wrote:

+void traverse_commit_list_filtered(
+   struct list_objects_filter_options *filter_options,
+   struct rev_info *revs,
+   show_commit_fn show_commit,
+   show_object_fn show_object,
+   list_objects_filter_map_foreach_cb print_omitted_object,
+   void *show_data);


So the function call chain, if we wanted a filtered traversal, is:
traverse_commit_list_filtered -> traverse_commit_list__sparse_path
(and friends, and each algorithm is in its own file) ->
traverse_commit_list_worker

This makes the implementation of each algorithm more easily understood
(since they are all in their own files), but also increases the number
of global functions and code files. I personally would combine the
traverse_commit_list__* functions into one file
(list-objects-filtered.c), make them static, and also put
traverse_commit_list_filtered in there, but I understand that other
people in the Git project may differ on this.



I'll do a round of refactoring to include your suggestion of
a default null filter.  Then with that see what collapsing this
looks like.

Thanks,
Jeff


Re: [PATCH 08/13] list-objects: add traverse_commit_list_filtered method

2017-10-24 Thread Jonathan Tan
On Tue, Oct 24, 2017 at 11:53 AM, Jeff Hostetler  wrote:
> +void traverse_commit_list_filtered(
> +   struct list_objects_filter_options *filter_options,
> +   struct rev_info *revs,
> +   show_commit_fn show_commit,
> +   show_object_fn show_object,
> +   list_objects_filter_map_foreach_cb print_omitted_object,
> +   void *show_data);

So the function call chain, if we wanted a filtered traversal, is:
traverse_commit_list_filtered -> traverse_commit_list__sparse_path
(and friends, and each algorithm is in its own file) ->
traverse_commit_list_worker

This makes the implementation of each algorithm more easily understood
(since they are all in their own files), but also increases the number
of global functions and code files. I personally would combine the
traverse_commit_list__* functions into one file
(list-objects-filtered.c), make them static, and also put
traverse_commit_list_filtered in there, but I understand that other
people in the Git project may differ on this.


[PATCH 08/13] list-objects: add traverse_commit_list_filtered method

2017-10-24 Thread Jeff Hostetler
From: Jeff Hostetler 

Add traverse_commit_list_filtered() wrapper around the various
filter methods using common data in object_filter_options.

Signed-off-by: Jeff Hostetler 
---
 list-objects.c | 45 +
 list-objects.h | 11 +++
 2 files changed, 56 insertions(+)

diff --git a/list-objects.c b/list-objects.c
index 3e86008..4ce2593 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -7,6 +7,9 @@
 #include "tree-walk.h"
 #include "revision.h"
 #include "list-objects.h"
+#include "list-objects-filter-blobs-none.h"
+#include "list-objects-filter-blobs-limit.h"
+#include "list-objects-filter-sparse.h"
 
 static void process_blob(struct rev_info *revs,
 struct blob *blob,
@@ -266,3 +269,45 @@ void traverse_commit_list(struct rev_info *revs,
show_commit, show_object, show_data,
NULL, NULL);
 }
+
+void traverse_commit_list_filtered(
+   struct list_objects_filter_options *filter_options,
+   struct rev_info *revs,
+   show_commit_fn show_commit,
+   show_object_fn show_object,
+   list_objects_filter_map_foreach_cb print_omitted_object,
+   void *show_data)
+{
+   switch (filter_options->choice) {
+   case LOFC_DISABLED:
+   traverse_commit_list(revs, show_commit, show_object, show_data);
+   return;
+
+   case LOFC_BLOB_NONE:
+   traverse_commit_list__blobs_none(
+   revs, show_commit, show_object, print_omitted_object,
+   show_data);
+   return;
+
+   case LOFC_BLOB_LIMIT:
+   traverse_commit_list__blobs_limit(
+   revs, show_commit, show_object, print_omitted_object,
+   show_data, filter_options->blob_limit_value);
+   return;
+
+   case LOFC_SPARSE_OID:
+   traverse_commit_list__sparse_oid(
+   revs, show_commit, show_object, print_omitted_object,
+   show_data, filter_options->sparse_oid_value);
+   return;
+
+   case LOFC_SPARSE_PATH:
+   traverse_commit_list__sparse_path(
+   revs, show_commit, show_object, print_omitted_object,
+   show_data, filter_options->sparse_path_value);
+   return;
+
+   default:
+   die("unspecified list-objects filter");
+   }
+}
diff --git a/list-objects.h b/list-objects.h
index 43a06fb..d14b0e0 100644
--- a/list-objects.h
+++ b/list-objects.h
@@ -1,6 +1,9 @@
 #ifndef LIST_OBJECTS_H
 #define LIST_OBJECTS_H
 
+#include "list-objects-filter-map.h"
+#include "list-objects-filter-options.h"
+
 typedef void (*show_commit_fn)(struct commit *, void *);
 typedef void (*show_object_fn)(struct object *, const char *, void *);
 void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, 
void *);
@@ -38,4 +41,12 @@ void traverse_commit_list_worker(
show_commit_fn, show_object_fn, void *show_data,
filter_object_fn filter, void *filter_data);
 
+void traverse_commit_list_filtered(
+   struct list_objects_filter_options *filter_options,
+   struct rev_info *revs,
+   show_commit_fn show_commit,
+   show_object_fn show_object,
+   list_objects_filter_map_foreach_cb print_omitted_object,
+   void *show_data);
+
 #endif /* LIST_OBJECTS_H */
-- 
2.9.3



[PATCH 08/13] list-objects: add traverse_commit_list_filtered method

2017-09-22 Thread Jeff Hostetler
From: Jeff Hostetler 

Add traverse_commit_list_filtered() wrapper around the various
filter methods using common data in object_filter_options.

Signed-off-by: Jeff Hostetler 
---
 list-objects.c | 34 ++
 list-objects.h | 11 +++
 2 files changed, 45 insertions(+)

diff --git a/list-objects.c b/list-objects.c
index 3e86008..0f063d9 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -7,6 +7,9 @@
 #include "tree-walk.h"
 #include "revision.h"
 #include "list-objects.h"
+#include "list-objects-filter-all.h"
+#include "list-objects-filter-large.h"
+#include "list-objects-filter-sparse.h"
 
 static void process_blob(struct rev_info *revs,
 struct blob *blob,
@@ -266,3 +269,34 @@ void traverse_commit_list(struct rev_info *revs,
show_commit, show_object, show_data,
NULL, NULL);
 }
+
+void traverse_commit_list_filtered(
+   struct object_filter_options *filter_options,
+   struct rev_info *revs,
+   show_commit_fn show_commit,
+   show_object_fn show_object,
+   oidset2_foreach_cb print_omitted_object,
+   void *show_data)
+{
+   if (filter_options->omit_all_blobs)
+   traverse_commit_list_omit_all_blobs(
+   revs, show_commit, show_object, print_omitted_object, 
show_data);
+
+   else if (filter_options->omit_large_blobs)
+   traverse_commit_list_omit_large_blobs(
+   revs, show_commit, show_object, print_omitted_object, 
show_data,
+   (int64_t)(uint64_t)filter_options->large_byte_limit);
+
+   else if (filter_options->use_blob)
+   traverse_commit_list_use_blob(
+   revs, show_commit, show_object, print_omitted_object, 
show_data,
+   _options->sparse_oid);
+
+   else if (filter_options->use_path)
+   traverse_commit_list_use_path(
+   revs, show_commit, show_object, print_omitted_object, 
show_data,
+   filter_options->sparse_value);
+
+   else
+   die("unspecified list-objects filter");
+}
diff --git a/list-objects.h b/list-objects.h
index 39fcbb5..a8acedc 100644
--- a/list-objects.h
+++ b/list-objects.h
@@ -1,6 +1,9 @@
 #ifndef LIST_OBJECTS_H
 #define LIST_OBJECTS_H
 
+#include "oidset2.h"
+#include "object-filter.h"
+
 typedef void (*show_commit_fn)(struct commit *, void *);
 typedef void (*show_object_fn)(struct object *, const char *, void *);
 void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, 
void *);
@@ -38,4 +41,12 @@ void traverse_commit_list_worker(
show_commit_fn, show_object_fn, void *show_data,
filter_object_fn filter, void *filter_data);
 
+void traverse_commit_list_filtered(
+   struct object_filter_options *filter_options,
+   struct rev_info *revs,
+   show_commit_fn show_commit,
+   show_object_fn show_object,
+   oidset2_foreach_cb print_omitted_object,
+   void *show_data);
+
 #endif
-- 
2.9.3