API updates for status.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
diff --git a/include/git2/status.h b/include/git2/status.h
index 8c59d76..c6926f3 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -47,6 +47,18 @@ typedef enum {
} git_status_t;
/**
+ * Function pointer to receive status on individual files
+ *
+ * `path` is the relative path to the file from the root of the repository.
+ *
+ * `status_flags` is a combination of `git_status_t` values that apply.
+ *
+ * `payload` is the value you passed to the foreach function as payload.
+ */
+typedef int (*git_status_cb)(
+ const char *path, unsigned int status_flags, void *payload);
+
+/**
* Gather file statuses and run a callback for each one.
*
* The callback is passed the path of the file, the status (a combination of
@@ -63,7 +75,7 @@ typedef enum {
*/
GIT_EXTERN(int) git_status_foreach(
git_repository *repo,
- int (*callback)(const char *, unsigned int, void *),
+ git_status_cb callback,
void *payload);
/**
@@ -146,9 +158,10 @@ typedef enum {
* `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags.
*/
typedef struct {
+ unsigned int version;
git_status_show_t show;
- unsigned int flags;
- git_strarray pathspec;
+ unsigned int flags;
+ git_strarray pathspec;
} git_status_options;
/**
@@ -168,7 +181,7 @@ typedef struct {
GIT_EXTERN(int) git_status_foreach_ext(
git_repository *repo,
const git_status_options *opts,
- int (*callback)(const char *, unsigned int, void *),
+ git_status_cb callback,
void *payload);
/**
diff --git a/src/status.c b/src/status.c
index 4684172..c7dea2c 100644
--- a/src/status.c
+++ b/src/status.c
@@ -78,7 +78,7 @@ static unsigned int workdir_delta2status(git_delta_t workdir_status)
}
typedef struct {
- int (*cb)(const char *, unsigned int, void *);
+ git_status_cb cb;
void *payload;
} status_user_callback;
@@ -104,7 +104,7 @@ static int status_invoke_cb(
int git_status_foreach_ext(
git_repository *repo,
const git_status_options *opts,
- int (*cb)(const char *, unsigned int, void *),
+ git_status_cb cb,
void *payload)
{
int err = 0;
@@ -178,7 +178,7 @@ cleanup:
int git_status_foreach(
git_repository *repo,
- int (*callback)(const char *, unsigned int, void *),
+ git_status_cb callback,
void *payload)
{
git_status_options opts;