Re: [PATCH v13 02/14] apply: rename and move opt constants to apply.h

2016-09-01 Thread Christian Couder
On Wed, Aug 31, 2016 at 11:46 PM, Stefan Beller  wrote:
> On Sat, Aug 27, 2016 at 11:45 AM, Christian Couder
>  wrote:
>>  extern int check_apply_state(struct apply_state *state, int force_apply);
>>
>
> With greater scope comes greater responsibility. Nit of the day:
> In case a reroll is necessary, consider putting a comment here.
> (What are these constants? what do they control? How/where do I use them?)
>
>> +#define APPLY_OPT_INACCURATE_EOF   (1<<0)
>> +#define APPLY_OPT_RECOUNT  (1<<1)

Ok I will reroll with some added comments.


Re: [PATCH v13 02/14] apply: rename and move opt constants to apply.h

2016-08-31 Thread Stefan Beller
On Sat, Aug 27, 2016 at 11:45 AM, Christian Couder
 wrote:
>  extern int check_apply_state(struct apply_state *state, int force_apply);
>

With greater scope comes greater responsibility. Nit of the day:
In case a reroll is necessary, consider putting a comment here.
(What are these constants? what do they control? How/where do I use them?)

> +#define APPLY_OPT_INACCURATE_EOF   (1<<0)
> +#define APPLY_OPT_RECOUNT  (1<<1)
> +


[PATCH v13 02/14] apply: rename and move opt constants to apply.h

2016-08-27 Thread Christian Couder
The constants for the "inaccurate-eof" and the "recount" options will
be used in both "apply.c" and "builtin/apply.c", so they need to go
into "apply.h", and therefore they need a name that is more specific
to the API they belong to.

Signed-off-by: Christian Couder 
---
 apply.h |  3 +++
 builtin/apply.c | 11 ---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/apply.h b/apply.h
index 53f09b5..ca1dcee 100644
--- a/apply.h
+++ b/apply.h
@@ -108,4 +108,7 @@ extern int init_apply_state(struct apply_state *state,
 extern void clear_apply_state(struct apply_state *state);
 extern int check_apply_state(struct apply_state *state, int force_apply);
 
+#define APPLY_OPT_INACCURATE_EOF   (1<<0)
+#define APPLY_OPT_RECOUNT  (1<<1)
+
 #endif
diff --git a/builtin/apply.c b/builtin/apply.c
index 429fe44..9c396bb 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4463,9 +4463,6 @@ static int write_out_results(struct apply_state *state, 
struct patch *list)
 
 static struct lock_file lock_file;
 
-#define INACCURATE_EOF (1<<0)
-#define RECOUNT(1<<1)
-
 /*
  * Try to apply a patch.
  *
@@ -4495,8 +4492,8 @@ static int apply_patch(struct apply_state *state,
int nr;
 
patch = xcalloc(1, sizeof(*patch));
-   patch->inaccurate_eof = !!(options & INACCURATE_EOF);
-   patch->recount =  !!(options & RECOUNT);
+   patch->inaccurate_eof = !!(options & APPLY_OPT_INACCURATE_EOF);
+   patch->recount =  !!(options & APPLY_OPT_RECOUNT);
nr = parse_chunk(state, buf.buf + offset, buf.len - offset, 
patch);
if (nr < 0) {
free_patch(patch);
@@ -4811,10 +4808,10 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix)
OPT__VERBOSE(_verbosely, N_("be verbose")),
OPT_BIT(0, "inaccurate-eof", ,
N_("tolerate incorrectly detected missing new-line at 
the end of file"),
-   INACCURATE_EOF),
+   APPLY_OPT_INACCURATE_EOF),
OPT_BIT(0, "recount", ,
N_("do not trust the line counts in the hunk headers"),
-   RECOUNT),
+   APPLY_OPT_RECOUNT),
{ OPTION_CALLBACK, 0, "directory", , N_("root"),
N_("prepend  to all filenames"),
0, apply_option_parse_directory },
-- 
2.9.2.770.g14ff7d2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html