Apply

2017-10-05 Thread Capital Finance

   UNSECURED BUSINESS/PERSONAL LOAN BY LOAN CAPITAL FINANCE
 - NO COLLATERAL
 - MINIMUM DOCUMENTATION
 - BUSINESS LOAN UP TO FIVE(5) MILLION US DOLLARS

   CONTACT US TODAY VIA EMAIL: financeloa...@hotmail.com


Apply Today

2016-08-30 Thread Loan Firm



Dear Sir/Madam,

We give out urgent loan for business and personal purpose with 3% intrest rate 
applicable to all amount.

Kindly get back to us via email: loa...@foxmail.com for further details on how 
to apply.


git apply --interactive

2013-05-06 Thread Mark Lodato
I'd love for "git apply" to have an equivalent to "git add -p".  (I'm
guessing it would be called --interactive since "git apply -p" is
taken and --patch would be confusing.)  Has anyone thought about this?

After taking a quick look at git-add--interactive.perl, it seems like
the main steps would be:
1) making sure the patch comes from a file and not stdin, since stdin
is required for the interactive input
2) collecting the input patch(es) and separating by output file
3) modifying parse_diff to accept these pre-split patches
4) coloring the patch

Mark
--
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


git-apply patches

2005-08-28 Thread Robert Fitzsimons
Here is a series of patches which fix some bugs in and add some new
command line options to git-apply.

[PATCH 1/9] Fix git patch header processing in git-apply.
[PATCH 2/9] Fix detection of files with only one line in git-apply.
[PATCH 3/9] Fix processing of a patch file which modifies the same file in 
git-apply.
[PATCH 4/9] Fix the procssing of multiple patch files with --check in git-apply.
[PATCH 5/9] New option --force-delete for git-apply.
[PATCH 6/9] New option --ignore-whitespace for git-apply.
[PATCH 7/9] New option --ignore-applied for git-apply.
[PATCH 8/9] New git-apply test cases for patches with mulitple fragments.
[PATCH 9/9] New git-apply test cases for scanning forwards and backwards.

Robert Fitzsimons
[EMAIL PROTECTED]

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


[PATCH v9 40/41] apply: refactor `git apply` option parsing

2016-07-30 Thread Christian Couder
Parsing `git apply` options can be useful to other commands that
want to call the libified apply functionality, because this way
they can easily pass some options from their own command line to
the libified apply functionality.

This will be used by `git am` in a following patch.

To make this possible, let's refactor the `git apply` option
parsing code into a new libified apply_parse_options() function.

Signed-off-by: Christian Couder 
---
 apply.c | 77 +
 apply.h |  4 +++
 builtin/apply.c | 74 +++---
 3 files changed, 84 insertions(+), 71 deletions(-)

diff --git a/apply.c b/apply.c
index 51985c1..a73889e 100644
--- a/apply.c
+++ b/apply.c
@@ -4890,3 +4890,80 @@ int apply_all_patches(struct apply_state *state,
return res;
return (res == -1 ? 1 : 128);
 }
+
+int apply_parse_options(int argc, const char **argv,
+   struct apply_state *state,
+   int *force_apply, int *options,
+   const char * const *apply_usage)
+{
+   struct option builtin_apply_options[] = {
+   { OPTION_CALLBACK, 0, "exclude", state, N_("path"),
+   N_("don't apply changes matching the given path"),
+   0, apply_option_parse_exclude },
+   { OPTION_CALLBACK, 0, "include", state, N_("path"),
+   N_("apply changes matching the given path"),
+   0, apply_option_parse_include },
+   { OPTION_CALLBACK, 'p', NULL, state, N_("num"),
+   N_("remove  leading slashes from traditional diff 
paths"),
+   0, apply_option_parse_p },
+   OPT_BOOL(0, "no-add", &state->no_add,
+   N_("ignore additions made by the patch")),
+   OPT_BOOL(0, "stat", &state->diffstat,
+   N_("instead of applying the patch, output diffstat for 
the input")),
+   OPT_NOOP_NOARG(0, "allow-binary-replacement"),
+   OPT_NOOP_NOARG(0, "binary"),
+   OPT_BOOL(0, "numstat", &state->numstat,
+   N_("show number of added and deleted lines in decimal 
notation")),
+   OPT_BOOL(0, "summary", &state->summary,
+   N_("instead of applying the patch, output a summary for 
the input")),
+   OPT_BOOL(0, "check", &state->check,
+   N_("instead of applying the patch, see if the patch is 
applicable")),
+   OPT_BOOL(0, "index", &state->check_index,
+   N_("make sure the patch is applicable to the current 
index")),
+   OPT_BOOL(0, "cached", &state->cached,
+       N_("apply a patch without touching the working tree")),
+   OPT_BOOL(0, "unsafe-paths", &state->unsafe_paths,
+   N_("accept a patch that touches outside the working 
area")),
+   OPT_BOOL(0, "apply", force_apply,
+   N_("also apply the patch (use with 
--stat/--summary/--check)")),
+   OPT_BOOL('3', "3way", &state->threeway,
+N_( "attempt three-way merge if a patch does not 
apply")),
+   OPT_FILENAME(0, "build-fake-ancestor", &state->fake_ancestor,
+   N_("build a temporary index based on embedded index 
information")),
+   /* Think twice before adding "--nul" synonym to this */
+   OPT_SET_INT('z', NULL, &state->line_termination,
+   N_("paths are separated with NUL character"), '\0'),
+   OPT_INTEGER('C', NULL, &state->p_context,
+   N_("ensure at least  lines of context 
match")),
+   { OPTION_CALLBACK, 0, "whitespace", state, N_("action"),
+   N_("detect new or modified lines that have whitespace 
errors"),
+   0, apply_option_parse_whitespace },
+   { OPTION_CALLBACK, 0, "ignore-space-change", state, NULL,
+   N_("ignore changes in whitespace when finding context"),
+   PARSE_OPT_NOARG, apply_option_parse_space_change },
+   { OPTION_CALLBACK, 0, "ignore-whitespace", state, NULL,
+   N_("ignore changes in whitespace when findi

[PATCH v10 39/40] apply: refactor `git apply` option parsing

2016-08-08 Thread Christian Couder
Parsing `git apply` options can be useful to other commands that
want to call the libified apply functionality, because this way
they can easily pass some options from their own command line to
the libified apply functionality.

This will be used by `git am` in a following patch.

To make this possible, let's refactor the `git apply` option
parsing code into a new libified apply_parse_options() function.

Doing that makes it possible to remove some functions definitions
from "apply.h" and make them static in "apply.c".

Helped-by: Ramsay Jones 
Signed-off-by: Christian Couder 
---
 apply.c | 103 +---
 apply.h |  18 +++---
 builtin/apply.c |  74 ++--
 3 files changed, 97 insertions(+), 98 deletions(-)

diff --git a/apply.c b/apply.c
index bf81b70..2ec2a8a 100644
--- a/apply.c
+++ b/apply.c
@@ -4730,16 +4730,16 @@ static int apply_patch(struct apply_state *state,
return res;
 }
 
-int apply_option_parse_exclude(const struct option *opt,
-  const char *arg, int unset)
+static int apply_option_parse_exclude(const struct option *opt,
+ const char *arg, int unset)
 {
struct apply_state *state = opt->value;
add_name_limit(state, arg, 1);
return 0;
 }
 
-int apply_option_parse_include(const struct option *opt,
-  const char *arg, int unset)
+static int apply_option_parse_include(const struct option *opt,
+ const char *arg, int unset)
 {
struct apply_state *state = opt->value;
add_name_limit(state, arg, 0);
@@ -4747,9 +4747,9 @@ int apply_option_parse_include(const struct option *opt,
return 0;
 }
 
-int apply_option_parse_p(const struct option *opt,
-const char *arg,
-int unset)
+static int apply_option_parse_p(const struct option *opt,
+   const char *arg,
+   int unset)
 {
struct apply_state *state = opt->value;
state->p_value = atoi(arg);
@@ -4757,8 +4757,8 @@ int apply_option_parse_p(const struct option *opt,
return 0;
 }
 
-int apply_option_parse_space_change(const struct option *opt,
-   const char *arg, int unset)
+static int apply_option_parse_space_change(const struct option *opt,
+  const char *arg, int unset)
 {
struct apply_state *state = opt->value;
if (unset)
@@ -4768,8 +4768,8 @@ int apply_option_parse_space_change(const struct option 
*opt,
return 0;
 }
 
-int apply_option_parse_whitespace(const struct option *opt,
- const char *arg, int unset)
+static int apply_option_parse_whitespace(const struct option *opt,
+const char *arg, int unset)
 {
struct apply_state *state = opt->value;
state->whitespace_option = arg;
@@ -4778,8 +4778,8 @@ int apply_option_parse_whitespace(const struct option 
*opt,
return 0;
 }
 
-int apply_option_parse_directory(const struct option *opt,
-const char *arg, int unset)
+static int apply_option_parse_directory(const struct option *opt,
+   const char *arg, int unset)
 {
struct apply_state *state = opt->value;
strbuf_reset(&state->root);
@@ -4893,3 +4893,80 @@ int apply_all_patches(struct apply_state *state,
return res;
return (res == -1 ? 1 : 128);
 }
+
+int apply_parse_options(int argc, const char **argv,
+   struct apply_state *state,
+   int *force_apply, int *options,
+   const char * const *apply_usage)
+{
+   struct option builtin_apply_options[] = {
+   { OPTION_CALLBACK, 0, "exclude", state, N_("path"),
+   N_("don't apply changes matching the given path"),
+   0, apply_option_parse_exclude },
+   { OPTION_CALLBACK, 0, "include", state, N_("path"),
+   N_("apply changes matching the given path"),
+   0, apply_option_parse_include },
+   { OPTION_CALLBACK, 'p', NULL, state, N_("num"),
+   N_("remove  leading slashes from traditional diff 
paths"),
+   0, apply_option_parse_p },
+   OPT_BOOL(0, "no-add", &state->no_add,
+   N_("ignore additions made by the patch")),
+   OPT_BOOL(0, "stat", &state->diffstat,
+   N_("instead of applying the patch, output diffstat for 
the input"))

[PATCH v12 11/13] apply: refactor `git apply` option parsing

2016-08-11 Thread Christian Couder
Parsing `git apply` options can be useful to other commands that
want to call the libified apply functionality, because this way
they can easily pass some options from their own command line to
the libified apply functionality.

This will be used by `git am` in a following patch.

To make this possible, let's refactor the `git apply` option
parsing code into a new libified apply_parse_options() function.

Doing that makes it possible to remove some functions definitions
from "apply.h" and make them static in "apply.c".

Helped-by: Ramsay Jones 
Signed-off-by: Christian Couder 
---
 apply.c | 103 +---
 apply.h |  18 +++---
 builtin/apply.c |  74 ++--
 3 files changed, 97 insertions(+), 98 deletions(-)

diff --git a/apply.c b/apply.c
index bf81b70..2ec2a8a 100644
--- a/apply.c
+++ b/apply.c
@@ -4730,16 +4730,16 @@ static int apply_patch(struct apply_state *state,
return res;
 }
 
-int apply_option_parse_exclude(const struct option *opt,
-  const char *arg, int unset)
+static int apply_option_parse_exclude(const struct option *opt,
+ const char *arg, int unset)
 {
struct apply_state *state = opt->value;
add_name_limit(state, arg, 1);
return 0;
 }
 
-int apply_option_parse_include(const struct option *opt,
-  const char *arg, int unset)
+static int apply_option_parse_include(const struct option *opt,
+ const char *arg, int unset)
 {
struct apply_state *state = opt->value;
add_name_limit(state, arg, 0);
@@ -4747,9 +4747,9 @@ int apply_option_parse_include(const struct option *opt,
return 0;
 }
 
-int apply_option_parse_p(const struct option *opt,
-const char *arg,
-int unset)
+static int apply_option_parse_p(const struct option *opt,
+   const char *arg,
+   int unset)
 {
struct apply_state *state = opt->value;
state->p_value = atoi(arg);
@@ -4757,8 +4757,8 @@ int apply_option_parse_p(const struct option *opt,
return 0;
 }
 
-int apply_option_parse_space_change(const struct option *opt,
-   const char *arg, int unset)
+static int apply_option_parse_space_change(const struct option *opt,
+  const char *arg, int unset)
 {
struct apply_state *state = opt->value;
if (unset)
@@ -4768,8 +4768,8 @@ int apply_option_parse_space_change(const struct option 
*opt,
return 0;
 }
 
-int apply_option_parse_whitespace(const struct option *opt,
- const char *arg, int unset)
+static int apply_option_parse_whitespace(const struct option *opt,
+const char *arg, int unset)
 {
struct apply_state *state = opt->value;
state->whitespace_option = arg;
@@ -4778,8 +4778,8 @@ int apply_option_parse_whitespace(const struct option 
*opt,
return 0;
 }
 
-int apply_option_parse_directory(const struct option *opt,
-const char *arg, int unset)
+static int apply_option_parse_directory(const struct option *opt,
+   const char *arg, int unset)
 {
struct apply_state *state = opt->value;
strbuf_reset(&state->root);
@@ -4893,3 +4893,80 @@ int apply_all_patches(struct apply_state *state,
return res;
return (res == -1 ? 1 : 128);
 }
+
+int apply_parse_options(int argc, const char **argv,
+   struct apply_state *state,
+   int *force_apply, int *options,
+   const char * const *apply_usage)
+{
+   struct option builtin_apply_options[] = {
+   { OPTION_CALLBACK, 0, "exclude", state, N_("path"),
+   N_("don't apply changes matching the given path"),
+   0, apply_option_parse_exclude },
+   { OPTION_CALLBACK, 0, "include", state, N_("path"),
+   N_("apply changes matching the given path"),
+   0, apply_option_parse_include },
+   { OPTION_CALLBACK, 'p', NULL, state, N_("num"),
+   N_("remove  leading slashes from traditional diff 
paths"),
+   0, apply_option_parse_p },
+   OPT_BOOL(0, "no-add", &state->no_add,
+   N_("ignore additions made by the patch")),
+   OPT_BOOL(0, "stat", &state->diffstat,
+   N_("instead of applying the patch, output diffstat for 
the input"))

[PATCH v13 12/14] apply: pass apply state to build_fake_ancestor()

2016-08-27 Thread Christian Couder
To libify git apply functionality, we will need to read from a
different index file in get_current_sha1(). This index file will be
stored in "struct apply_state", so let's pass the state to
build_fake_ancestor() which will later pass it to get_current_sha1().

Signed-off-by: Christian Couder 
---
 apply.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/apply.c b/apply.c
index 2ec2a8a..276e4af 100644
--- a/apply.c
+++ b/apply.c
@@ -4042,7 +4042,7 @@ static int preimage_sha1_in_gitlink_patch(struct patch 
*p, unsigned char sha1[20
 }
 
 /* Build an index that contains the just the files needed for a 3way merge */
-static int build_fake_ancestor(struct patch *list, const char *filename)
+static int build_fake_ancestor(struct apply_state *state, struct patch *list)
 {
struct patch *patch;
struct index_state result = { NULL };
@@ -4089,12 +4089,13 @@ static int build_fake_ancestor(struct patch *list, 
const char *filename)
}
}
 
-   hold_lock_file_for_update(&lock, filename, LOCK_DIE_ON_ERROR);
+   hold_lock_file_for_update(&lock, state->fake_ancestor, 
LOCK_DIE_ON_ERROR);
res = write_locked_index(&result, &lock, COMMIT_LOCK);
discard_index(&result);
 
if (res)
-   return error("Could not write temporary index to %s", filename);
+   return error("Could not write temporary index to %s",
+state->fake_ancestor);
 
return 0;
 }
@@ -4709,7 +4710,7 @@ static int apply_patch(struct apply_state *state,
}
 
if (state->fake_ancestor &&
-   build_fake_ancestor(list, state->fake_ancestor)) {
+   build_fake_ancestor(state, list)) {
res = -128;
goto end;
}
-- 
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


[PATCH v13 11/14] apply: refactor `git apply` option parsing

2016-08-27 Thread Christian Couder
Parsing `git apply` options can be useful to other commands that
want to call the libified apply functionality, because this way
they can easily pass some options from their own command line to
the libified apply functionality.

This will be used by `git am` in a following patch.

To make this possible, let's refactor the `git apply` option
parsing code into a new libified apply_parse_options() function.

Doing that makes it possible to remove some functions definitions
from "apply.h" and make them static in "apply.c".

Helped-by: Ramsay Jones 
Signed-off-by: Christian Couder 
---
 apply.c | 103 +---
 apply.h |  18 +++---
 builtin/apply.c |  74 ++--
 3 files changed, 97 insertions(+), 98 deletions(-)

diff --git a/apply.c b/apply.c
index bf81b70..2ec2a8a 100644
--- a/apply.c
+++ b/apply.c
@@ -4730,16 +4730,16 @@ static int apply_patch(struct apply_state *state,
return res;
 }
 
-int apply_option_parse_exclude(const struct option *opt,
-  const char *arg, int unset)
+static int apply_option_parse_exclude(const struct option *opt,
+ const char *arg, int unset)
 {
struct apply_state *state = opt->value;
add_name_limit(state, arg, 1);
return 0;
 }
 
-int apply_option_parse_include(const struct option *opt,
-  const char *arg, int unset)
+static int apply_option_parse_include(const struct option *opt,
+ const char *arg, int unset)
 {
struct apply_state *state = opt->value;
add_name_limit(state, arg, 0);
@@ -4747,9 +4747,9 @@ int apply_option_parse_include(const struct option *opt,
return 0;
 }
 
-int apply_option_parse_p(const struct option *opt,
-const char *arg,
-int unset)
+static int apply_option_parse_p(const struct option *opt,
+   const char *arg,
+   int unset)
 {
struct apply_state *state = opt->value;
state->p_value = atoi(arg);
@@ -4757,8 +4757,8 @@ int apply_option_parse_p(const struct option *opt,
return 0;
 }
 
-int apply_option_parse_space_change(const struct option *opt,
-   const char *arg, int unset)
+static int apply_option_parse_space_change(const struct option *opt,
+  const char *arg, int unset)
 {
struct apply_state *state = opt->value;
if (unset)
@@ -4768,8 +4768,8 @@ int apply_option_parse_space_change(const struct option 
*opt,
return 0;
 }
 
-int apply_option_parse_whitespace(const struct option *opt,
- const char *arg, int unset)
+static int apply_option_parse_whitespace(const struct option *opt,
+const char *arg, int unset)
 {
struct apply_state *state = opt->value;
state->whitespace_option = arg;
@@ -4778,8 +4778,8 @@ int apply_option_parse_whitespace(const struct option 
*opt,
return 0;
 }
 
-int apply_option_parse_directory(const struct option *opt,
-const char *arg, int unset)
+static int apply_option_parse_directory(const struct option *opt,
+   const char *arg, int unset)
 {
struct apply_state *state = opt->value;
strbuf_reset(&state->root);
@@ -4893,3 +4893,80 @@ int apply_all_patches(struct apply_state *state,
return res;
return (res == -1 ? 1 : 128);
 }
+
+int apply_parse_options(int argc, const char **argv,
+   struct apply_state *state,
+   int *force_apply, int *options,
+   const char * const *apply_usage)
+{
+   struct option builtin_apply_options[] = {
+   { OPTION_CALLBACK, 0, "exclude", state, N_("path"),
+   N_("don't apply changes matching the given path"),
+   0, apply_option_parse_exclude },
+   { OPTION_CALLBACK, 0, "include", state, N_("path"),
+   N_("apply changes matching the given path"),
+   0, apply_option_parse_include },
+   { OPTION_CALLBACK, 'p', NULL, state, N_("num"),
+   N_("remove  leading slashes from traditional diff 
paths"),
+   0, apply_option_parse_p },
+   OPT_BOOL(0, "no-add", &state->no_add,
+   N_("ignore additions made by the patch")),
+   OPT_BOOL(0, "stat", &state->diffstat,
+   N_("instead of applying the patch, output diffstat for 
the input"))

[PATCH v14 38/41] apply: refactor `git apply` option parsing

2016-09-04 Thread Christian Couder
Parsing `git apply` options can be useful to other commands that
want to call the libified apply functionality, because this way
they can easily pass some options from their own command line to
the libified apply functionality.

This will be used by `git am` in a following patch.

To make this possible, let's refactor the `git apply` option
parsing code into a new libified apply_parse_options() function.

Doing that makes it possible to remove some functions definitions
from "apply.h" and make them static in "apply.c".

Helped-by: Ramsay Jones 
Signed-off-by: Christian Couder 
---
 apply.c | 103 +---
 apply.h |  18 +++---
 builtin/apply.c |  74 ++--
 3 files changed, 97 insertions(+), 98 deletions(-)

diff --git a/apply.c b/apply.c
index 27baf0e..2dad0db 100644
--- a/apply.c
+++ b/apply.c
@@ -4730,16 +4730,16 @@ static int apply_patch(struct apply_state *state,
return res;
 }
 
-int apply_option_parse_exclude(const struct option *opt,
-  const char *arg, int unset)
+static int apply_option_parse_exclude(const struct option *opt,
+ const char *arg, int unset)
 {
struct apply_state *state = opt->value;
add_name_limit(state, arg, 1);
return 0;
 }
 
-int apply_option_parse_include(const struct option *opt,
-  const char *arg, int unset)
+static int apply_option_parse_include(const struct option *opt,
+ const char *arg, int unset)
 {
struct apply_state *state = opt->value;
add_name_limit(state, arg, 0);
@@ -4747,9 +4747,9 @@ int apply_option_parse_include(const struct option *opt,
return 0;
 }
 
-int apply_option_parse_p(const struct option *opt,
-const char *arg,
-int unset)
+static int apply_option_parse_p(const struct option *opt,
+   const char *arg,
+   int unset)
 {
struct apply_state *state = opt->value;
state->p_value = atoi(arg);
@@ -4757,8 +4757,8 @@ int apply_option_parse_p(const struct option *opt,
return 0;
 }
 
-int apply_option_parse_space_change(const struct option *opt,
-   const char *arg, int unset)
+static int apply_option_parse_space_change(const struct option *opt,
+  const char *arg, int unset)
 {
struct apply_state *state = opt->value;
if (unset)
@@ -4768,8 +4768,8 @@ int apply_option_parse_space_change(const struct option 
*opt,
return 0;
 }
 
-int apply_option_parse_whitespace(const struct option *opt,
- const char *arg, int unset)
+static int apply_option_parse_whitespace(const struct option *opt,
+const char *arg, int unset)
 {
struct apply_state *state = opt->value;
state->whitespace_option = arg;
@@ -4778,8 +4778,8 @@ int apply_option_parse_whitespace(const struct option 
*opt,
return 0;
 }
 
-int apply_option_parse_directory(const struct option *opt,
-const char *arg, int unset)
+static int apply_option_parse_directory(const struct option *opt,
+   const char *arg, int unset)
 {
struct apply_state *state = opt->value;
strbuf_reset(&state->root);
@@ -4893,3 +4893,80 @@ int apply_all_patches(struct apply_state *state,
return res;
return (res == -1 ? 1 : 128);
 }
+
+int apply_parse_options(int argc, const char **argv,
+   struct apply_state *state,
+   int *force_apply, int *options,
+   const char * const *apply_usage)
+{
+   struct option builtin_apply_options[] = {
+   { OPTION_CALLBACK, 0, "exclude", state, N_("path"),
+   N_("don't apply changes matching the given path"),
+   0, apply_option_parse_exclude },
+   { OPTION_CALLBACK, 0, "include", state, N_("path"),
+   N_("apply changes matching the given path"),
+   0, apply_option_parse_include },
+   { OPTION_CALLBACK, 'p', NULL, state, N_("num"),
+   N_("remove  leading slashes from traditional diff 
paths"),
+   0, apply_option_parse_p },
+   OPT_BOOL(0, "no-add", &state->no_add,
+   N_("ignore additions made by the patch")),
+   OPT_BOOL(0, "stat", &state->diffstat,
+   N_("instead of applying the patch, output diffstat for 
the input"))

[PATCH v14 39/41] apply: pass apply state to build_fake_ancestor()

2016-09-04 Thread Christian Couder
To libify git apply functionality, we will need to read from a
different index file in get_current_sha1(). This index file will be
stored in "struct apply_state", so let's pass the state to
build_fake_ancestor() which will later pass it to get_current_sha1().

Signed-off-by: Christian Couder 
---
 apply.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/apply.c b/apply.c
index 2dad0db..f29387d 100644
--- a/apply.c
+++ b/apply.c
@@ -4042,7 +4042,7 @@ static int preimage_sha1_in_gitlink_patch(struct patch 
*p, unsigned char sha1[20
 }
 
 /* Build an index that contains the just the files needed for a 3way merge */
-static int build_fake_ancestor(struct patch *list, const char *filename)
+static int build_fake_ancestor(struct apply_state *state, struct patch *list)
 {
struct patch *patch;
struct index_state result = { NULL };
@@ -4089,12 +4089,13 @@ static int build_fake_ancestor(struct patch *list, 
const char *filename)
}
}
 
-   hold_lock_file_for_update(&lock, filename, LOCK_DIE_ON_ERROR);
+   hold_lock_file_for_update(&lock, state->fake_ancestor, 
LOCK_DIE_ON_ERROR);
res = write_locked_index(&result, &lock, COMMIT_LOCK);
discard_index(&result);
 
if (res)
-   return error("Could not write temporary index to %s", filename);
+   return error("Could not write temporary index to %s",
+state->fake_ancestor);
 
return 0;
 }
@@ -4709,7 +4710,7 @@ static int apply_patch(struct apply_state *state,
}
 
if (state->fake_ancestor &&
-   build_fake_ancestor(list, state->fake_ancestor)) {
+   build_fake_ancestor(state, list)) {
res = -128;
goto end;
}
-- 
2.10.0.41.g9df52c3



[PATCH/WIP 7/8] am: apply patch with git-apply

2015-05-27 Thread Paul Tan
Implement applying the patch to the index using git-apply.

Signed-off-by: Paul Tan 
---
 builtin/am.c | 50 +-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/builtin/am.c b/builtin/am.c
index 0b8a42d..7126df3 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -25,6 +25,18 @@ static int is_empty_file(const char *filename)
return !st.st_size;
 }
 
+/**
+ * Returns the first line of msg
+ */
+static const char *firstline(const char *msg)
+{
+   static struct strbuf sb = STRBUF_INIT;
+
+   strbuf_reset(&sb);
+   strbuf_add(&sb, msg, strchrnul(msg, '\n') - msg);
+   return sb.buf;
+}
+
 enum patch_format {
PATCH_FORMAT_UNKNOWN = 0,
PATCH_FORMAT_MBOX
@@ -503,6 +515,29 @@ static int parse_patch(struct am_state *state, const char 
*patch)
return 0;
 }
 
+/*
+ * Applies current patch with git-apply. Returns 0 on success, -1 otherwise.
+ */
+static int run_apply(const struct am_state *state)
+{
+   struct child_process cp = CHILD_PROCESS_INIT;
+
+   cp.git_cmd = 1;
+
+   argv_array_push(&cp.args, "apply");
+   argv_array_push(&cp.args, "--index");
+   argv_array_push(&cp.args, am_path(state, "patch"));
+
+   if (run_command(&cp))
+   return -1;
+
+   /* Reload index as git-apply will have modified it. */
+   discard_cache();
+   read_cache();
+
+   return 0;
+}
+
 /**
  * Applies all queued patches.
  */
@@ -520,7 +555,20 @@ static void am_run(struct am_state *state)
write_file(am_path(state, "final-commit"), 1, "%s", 
state->msg.buf);
write_author_script(state);
 
-   /* patch application not implemented yet */
+   printf_ln(_("Applying: %s"), firstline(state->msg.buf));
+
+   if (run_apply(state) < 0) {
+   int value;
+
+   printf_ln(_("Patch failed at %s %s"), msgnum(state),
+   firstline(state->msg.buf));
+
+   if (!git_config_get_bool("advice.amworkdir", &value) && 
!value)
+   printf_ln(_("The copy of the patch that failed 
is found in: %s"),
+   am_path(state, "patch"));
+
+   exit(128);
+   }
 
 next:
am_next(state);
-- 
2.1.4

--
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


[PATCH v4 08/44] builtin-am: apply patch with git-apply

2015-06-28 Thread Paul Tan
Implement applying the patch to the index using git-apply.

If a file is unchanged but stat-dirty, git-apply may erroneously fail to
apply patches, thinking that they conflict with a dirty working tree.

As such, since 2a6f08a (am: refresh the index at start and --resolved,
2011-08-15), git-am will refresh the index before applying patches.
Re-implement this behavior.

Helped-by: Junio C Hamano 
Signed-off-by: Paul Tan 
---

Notes:
v4

* Switch firstline() to linelen(), use .%s format specifier.

* Remove blank lines.

 builtin/am.c | 73 +++-
 1 file changed, 72 insertions(+), 1 deletion(-)

diff --git a/builtin/am.c b/builtin/am.c
index 2fbad5b..0762c70 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -10,6 +10,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "quote.h"
+#include "lockfile.h"
 
 /**
  * Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -42,6 +43,14 @@ static int strbuf_getline_crlf(struct strbuf *sb, FILE *fp)
return 0;
 }
 
+/**
+ * Returns the length of the first line of msg.
+ */
+static int linelen(const char *msg)
+{
+   return strchrnul(msg, '\n') - msg;
+}
+
 enum patch_format {
PATCH_FORMAT_UNKNOWN = 0,
PATCH_FORMAT_MBOX
@@ -561,6 +570,20 @@ static const char *msgnum(const struct am_state *state)
 }
 
 /**
+ * Refresh and write index.
+ */
+static void refresh_and_write_cache(void)
+{
+   static struct lock_file lock_file;
+
+   hold_locked_index(&lock_file, 1);
+   refresh_cache(REFRESH_QUIET);
+   if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
+   die(_("unable to write index file"));
+   rollback_lock_file(&lock_file);
+}
+
+/**
  * Parses `mail` using git-mailinfo, extracting its patch and authorship info.
  * state->msg will be set to the patch message. state->author_name,
  * state->author_email and state->author_date will be set to the patch author's
@@ -650,10 +673,35 @@ finish:
 }
 
 /**
+ * Applies current patch with git-apply. Returns 0 on success, -1 otherwise.
+ */
+static int run_apply(const struct am_state *state)
+{
+   struct child_process cp = CHILD_PROCESS_INIT;
+
+   cp.git_cmd = 1;
+
+   argv_array_push(&cp.args, "apply");
+   argv_array_push(&cp.args, "--index");
+   argv_array_push(&cp.args, am_path(state, "patch"));
+
+   if (run_command(&cp))
+   return -1;
+
+   /* Reload index as git-apply will have modified it. */
+   discard_cache();
+   read_cache();
+
+   return 0;
+}
+
+/**
  * Applies all queued mail.
  */
 static void am_run(struct am_state *state)
 {
+   refresh_and_write_cache();
+
while (state->cur <= state->last) {
const char *mail = am_path(state, msgnum(state));
 
@@ -666,7 +714,27 @@ static void am_run(struct am_state *state)
write_author_script(state);
write_commit_msg(state);
 
-   /* TODO: Patch application not implemented yet */
+   printf_ln(_("Applying: %.*s"), linelen(state->msg), state->msg);
+
+   if (run_apply(state) < 0) {
+   int advice_amworkdir = 1;
+
+   printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
+   linelen(state->msg), state->msg);
+
+   git_config_get_bool("advice.amworkdir", 
&advice_amworkdir);
+
+   if (advice_amworkdir)
+   printf_ln(_("The copy of the patch that failed 
is found in: %s"),
+   am_path(state, "patch"));
+
+   exit(128);
+   }
+
+   /*
+* TODO: After the patch has been applied to the index with
+* git-apply, we need to make commit as well.
+*/
 
 next:
am_next(state);
@@ -728,6 +796,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 
argc = parse_options(argc, argv, prefix, options, usage, 0);
 
+   if (read_index_preload(&the_index, NULL) < 0)
+   die(_("failed to read the index"));
+
if (am_in_progress(&state))
am_load(&state);
else {
-- 
2.5.0.rc0.76.gb2c6e93

--
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


[PATCH v5 08/44] builtin-am: apply patch with git-apply

2015-07-07 Thread Paul Tan
Implement applying the patch to the index using git-apply.

If a file is unchanged but stat-dirty, git-apply may erroneously fail to
apply patches, thinking that they conflict with a dirty working tree.

As such, since 2a6f08a (am: refresh the index at start and --resolved,
2011-08-15), git-am will refresh the index before applying patches.
Re-implement this behavior.

Helped-by: Junio C Hamano 
Signed-off-by: Paul Tan 
---
 builtin/am.c | 73 +++-
 1 file changed, 72 insertions(+), 1 deletion(-)

diff --git a/builtin/am.c b/builtin/am.c
index 4897857..9c7a6c8 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -10,6 +10,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "quote.h"
+#include "lockfile.h"
 
 /**
  * Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -42,6 +43,14 @@ static int strbuf_getline_crlf(struct strbuf *sb, FILE *fp)
return 0;
 }
 
+/**
+ * Returns the length of the first line of msg.
+ */
+static int linelen(const char *msg)
+{
+   return strchrnul(msg, '\n') - msg;
+}
+
 enum patch_format {
PATCH_FORMAT_UNKNOWN = 0,
PATCH_FORMAT_MBOX
@@ -561,6 +570,20 @@ static const char *msgnum(const struct am_state *state)
 }
 
 /**
+ * Refresh and write index.
+ */
+static void refresh_and_write_cache(void)
+{
+   static struct lock_file lock_file;
+
+   hold_locked_index(&lock_file, 1);
+   refresh_cache(REFRESH_QUIET);
+   if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
+   die(_("unable to write index file"));
+   rollback_lock_file(&lock_file);
+}
+
+/**
  * Parses `mail` using git-mailinfo, extracting its patch and authorship info.
  * state->msg will be set to the patch message. state->author_name,
  * state->author_email and state->author_date will be set to the patch author's
@@ -650,10 +673,35 @@ finish:
 }
 
 /**
+ * Applies current patch with git-apply. Returns 0 on success, -1 otherwise.
+ */
+static int run_apply(const struct am_state *state)
+{
+   struct child_process cp = CHILD_PROCESS_INIT;
+
+   cp.git_cmd = 1;
+
+   argv_array_push(&cp.args, "apply");
+   argv_array_push(&cp.args, "--index");
+   argv_array_push(&cp.args, am_path(state, "patch"));
+
+   if (run_command(&cp))
+   return -1;
+
+   /* Reload index as git-apply will have modified it. */
+   discard_cache();
+   read_cache();
+
+   return 0;
+}
+
+/**
  * Applies all queued mail.
  */
 static void am_run(struct am_state *state)
 {
+   refresh_and_write_cache();
+
while (state->cur <= state->last) {
const char *mail = am_path(state, msgnum(state));
 
@@ -666,7 +714,27 @@ static void am_run(struct am_state *state)
write_author_script(state);
write_commit_msg(state);
 
-   /* NEEDSWORK: Patch application not implemented yet */
+   printf_ln(_("Applying: %.*s"), linelen(state->msg), state->msg);
+
+   if (run_apply(state) < 0) {
+   int advice_amworkdir = 1;
+
+   printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
+   linelen(state->msg), state->msg);
+
+   git_config_get_bool("advice.amworkdir", 
&advice_amworkdir);
+
+   if (advice_amworkdir)
+   printf_ln(_("The copy of the patch that failed 
is found in: %s"),
+   am_path(state, "patch"));
+
+   exit(128);
+   }
+
+   /*
+* NEEDSWORK: After the patch has been applied to the index
+* with git-apply, we need to make commit as well.
+*/
 
 next:
am_next(state);
@@ -728,6 +796,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 
argc = parse_options(argc, argv, prefix, options, usage, 0);
 
+   if (read_index_preload(&the_index, NULL) < 0)
+   die(_("failed to read the index"));
+
if (am_in_progress(&state))
am_load(&state);
else {
-- 
2.5.0.rc1.76.gf60a929

--
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


[PATCH v6 08/45] builtin-am: apply patch with git-apply

2015-07-19 Thread Paul Tan
Implement applying the patch to the index using git-apply.

If a file is unchanged but stat-dirty, git-apply may erroneously fail to
apply patches, thinking that they conflict with a dirty working tree.

As such, since 2a6f08a (am: refresh the index at start and --resolved,
2011-08-15), git-am will refresh the index before applying patches.
Re-implement this behavior.

Helped-by: Junio C Hamano 
Signed-off-by: Paul Tan 
---

Notes:
v6

* refresh_and_write_cache(): use a heap-allocated lock_file instead of a
  static-allocated one to allow the function to be reentrant.

* refresh_and_write_cache(): remove the rollback_lock_file() -- since we
  ensure that the write_locked_index() succeeds there is no need to call
  it.

 builtin/am.c | 72 +++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/builtin/am.c b/builtin/am.c
index 63f0fa4..1f198e4 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -10,6 +10,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "quote.h"
+#include "lockfile.h"
 
 /**
  * Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -42,6 +43,14 @@ static int strbuf_getline_crlf(struct strbuf *sb, FILE *fp)
return 0;
 }
 
+/**
+ * Returns the length of the first line of msg.
+ */
+static int linelen(const char *msg)
+{
+   return strchrnul(msg, '\n') - msg;
+}
+
 enum patch_format {
PATCH_FORMAT_UNKNOWN = 0,
PATCH_FORMAT_MBOX
@@ -540,6 +549,19 @@ static const char *msgnum(const struct am_state *state)
 }
 
 /**
+ * Refresh and write index.
+ */
+static void refresh_and_write_cache(void)
+{
+   struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+
+   hold_locked_index(lock_file, 1);
+   refresh_cache(REFRESH_QUIET);
+   if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
+   die(_("unable to write index file"));
+}
+
+/**
  * Parses `mail` using git-mailinfo, extracting its patch and authorship info.
  * state->msg will be set to the patch message. state->author_name,
  * state->author_email and state->author_date will be set to the patch author's
@@ -629,10 +651,35 @@ finish:
 }
 
 /**
+ * Applies current patch with git-apply. Returns 0 on success, -1 otherwise.
+ */
+static int run_apply(const struct am_state *state)
+{
+   struct child_process cp = CHILD_PROCESS_INIT;
+
+   cp.git_cmd = 1;
+
+   argv_array_push(&cp.args, "apply");
+   argv_array_push(&cp.args, "--index");
+   argv_array_push(&cp.args, am_path(state, "patch"));
+
+   if (run_command(&cp))
+   return -1;
+
+   /* Reload index as git-apply will have modified it. */
+   discard_cache();
+   read_cache();
+
+   return 0;
+}
+
+/**
  * Applies all queued mail.
  */
 static void am_run(struct am_state *state)
 {
+   refresh_and_write_cache();
+
while (state->cur <= state->last) {
const char *mail = am_path(state, msgnum(state));
 
@@ -645,7 +692,27 @@ static void am_run(struct am_state *state)
write_author_script(state);
write_commit_msg(state);
 
-   /* NEEDSWORK: Patch application not implemented yet */
+   printf_ln(_("Applying: %.*s"), linelen(state->msg), state->msg);
+
+   if (run_apply(state) < 0) {
+   int advice_amworkdir = 1;
+
+   printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
+   linelen(state->msg), state->msg);
+
+   git_config_get_bool("advice.amworkdir", 
&advice_amworkdir);
+
+   if (advice_amworkdir)
+   printf_ln(_("The copy of the patch that failed 
is found in: %s"),
+   am_path(state, "patch"));
+
+   exit(128);
+   }
+
+   /*
+* NEEDSWORK: After the patch has been applied to the index
+* with git-apply, we need to make commit as well.
+*/
 
 next:
am_next(state);
@@ -707,6 +774,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 
argc = parse_options(argc, argv, prefix, options, usage, 0);
 
+   if (read_index_preload(&the_index, NULL) < 0)
+   die(_("failed to read the index"));
+
if (am_in_progress(&state))
am_load(&state);
else {
-- 
2.5.0.rc2.110.gb39b692

--
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


[PATCH v7 08/45] builtin-am: apply patch with git-apply

2015-08-04 Thread Paul Tan
Implement applying the patch to the index using git-apply.

If a file is unchanged but stat-dirty, git-apply may erroneously fail to
apply patches, thinking that they conflict with a dirty working tree.

As such, since 2a6f08a (am: refresh the index at start and --resolved,
2011-08-15), git-am will refresh the index before applying patches.
Re-implement this behavior.

Helped-by: Junio C Hamano 
Signed-off-by: Paul Tan 
---
 builtin/am.c | 72 +++-
 1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/builtin/am.c b/builtin/am.c
index 63f0fa4..1f198e4 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -10,6 +10,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "quote.h"
+#include "lockfile.h"
 
 /**
  * Returns 1 if the file is empty or does not exist, 0 otherwise.
@@ -42,6 +43,14 @@ static int strbuf_getline_crlf(struct strbuf *sb, FILE *fp)
return 0;
 }
 
+/**
+ * Returns the length of the first line of msg.
+ */
+static int linelen(const char *msg)
+{
+   return strchrnul(msg, '\n') - msg;
+}
+
 enum patch_format {
PATCH_FORMAT_UNKNOWN = 0,
PATCH_FORMAT_MBOX
@@ -540,6 +549,19 @@ static const char *msgnum(const struct am_state *state)
 }
 
 /**
+ * Refresh and write index.
+ */
+static void refresh_and_write_cache(void)
+{
+   struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
+
+   hold_locked_index(lock_file, 1);
+   refresh_cache(REFRESH_QUIET);
+   if (write_locked_index(&the_index, lock_file, COMMIT_LOCK))
+   die(_("unable to write index file"));
+}
+
+/**
  * Parses `mail` using git-mailinfo, extracting its patch and authorship info.
  * state->msg will be set to the patch message. state->author_name,
  * state->author_email and state->author_date will be set to the patch author's
@@ -629,10 +651,35 @@ finish:
 }
 
 /**
+ * Applies current patch with git-apply. Returns 0 on success, -1 otherwise.
+ */
+static int run_apply(const struct am_state *state)
+{
+   struct child_process cp = CHILD_PROCESS_INIT;
+
+   cp.git_cmd = 1;
+
+   argv_array_push(&cp.args, "apply");
+   argv_array_push(&cp.args, "--index");
+   argv_array_push(&cp.args, am_path(state, "patch"));
+
+   if (run_command(&cp))
+   return -1;
+
+   /* Reload index as git-apply will have modified it. */
+   discard_cache();
+   read_cache();
+
+   return 0;
+}
+
+/**
  * Applies all queued mail.
  */
 static void am_run(struct am_state *state)
 {
+   refresh_and_write_cache();
+
while (state->cur <= state->last) {
const char *mail = am_path(state, msgnum(state));
 
@@ -645,7 +692,27 @@ static void am_run(struct am_state *state)
write_author_script(state);
write_commit_msg(state);
 
-   /* NEEDSWORK: Patch application not implemented yet */
+   printf_ln(_("Applying: %.*s"), linelen(state->msg), state->msg);
+
+   if (run_apply(state) < 0) {
+   int advice_amworkdir = 1;
+
+   printf_ln(_("Patch failed at %s %.*s"), msgnum(state),
+   linelen(state->msg), state->msg);
+
+   git_config_get_bool("advice.amworkdir", 
&advice_amworkdir);
+
+   if (advice_amworkdir)
+   printf_ln(_("The copy of the patch that failed 
is found in: %s"),
+   am_path(state, "patch"));
+
+   exit(128);
+   }
+
+   /*
+* NEEDSWORK: After the patch has been applied to the index
+* with git-apply, we need to make commit as well.
+*/
 
 next:
am_next(state);
@@ -707,6 +774,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 
argc = parse_options(argc, argv, prefix, options, usage, 0);
 
+   if (read_index_preload(&the_index, NULL) < 0)
+   die(_("failed to read the index"));
+
if (am_in_progress(&state))
am_load(&state);
else {
-- 
2.5.0.280.gd88bd6e

--
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


[PATCH v9 35/41] apply: make it possible to silently apply

2016-07-30 Thread Christian Couder
This changes 'int apply_verbosely' into 'enum apply_verbosity', and
changes the possible values of the variable from a bool to
a tristate.

The previous 'false' state is changed into 'verbosity_normal'.
The previous 'true' state is changed into 'verbosity_verbose'.

The new added state is 'verbosity_silent'. It should prevent
anything to be printed on both stderr and stdout.

This is needed because `git am` wants to first call apply
functionality silently, if it can then fall back on 3-way merge
in case of error.

Printing on stdout, and calls to warning() or error() are not
taken care of in this patch, as that will be done in following
patches.

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

diff --git a/apply.c b/apply.c
index 7ccb6b5..e369f49 100644
--- a/apply.c
+++ b/apply.c
@@ -125,8 +125,11 @@ int check_apply_state(struct apply_state *state, int 
force_apply)
return error(_("--3way outside a repository"));
state->check_index = 1;
}
-   if (state->apply_with_reject)
-   state->apply = state->apply_verbosely = 1;
+   if (state->apply_with_reject) {
+   state->apply = 1;
+   if (state->apply_verbosity == verbosity_normal)
+   state->apply_verbosity = verbosity_verbose;
+   }
if (!force_apply && (state->diffstat || state->numstat || 
state->summary || state->check || state->fake_ancestor))
state->apply = 0;
if (state->check_index && is_not_gitdir)
@@ -1620,8 +1623,9 @@ static void record_ws_error(struct apply_state *state,
return;
 
err = whitespace_error_string(result);
-   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
-   state->patch_input_file, linenr, err, len, line);
+   if (state->apply_verbosity > verbosity_silent)
+   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
+   state->patch_input_file, linenr, err, len, line);
free(err);
 }
 
@@ -1816,7 +1820,7 @@ static int parse_single_patch(struct apply_state *state,
return error(_("new file %s depends on old contents"), 
patch->new_name);
if (0 < patch->is_delete && newlines)
return error(_("deleted file %s still has contents"), 
patch->old_name);
-   if (!patch->is_delete && !newlines && context)
+   if (!patch->is_delete && !newlines && context && state->apply_verbosity 
> verbosity_silent)
fprintf_ln(stderr,
   _("** warning: "
 "file %s becomes empty but is not deleted"),
@@ -2911,7 +2915,7 @@ static int apply_one_fragment(struct apply_state *state,
/* Ignore it, we already handled it */
break;
default:
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_normal)
error(_("invalid start of line: '%c'"), first);
applied_pos = -1;
goto out;
@@ -3026,7 +3030,7 @@ static int apply_one_fragment(struct apply_state *state,
state->apply = 0;
}
 
-   if (state->apply_verbosely && applied_pos != pos) {
+   if (state->apply_verbosity > verbosity_normal && applied_pos != 
pos) {
int offset = applied_pos - pos;
if (state->apply_in_reverse)
offset = 0 - offset;
@@ -3041,14 +3045,14 @@ static int apply_one_fragment(struct apply_state *state,
 * Warn if it was necessary to reduce the number
 * of context lines.
 */
-   if ((leading != frag->leading) ||
-   (trailing != frag->trailing))
+   if ((leading != frag->leading ||
+trailing != frag->trailing) && state->apply_verbosity > 
verbosity_silent)
fprintf_ln(stderr, _("Context reduced to (%ld/%ld)"
 " to apply fragment at %d"),
   leading, trailing, applied_pos+1);
update_image(state, img, applied_pos, &preimage, &postimage);
} else {
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_n

[PATCH v10 34/40] apply: make it possible to silently apply

2016-08-08 Thread Christian Couder
This changes 'int apply_verbosely' into 'enum apply_verbosity', and
changes the possible values of the variable from a bool to
a tristate.

The previous 'false' state is changed into 'verbosity_normal'.
The previous 'true' state is changed into 'verbosity_verbose'.

The new added state is 'verbosity_silent'. It should prevent
anything to be printed on both stderr and stdout.

This is needed because `git am` wants to first call apply
functionality silently, if it can then fall back on 3-way merge
in case of error.

Printing on stdout, and calls to warning() or error() are not
taken care of in this patch, as that will be done in following
patches.

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

diff --git a/apply.c b/apply.c
index 41a33d3..df85cbc 100644
--- a/apply.c
+++ b/apply.c
@@ -125,8 +125,11 @@ int check_apply_state(struct apply_state *state, int 
force_apply)
return error(_("--3way outside a repository"));
state->check_index = 1;
}
-   if (state->apply_with_reject)
-   state->apply = state->apply_verbosely = 1;
+   if (state->apply_with_reject) {
+   state->apply = 1;
+   if (state->apply_verbosity == verbosity_normal)
+   state->apply_verbosity = verbosity_verbose;
+   }
if (!force_apply && (state->diffstat || state->numstat || 
state->summary || state->check || state->fake_ancestor))
state->apply = 0;
if (state->check_index && is_not_gitdir)
@@ -1620,8 +1623,9 @@ static void record_ws_error(struct apply_state *state,
return;
 
err = whitespace_error_string(result);
-   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
-   state->patch_input_file, linenr, err, len, line);
+   if (state->apply_verbosity > verbosity_silent)
+   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
+   state->patch_input_file, linenr, err, len, line);
free(err);
 }
 
@@ -1816,7 +1820,7 @@ static int parse_single_patch(struct apply_state *state,
return error(_("new file %s depends on old contents"), 
patch->new_name);
if (0 < patch->is_delete && newlines)
return error(_("deleted file %s still has contents"), 
patch->old_name);
-   if (!patch->is_delete && !newlines && context)
+   if (!patch->is_delete && !newlines && context && state->apply_verbosity 
> verbosity_silent)
fprintf_ln(stderr,
   _("** warning: "
 "file %s becomes empty but is not deleted"),
@@ -2911,7 +2915,7 @@ static int apply_one_fragment(struct apply_state *state,
/* Ignore it, we already handled it */
break;
default:
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_normal)
error(_("invalid start of line: '%c'"), first);
applied_pos = -1;
goto out;
@@ -3026,7 +3030,7 @@ static int apply_one_fragment(struct apply_state *state,
state->apply = 0;
}
 
-   if (state->apply_verbosely && applied_pos != pos) {
+   if (state->apply_verbosity > verbosity_normal && applied_pos != 
pos) {
int offset = applied_pos - pos;
if (state->apply_in_reverse)
offset = 0 - offset;
@@ -3041,14 +3045,14 @@ static int apply_one_fragment(struct apply_state *state,
 * Warn if it was necessary to reduce the number
 * of context lines.
 */
-   if ((leading != frag->leading) ||
-   (trailing != frag->trailing))
+   if ((leading != frag->leading ||
+trailing != frag->trailing) && state->apply_verbosity > 
verbosity_silent)
fprintf_ln(stderr, _("Context reduced to (%ld/%ld)"
 " to apply fragment at %d"),
   leading, trailing, applied_pos+1);
update_image(state, img, applied_pos, &preimage, &postimage);
} else {
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_n

[PATCH v12 06/13] apply: make it possible to silently apply

2016-08-11 Thread Christian Couder
This changes 'int apply_verbosely' into 'enum apply_verbosity', and
changes the possible values of the variable from a bool to
a tristate.

The previous 'false' state is changed into 'verbosity_normal'.
The previous 'true' state is changed into 'verbosity_verbose'.

The new added state is 'verbosity_silent'. It should prevent
anything to be printed on both stderr and stdout.

This is needed because `git am` wants to first call apply
functionality silently, if it can then fall back on 3-way merge
in case of error.

Printing on stdout, and calls to warning() or error() are not
taken care of in this patch, as that will be done in following
patches.

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

diff --git a/apply.c b/apply.c
index 41a33d3..df85cbc 100644
--- a/apply.c
+++ b/apply.c
@@ -125,8 +125,11 @@ int check_apply_state(struct apply_state *state, int 
force_apply)
return error(_("--3way outside a repository"));
state->check_index = 1;
}
-   if (state->apply_with_reject)
-   state->apply = state->apply_verbosely = 1;
+   if (state->apply_with_reject) {
+   state->apply = 1;
+   if (state->apply_verbosity == verbosity_normal)
+   state->apply_verbosity = verbosity_verbose;
+   }
if (!force_apply && (state->diffstat || state->numstat || 
state->summary || state->check || state->fake_ancestor))
state->apply = 0;
if (state->check_index && is_not_gitdir)
@@ -1620,8 +1623,9 @@ static void record_ws_error(struct apply_state *state,
return;
 
err = whitespace_error_string(result);
-   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
-   state->patch_input_file, linenr, err, len, line);
+   if (state->apply_verbosity > verbosity_silent)
+   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
+   state->patch_input_file, linenr, err, len, line);
free(err);
 }
 
@@ -1816,7 +1820,7 @@ static int parse_single_patch(struct apply_state *state,
return error(_("new file %s depends on old contents"), 
patch->new_name);
if (0 < patch->is_delete && newlines)
return error(_("deleted file %s still has contents"), 
patch->old_name);
-   if (!patch->is_delete && !newlines && context)
+   if (!patch->is_delete && !newlines && context && state->apply_verbosity 
> verbosity_silent)
fprintf_ln(stderr,
   _("** warning: "
 "file %s becomes empty but is not deleted"),
@@ -2911,7 +2915,7 @@ static int apply_one_fragment(struct apply_state *state,
/* Ignore it, we already handled it */
break;
default:
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_normal)
error(_("invalid start of line: '%c'"), first);
applied_pos = -1;
goto out;
@@ -3026,7 +3030,7 @@ static int apply_one_fragment(struct apply_state *state,
state->apply = 0;
}
 
-   if (state->apply_verbosely && applied_pos != pos) {
+   if (state->apply_verbosity > verbosity_normal && applied_pos != 
pos) {
int offset = applied_pos - pos;
if (state->apply_in_reverse)
offset = 0 - offset;
@@ -3041,14 +3045,14 @@ static int apply_one_fragment(struct apply_state *state,
 * Warn if it was necessary to reduce the number
 * of context lines.
 */
-   if ((leading != frag->leading) ||
-   (trailing != frag->trailing))
+   if ((leading != frag->leading ||
+trailing != frag->trailing) && state->apply_verbosity > 
verbosity_silent)
fprintf_ln(stderr, _("Context reduced to (%ld/%ld)"
 " to apply fragment at %d"),
   leading, trailing, applied_pos+1);
update_image(state, img, applied_pos, &preimage, &postimage);
} else {
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_n

[PATCH v13 06/14] apply: make it possible to silently apply

2016-08-27 Thread Christian Couder
This changes 'int apply_verbosely' into 'enum apply_verbosity', and
changes the possible values of the variable from a bool to
a tristate.

The previous 'false' state is changed into 'verbosity_normal'.
The previous 'true' state is changed into 'verbosity_verbose'.

The new added state is 'verbosity_silent'. It should prevent
anything to be printed on both stderr and stdout.

This is needed because `git am` wants to first call apply
functionality silently, if it can then fall back on 3-way merge
in case of error.

Printing on stdout, and calls to warning() or error() are not
taken care of in this patch, as that will be done in following
patches.

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

diff --git a/apply.c b/apply.c
index 41a33d3..df85cbc 100644
--- a/apply.c
+++ b/apply.c
@@ -125,8 +125,11 @@ int check_apply_state(struct apply_state *state, int 
force_apply)
return error(_("--3way outside a repository"));
state->check_index = 1;
}
-   if (state->apply_with_reject)
-   state->apply = state->apply_verbosely = 1;
+   if (state->apply_with_reject) {
+   state->apply = 1;
+   if (state->apply_verbosity == verbosity_normal)
+   state->apply_verbosity = verbosity_verbose;
+   }
if (!force_apply && (state->diffstat || state->numstat || 
state->summary || state->check || state->fake_ancestor))
state->apply = 0;
if (state->check_index && is_not_gitdir)
@@ -1620,8 +1623,9 @@ static void record_ws_error(struct apply_state *state,
return;
 
err = whitespace_error_string(result);
-   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
-   state->patch_input_file, linenr, err, len, line);
+   if (state->apply_verbosity > verbosity_silent)
+   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
+   state->patch_input_file, linenr, err, len, line);
free(err);
 }
 
@@ -1816,7 +1820,7 @@ static int parse_single_patch(struct apply_state *state,
return error(_("new file %s depends on old contents"), 
patch->new_name);
if (0 < patch->is_delete && newlines)
return error(_("deleted file %s still has contents"), 
patch->old_name);
-   if (!patch->is_delete && !newlines && context)
+   if (!patch->is_delete && !newlines && context && state->apply_verbosity 
> verbosity_silent)
fprintf_ln(stderr,
   _("** warning: "
 "file %s becomes empty but is not deleted"),
@@ -2911,7 +2915,7 @@ static int apply_one_fragment(struct apply_state *state,
/* Ignore it, we already handled it */
break;
default:
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_normal)
error(_("invalid start of line: '%c'"), first);
applied_pos = -1;
goto out;
@@ -3026,7 +3030,7 @@ static int apply_one_fragment(struct apply_state *state,
state->apply = 0;
}
 
-   if (state->apply_verbosely && applied_pos != pos) {
+   if (state->apply_verbosity > verbosity_normal && applied_pos != 
pos) {
int offset = applied_pos - pos;
if (state->apply_in_reverse)
offset = 0 - offset;
@@ -3041,14 +3045,14 @@ static int apply_one_fragment(struct apply_state *state,
 * Warn if it was necessary to reduce the number
 * of context lines.
 */
-   if ((leading != frag->leading) ||
-   (trailing != frag->trailing))
+   if ((leading != frag->leading ||
+trailing != frag->trailing) && state->apply_verbosity > 
verbosity_silent)
fprintf_ln(stderr, _("Context reduced to (%ld/%ld)"
 " to apply fragment at %d"),
   leading, trailing, applied_pos+1);
update_image(state, img, applied_pos, &preimage, &postimage);
} else {
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_n

[PATCH v14 33/41] apply: make it possible to silently apply

2016-09-04 Thread Christian Couder
This changes 'int apply_verbosely' into 'enum apply_verbosity', and
changes the possible values of the variable from a bool to
a tristate.

The previous 'false' state is changed into 'verbosity_normal'.
The previous 'true' state is changed into 'verbosity_verbose'.

The new added state is 'verbosity_silent'. It should prevent
anything to be printed on both stderr and stdout.

This is needed because `git am` wants to first call apply
functionality silently, if it can then fall back on 3-way merge
in case of error.

Printing on stdout, and calls to warning() or error() are not
taken care of in this patch, as that will be done in following
patches.

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

diff --git a/apply.c b/apply.c
index 41a33d3..df85cbc 100644
--- a/apply.c
+++ b/apply.c
@@ -125,8 +125,11 @@ int check_apply_state(struct apply_state *state, int 
force_apply)
return error(_("--3way outside a repository"));
state->check_index = 1;
}
-   if (state->apply_with_reject)
-   state->apply = state->apply_verbosely = 1;
+   if (state->apply_with_reject) {
+   state->apply = 1;
+   if (state->apply_verbosity == verbosity_normal)
+   state->apply_verbosity = verbosity_verbose;
+   }
if (!force_apply && (state->diffstat || state->numstat || 
state->summary || state->check || state->fake_ancestor))
state->apply = 0;
if (state->check_index && is_not_gitdir)
@@ -1620,8 +1623,9 @@ static void record_ws_error(struct apply_state *state,
return;
 
err = whitespace_error_string(result);
-   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
-   state->patch_input_file, linenr, err, len, line);
+   if (state->apply_verbosity > verbosity_silent)
+   fprintf(stderr, "%s:%d: %s.\n%.*s\n",
+   state->patch_input_file, linenr, err, len, line);
free(err);
 }
 
@@ -1816,7 +1820,7 @@ static int parse_single_patch(struct apply_state *state,
return error(_("new file %s depends on old contents"), 
patch->new_name);
if (0 < patch->is_delete && newlines)
return error(_("deleted file %s still has contents"), 
patch->old_name);
-   if (!patch->is_delete && !newlines && context)
+   if (!patch->is_delete && !newlines && context && state->apply_verbosity 
> verbosity_silent)
fprintf_ln(stderr,
   _("** warning: "
 "file %s becomes empty but is not deleted"),
@@ -2911,7 +2915,7 @@ static int apply_one_fragment(struct apply_state *state,
/* Ignore it, we already handled it */
break;
default:
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_normal)
error(_("invalid start of line: '%c'"), first);
applied_pos = -1;
goto out;
@@ -3026,7 +3030,7 @@ static int apply_one_fragment(struct apply_state *state,
state->apply = 0;
}
 
-   if (state->apply_verbosely && applied_pos != pos) {
+   if (state->apply_verbosity > verbosity_normal && applied_pos != 
pos) {
int offset = applied_pos - pos;
if (state->apply_in_reverse)
offset = 0 - offset;
@@ -3041,14 +3045,14 @@ static int apply_one_fragment(struct apply_state *state,
 * Warn if it was necessary to reduce the number
 * of context lines.
 */
-   if ((leading != frag->leading) ||
-   (trailing != frag->trailing))
+   if ((leading != frag->leading ||
+trailing != frag->trailing) && state->apply_verbosity > 
verbosity_silent)
fprintf_ln(stderr, _("Context reduced to (%ld/%ld)"
 " to apply fragment at %d"),
   leading, trailing, applied_pos+1);
update_image(state, img, applied_pos, &preimage, &postimage);
} else {
-   if (state->apply_verbosely)
+   if (state->apply_verbosity > verbosity_n

[PATCH 26/83] builtin/apply: move 'apply' global into 'struct apply_state'

2016-04-24 Thread Christian Couder
Signed-off-by: Christian Couder 
---
 builtin/apply.c | 31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index b6d2343..699cabf 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -25,6 +25,7 @@ struct apply_state {
const char *prefix;
int prefix_length;
 
+   int apply;
int allow_overlap;
int apply_in_reverse;
int apply_with_reject;
@@ -71,7 +72,7 @@ static int newfd = -1;
 
 static int state_p_value = 1;
 static int p_value_known;
-static int apply = 1;
+
 static const char * const apply_usage[] = {
N_("git apply [] [...]"),
NULL
@@ -142,10 +143,11 @@ static void parse_ignorewhitespace_option(const char 
*option)
die(_("unrecognized whitespace ignore option '%s'"), option);
 }
 
-static void set_default_whitespace_mode(const char *whitespace_option)
+static void set_default_whitespace_mode(struct apply_state *state,
+   const char *whitespace_option)
 {
if (!whitespace_option && !apply_default_whitespace)
-   ws_error_action = (apply ? warn_on_ws_error : nowarn_ws_error);
+       ws_error_action = (state->apply ? warn_on_ws_error : 
nowarn_ws_error);
 }
 
 /*
@@ -2074,7 +2076,7 @@ static int parse_chunk(struct apply_state *state, char 
*buffer, unsigned long si
 * without metadata change.  A binary patch appears
 * empty to us here.
 */
-   if ((apply || state->check) &&
+   if ((state->apply || state->check) &&
(!patch->is_binary && !metadata_changes(patch)))
die(_("patch with only garbage at line %d"), linenr);
}
@@ -2933,7 +2935,7 @@ static int apply_one_fragment(struct apply_state *state,
 * apply_data->apply_fragments->apply_one_fragment
 */
    if (ws_error_action == die_on_ws_error)
-   apply = 0;
+   state->apply = 0;
}
 
if (state->apply_verbosely && applied_pos != pos) {
@@ -4477,9 +4479,9 @@ static int apply_patch(struct apply_state *state,
die(_("unrecognized input"));
 
    if (whitespace_error && (ws_error_action == die_on_ws_error))
-   apply = 0;
+   state->apply = 0;
 
-   state->update_index = state->check_index && apply;
+   state->update_index = state->check_index && state->apply;
if (state->update_index && newfd < 0)
newfd = hold_locked_index(&lock_file, 1);
 
@@ -4488,12 +4490,12 @@ static int apply_patch(struct apply_state *state,
die(_("unable to read index file"));
}
 
-   if ((state->check || apply) &&
+   if ((state->check || state->apply) &&
check_patch_list(state, list) < 0 &&
!state->apply_with_reject)
exit(1);
 
-   if (apply && write_out_results(state, list)) {
+   if (state->apply && write_out_results(state, list)) {
if (state->apply_with_reject)
exit(1);
/* with --3way, we still need to write the index out */
@@ -4660,6 +4662,7 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
memset(&state, 0, sizeof(state));
state.prefix = prefix_;
state.prefix_length = state.prefix ? strlen(state.prefix) : 0;
+   state.apply = 1;
state.line_termination = '\n';
state.p_context = UINT_MAX;
 
@@ -4682,9 +4685,9 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
state.check_index = 1;
}
if (state.apply_with_reject)
-   apply = state.apply_verbosely = 1;
+   state.apply = state.apply_verbosely = 1;
if (!force_apply && (state.diffstat || state.numstat || state.summary 
|| state.check || state.fake_ancestor))
-   apply = 0;
+   state.apply = 0;
if (state.check_index && is_not_gitdir)
die(_("--index outside a repository"));
if (state.cached) {
@@ -4712,11 +4715,11 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
if (fd < 0)
die_errno(_("can't open patch '%s'"), arg);
read_stdin = 0;
-   set_default_whitespace_mode(whitespace_option);
+   set_default_whitespace_mode(&state, whitespace_option);
errs |= apply_patch(&state, fd, arg, options);
clos

[PATCH/WIP v2 08/19] am: apply patch with git-apply

2015-06-11 Thread Paul Tan
Implement applying the patch to the index using git-apply.

Signed-off-by: Paul Tan 
---
 builtin/am.c | 55 ++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/builtin/am.c b/builtin/am.c
index a1db474..b725a74 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -27,6 +27,18 @@ static int is_empty_file(const char *filename)
return !st.st_size;
 }
 
+/**
+ * Returns the first line of msg
+ */
+static const char *firstline(const char *msg)
+{
+   static struct strbuf sb = STRBUF_INIT;
+
+   strbuf_reset(&sb);
+   strbuf_add(&sb, msg, strchrnul(msg, '\n') - msg);
+   return sb.buf;
+}
+
 enum patch_format {
PATCH_FORMAT_UNKNOWN = 0,
PATCH_FORMAT_MBOX
@@ -512,6 +524,29 @@ static int parse_patch(struct am_state *state, const char 
*patch)
return 0;
 }
 
+/*
+ * Applies current patch with git-apply. Returns 0 on success, -1 otherwise.
+ */
+static int run_apply(const struct am_state *state)
+{
+   struct child_process cp = CHILD_PROCESS_INIT;
+
+   cp.git_cmd = 1;
+
+   argv_array_push(&cp.args, "apply");
+   argv_array_push(&cp.args, "--index");
+   argv_array_push(&cp.args, am_path(state, "patch"));
+
+   if (run_command(&cp))
+   return -1;
+
+   /* Reload index as git-apply will have modified it. */
+   discard_cache();
+   read_cache();
+
+   return 0;
+}
+
 /**
  * Applies all queued patches.
  */
@@ -529,7 +564,25 @@ static void am_run(struct am_state *state)
write_author_script(state);
write_file(am_path(state, "final-commit"), 1, "%s", 
state->msg.buf);
 
-   /* TODO: Patch application not implemented yet */
+   printf_ln(_("Applying: %s"), firstline(state->msg.buf));
+
+   if (run_apply(state) < 0) {
+   int value;
+
+   printf_ln(_("Patch failed at %s %s"), msgnum(state),
+   firstline(state->msg.buf));
+
+   if (!git_config_get_bool("advice.amworkdir", &value) && 
!value)
+   printf_ln(_("The copy of the patch that failed 
is found in: %s"),
+   am_path(state, "patch"));
+
+   exit(128);
+   }
+
+   /*
+* TODO: After the patch has been applied to the index with
+* git-apply, we need to make commit as well.
+*/
 
 next:
am_next(state);
-- 
2.1.4

--
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


[PATCH/WIP v3 08/31] am: apply patch with git-apply

2015-06-18 Thread Paul Tan
Implement applying the patch to the index using git-apply.

Signed-off-by: Paul Tan 
---
 builtin/am.c | 57 -
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/builtin/am.c b/builtin/am.c
index d6434e4..296a5fc 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -27,6 +27,18 @@ static int is_empty_file(const char *filename)
return !st.st_size;
 }
 
+/**
+ * Returns the first line of msg
+ */
+static const char *firstline(const char *msg)
+{
+   static struct strbuf sb = STRBUF_INIT;
+
+   strbuf_reset(&sb);
+   strbuf_add(&sb, msg, strchrnul(msg, '\n') - msg);
+   return sb.buf;
+}
+
 enum patch_format {
PATCH_FORMAT_UNKNOWN = 0,
PATCH_FORMAT_MBOX
@@ -519,6 +531,31 @@ static int parse_patch(struct am_state *state, const char 
*patch)
return 0;
 }
 
+/*
+ * Applies current patch with git-apply. Returns 0 on success, -1 otherwise.
+ */
+static int run_apply(const struct am_state *state)
+{
+   struct child_process cp = CHILD_PROCESS_INIT;
+
+   cp.git_cmd = 1;
+
+   argv_array_push(&cp.args, "apply");
+
+   argv_array_push(&cp.args, "--index");
+
+   argv_array_push(&cp.args, am_path(state, "patch"));
+
+   if (run_command(&cp))
+   return -1;
+
+   /* Reload index as git-apply will have modified it. */
+   discard_cache();
+   read_cache();
+
+   return 0;
+}
+
 /**
  * Applies all queued patches.
  */
@@ -536,7 +573,25 @@ static void am_run(struct am_state *state)
write_author_script(state);
write_file(am_path(state, "final-commit"), 1, "%s", 
state->msg.buf);
 
-   /* TODO: Patch application not implemented yet */
+   printf_ln(_("Applying: %s"), firstline(state->msg.buf));
+
+   if (run_apply(state) < 0) {
+   int value;
+
+   printf_ln(_("Patch failed at %s %s"), msgnum(state),
+   firstline(state->msg.buf));
+
+   if (!git_config_get_bool("advice.amworkdir", &value) && 
!value)
+   printf_ln(_("The copy of the patch that failed 
is found in: %s"),
+   am_path(state, "patch"));
+
+   exit(128);
+   }
+
+   /*
+* TODO: After the patch has been applied to the index with
+* git-apply, we need to make commit as well.
+*/
 
 next:
am_next(state);
-- 
2.1.4

--
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


Re: [PATCH v9 35/41] apply: make it possible to silently apply

2016-08-01 Thread Junio C Hamano
Christian Couder  writes:

> +enum apply_verbosity {
> + verbosity_silent = -1,
> + verbosity_normal = 0,
> + verbosity_verbose = 1,

Drop the trailing comma from the last element in enum definition
(comma after the last element in an array is OK).
--
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


[PATCH v2 28/94] builtin/apply: move 'apply' global into 'struct apply_state'

2016-05-11 Thread Christian Couder
To libify the apply functionality the 'apply' variable should
not be static and global to the file. Let's move it into
'struct apply_state'.

Reviewed-by: Stefan Beller 
Signed-off-by: Christian Couder 
---
 builtin/apply.c | 31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 2ba2b21..a3db284 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -25,6 +25,7 @@ struct apply_state {
const char *prefix;
int prefix_length;
 
+   int apply;
int allow_overlap;
int apply_in_reverse;
int apply_with_reject;
@@ -65,7 +66,7 @@ static int newfd = -1;
 
 static int state_p_value = 1;
 static int p_value_known;
-static int apply = 1;
+
 static const char * const apply_usage[] = {
N_("git apply [] [...]"),
NULL
@@ -135,10 +136,11 @@ static void parse_ignorewhitespace_option(const char 
*option)
die(_("unrecognized whitespace ignore option '%s'"), option);
 }
 
-static void set_default_whitespace_mode(const char *whitespace_option)
+static void set_default_whitespace_mode(struct apply_state *state,
+   const char *whitespace_option)
 {
if (!whitespace_option && !apply_default_whitespace)
-   ws_error_action = (apply ? warn_on_ws_error : nowarn_ws_error);
+   ws_error_action = (state->apply ? warn_on_ws_error : 
nowarn_ws_error);
 }
 
 /*
@@ -2067,7 +2069,7 @@ static int parse_chunk(struct apply_state *state, char 
*buffer, unsigned long si
 * without metadata change.  A binary patch appears
 * empty to us here.
 */
-   if ((apply || state->check) &&
+   if ((state->apply || state->check) &&
(!patch->is_binary && !metadata_changes(patch)))
die(_("patch with only garbage at line %d"), 
state_linenr);
}
@@ -2925,7 +2927,7 @@ static int apply_one_fragment(struct apply_state *state,
 * apply_data->apply_fragments->apply_one_fragment
     */
if (ws_error_action == die_on_ws_error)
-   apply = 0;
+   state->apply = 0;
}
 
if (state->apply_verbosely && applied_pos != pos) {
@@ -4469,9 +4471,9 @@ static int apply_patch(struct apply_state *state,
    die(_("unrecognized input"));
 
if (whitespace_error && (ws_error_action == die_on_ws_error))
-   apply = 0;
+       state->apply = 0;
 
-   state->update_index = state->check_index && apply;
+   state->update_index = state->check_index && state->apply;
if (state->update_index && newfd < 0)
newfd = hold_locked_index(&lock_file, 1);
 
@@ -4480,12 +4482,12 @@ static int apply_patch(struct apply_state *state,
die(_("unable to read index file"));
}
 
-   if ((state->check || apply) &&
+   if ((state->check || state->apply) &&
check_patch_list(state, list) < 0 &&
!state->apply_with_reject)
exit(1);
 
-   if (apply && write_out_results(state, list)) {
+   if (state->apply && write_out_results(state, list)) {
if (state->apply_with_reject)
exit(1);
/* with --3way, we still need to write the index out */
@@ -4574,6 +4576,7 @@ static void init_apply_state(struct apply_state *state, 
const char *prefix)
memset(state, 0, sizeof(*state));
state->prefix = prefix;
state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
+   state->apply = 1;
state->line_termination = '\n';
state->p_context = UINT_MAX;
 
@@ -4680,9 +4683,9 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
state.check_index = 1;
}
if (state.apply_with_reject)
-   apply = state.apply_verbosely = 1;
+   state.apply = state.apply_verbosely = 1;
if (!force_apply && (state.diffstat || state.numstat || state.summary 
|| state.check || state.fake_ancestor))
-   apply = 0;
+   state.apply = 0;
if (state.check_index && is_not_gitdir)
die(_("--index outside a repository"));
if (state.cached) {
@@ -4710,11 +4713,11 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
if (fd < 0)
die_errno(_("can't open patch '%s'"), arg);

[PATCH v3 28/49] builtin/apply: move 'apply' global into 'struct apply_state'

2016-05-24 Thread Christian Couder
To libify the apply functionality the 'apply' variable should
not be static and global to the file. Let's move it into
'struct apply_state'.

Reviewed-by: Stefan Beller 
Signed-off-by: Christian Couder 
---
 builtin/apply.c | 31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 3c9f052..c0c18ce 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -26,6 +26,7 @@ struct apply_state {
int prefix_length;
 
/* These control what gets looked at and modified */
+   int apply; /* this is not a dry-run */
    int cached; /* apply to the index only */
int check; /* preimage must match working tree, don't actually apply */
int check_index; /* preimage must match the indexed version */
@@ -56,7 +57,7 @@ static int newfd = -1;
 
 static int state_p_value = 1;
 static int p_value_known;
-static int apply = 1;
+
 static const char * const apply_usage[] = {
N_("git apply [] [...]"),
NULL
@@ -126,10 +127,11 @@ static void parse_ignorewhitespace_option(const char 
*option)
die(_("unrecognized whitespace ignore option '%s'"), option);
 }
 
-static void set_default_whitespace_mode(const char *whitespace_option)
+static void set_default_whitespace_mode(struct apply_state *state,
+   const char *whitespace_option)
 {
if (!whitespace_option && !apply_default_whitespace)
-   ws_error_action = (apply ? warn_on_ws_error : nowarn_ws_error);
+   ws_error_action = (state->apply ? warn_on_ws_error : 
nowarn_ws_error);
 }
 
 /*
@@ -2058,7 +2060,7 @@ static int parse_chunk(struct apply_state *state, char 
*buffer, unsigned long si
 * without metadata change.  A binary patch appears
     * empty to us here.
 */
-       if ((apply || state->check) &&
+   if ((state->apply || state->check) &&
(!patch->is_binary && !metadata_changes(patch)))
die(_("patch with only garbage at line %d"), 
state_linenr);
}
@@ -2916,7 +2918,7 @@ static int apply_one_fragment(struct apply_state *state,
 * apply_data->apply_fragments->apply_one_fragment
     */
    if (ws_error_action == die_on_ws_error)
-   apply = 0;
+   state->apply = 0;
}
 
if (state->apply_verbosely && applied_pos != pos) {
@@ -4460,9 +4462,9 @@ static int apply_patch(struct apply_state *state,
    die(_("unrecognized input"));
 
if (whitespace_error && (ws_error_action == die_on_ws_error))
-   apply = 0;
+   state->apply = 0;
 
-   state->update_index = state->check_index && apply;
+   state->update_index = state->check_index && state->apply;
if (state->update_index && newfd < 0)
newfd = hold_locked_index(&lock_file, 1);
 
@@ -4471,12 +4473,12 @@ static int apply_patch(struct apply_state *state,
die(_("unable to read index file"));
    }
 
-   if ((state->check || apply) &&
+   if ((state->check || state->apply) &&
check_patch_list(state, list) < 0 &&
!state->apply_with_reject)
exit(1);
 
-   if (apply && write_out_results(state, list)) {
+   if (state->apply && write_out_results(state, list)) {
if (state->apply_with_reject)
exit(1);
/* with --3way, we still need to write the index out */
@@ -4565,6 +4567,7 @@ static void init_apply_state(struct apply_state *state, 
const char *prefix)
memset(state, 0, sizeof(*state));
state->prefix = prefix;
state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
+   state->apply = 1;
state->line_termination = '\n';
state->p_context = UINT_MAX;
 
@@ -4676,9 +4679,9 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix)
state.check_index = 1;
}
if (state.apply_with_reject)
-   apply = state.apply_verbosely = 1;
+   state.apply = state.apply_verbosely = 1;
if (!force_apply && (state.diffstat || state.numstat || state.summary 
|| state.check || state.fake_ancestor))
-   apply = 0;
+   state.apply = 0;
if (state.check_index && is_not_gitdir)
die(_("--index outside a repository"));
if (state.cached) {
@@ -4706,11 +4709,11 @@ int cmd_apply(int argc, const char 

Re: [PATCH v13 06/14] apply: make it possible to silently apply

2016-08-31 Thread Stefan Beller
> Printing on stdout, and calls to warning() or error() are not
> taken care of in this patch, as that will be done in following
> patches.

> -   if (state->apply_verbosely)
> +   if (state->apply_verbosity > verbosity_normal)
> error(_("while searching for:\n%.*s"),
>   (int)(old - oldlines), oldlines);

But this is an error(..) ?

Have you considered to replace all these print functions (error, warning,
fprintf, printf, fprintf_ln) with another custom

int say_when_at_least(verbosity level, const char *fmt,...)

? (I guess that would be more invasive, but the result would be more
consistent.)


Re: [PATCH v13 06/14] apply: make it possible to silently apply

2016-09-01 Thread Christian Couder
On Thu, Sep 1, 2016 at 12:07 AM, Stefan Beller  wrote:
>> Printing on stdout, and calls to warning() or error() are not
>> taken care of in this patch, as that will be done in following
>> patches.
>
>> -   if (state->apply_verbosely)
>> +   if (state->apply_verbosity > verbosity_normal)
>> error(_("while searching for:\n%.*s"),
>>   (int)(old - oldlines), oldlines);
>
> But this is an error(..) ?

Do you mean that it was a bug in the original code to print this error
only in verbose mode?

> Have you considered to replace all these print functions (error, warning,
> fprintf, printf, fprintf_ln) with another custom
>
> int say_when_at_least(verbosity level, const char *fmt,...)
>
> ? (I guess that would be more invasive, but the result would be more
> consistent.)

My opinion is that there is a reason (or there should have been a
reason) why people decided to use error() instead of warning() for
example.
If I use say_when_at_least(verbosity level, const char *fmt,...) like
you suggest, how do I decide if error() or warning() is used to
actually print the error message?
Another parameter to this function (severity level?) is needed.

Anyway I don't think such a refactoring is needed.


Re: [PATCH v13 06/14] apply: make it possible to silently apply

2016-09-01 Thread Stefan Beller
On Thu, Sep 1, 2016 at 1:01 AM, Christian Couder
 wrote:
> On Thu, Sep 1, 2016 at 12:07 AM, Stefan Beller  wrote:
>>> Printing on stdout, and calls to warning() or error() are not
>>> taken care of in this patch, as that will be done in following
>>> patches.
>>
>>> -   if (state->apply_verbosely)
>>> +   if (state->apply_verbosity > verbosity_normal)
>>> error(_("while searching for:\n%.*s"),
>>>   (int)(old - oldlines), oldlines);
>>
>> But this is an error(..) ?
>
> Do you mean that it was a bug in the original code to print this error
> only in verbose mode?

Oh never mind.

I meant to point out the inconsistency between the commit message, that
said: "error() are not taken care of in this patch" and modifying a
condition for
an error call. However we need to fix them as you renamed apply_verbosely
to apply_verbosity and made it an enum. So I spoke too early.

>
> Anyway I don't think such a refactoring is needed.

great :)


[RFC/PATCH 26/48] builtin/apply: move 'apply' global into 'struct apply_state'

2016-03-09 Thread Christian Couder
Signed-off-by: Christian Couder 
---
 builtin/apply.c | 31 +--
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 6e347e2..6342b61 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -26,6 +26,7 @@ struct apply_state {
int prefix_length;
int newfd;
 
+   int apply;
int allow_overlap;
int apply_in_reverse;
int apply_with_reject;
@@ -70,7 +71,7 @@ struct apply_state {
 
 static int p_value = 1;
 static int p_value_known;
-static int apply = 1;
+
 static const char * const apply_usage[] = {
N_("git apply [] [...]"),
NULL
@@ -141,10 +142,11 @@ static void parse_ignorewhitespace_option(const char 
*option)
die(_("unrecognized whitespace ignore option '%s'"), option);
 }
 
-static void set_default_whitespace_mode(const char *whitespace_option)
+static void set_default_whitespace_mode(struct apply_state *state,
+   const char *whitespace_option)
 {
if (!whitespace_option && !apply_default_whitespace)
-   ws_error_action = (apply ? warn_on_ws_error : nowarn_ws_error);
+       ws_error_action = (state->apply ? warn_on_ws_error : 
nowarn_ws_error);
 }
 
 /*
@@ -2075,7 +2077,7 @@ static int parse_chunk(struct apply_state *state, char 
*buffer, unsigned long si
 * without metadata change.  A binary patch appears
 * empty to us here.
 */
-   if ((apply || state->check) &&
+   if ((state->apply || state->check) &&
(!patch->is_binary && !metadata_changes(patch)))
die(_("patch with only garbage at line %d"), linenr);
}
@@ -2934,7 +2936,7 @@ static int apply_one_fragment(struct apply_state *state,
 * apply_data->apply_fragments->apply_one_fragment
 */
    if (ws_error_action == die_on_ws_error)
-   apply = 0;
+   state->apply = 0;
}
 
if (state->apply_verbosely && applied_pos != pos) {
@@ -4474,9 +4476,9 @@ static int apply_patch(struct apply_state *state,
die(_("unrecognized input"));
 
    if (whitespace_error && (ws_error_action == die_on_ws_error))
-   apply = 0;
+   state->apply = 0;
 
-   state->update_index = state->check_index && apply;
+   state->update_index = state->check_index && state->apply;
if (state->update_index && state->newfd < 0)
state->newfd = hold_locked_index(&lock_file, 1);
 
@@ -4485,12 +4487,12 @@ static int apply_patch(struct apply_state *state,
die(_("unable to read index file"));
}
 
-   if ((state->check || apply) &&
+   if ((state->check || state->apply) &&
check_patch_list(state, list) < 0 &&
!state->apply_with_reject)
exit(1);
 
-   if (apply && write_out_results(state, list)) {
+   if (state->apply && write_out_results(state, list)) {
if (state->apply_with_reject)
exit(1);
/* with --3way, we still need to write the index out */
@@ -4657,6 +4659,7 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
memset(&state, 0, sizeof(state));
state.prefix = prefix_;
state.prefix_length = state.prefix ? strlen(state.prefix) : 0;
+   state.apply = 1;
state.newfd = -1;
    state.line_termination = '\n';
state.p_context = UINT_MAX;
@@ -4680,9 +4683,9 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
state.check_index = 1;
}
if (state.apply_with_reject)
-   apply = state.apply_verbosely = 1;
+   state.apply = state.apply_verbosely = 1;
if (!force_apply && (state.diffstat || state.numstat || state.summary 
|| state.check || state.fake_ancestor))
-   apply = 0;
+   state.apply = 0;
if (state.check_index && is_not_gitdir)
die(_("--index outside a repository"));
if (state.cached) {
@@ -4710,11 +4713,11 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
if (fd < 0)
die_errno(_("can't open patch '%s'"), arg);
read_stdin = 0;
-   set_default_whitespace_mode(whitespace_option);
+   set_default_whitespace_mode(&state, whitespace_option);
errs |= apply_patch(&state, fd, arg, optio

Re: [PATCH/WIP v3 08/31] am: apply patch with git-apply

2015-06-18 Thread Junio C Hamano
Paul Tan  writes:

> Implement applying the patch to the index using git-apply.
>
> Signed-off-by: Paul Tan 
> ---
>  builtin/am.c | 57 -
>  1 file changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/am.c b/builtin/am.c
> index d6434e4..296a5fc 100644
> --- a/builtin/am.c
> +++ b/builtin/am.c
> @@ -27,6 +27,18 @@ static int is_empty_file(const char *filename)
>   return !st.st_size;
>  }
>  
> +/**
> + * Returns the first line of msg
> + */
> +static const char *firstline(const char *msg)
> +{
> + static struct strbuf sb = STRBUF_INIT;
> +
> + strbuf_reset(&sb);
> + strbuf_add(&sb, msg, strchrnul(msg, '\n') - msg);
> + return sb.buf;
> +}

Hmm.  This is not wrong per-se but a more efficient way to do it may
be to have a helper function that returns a bytecount of the first
line of the msg, i.e. strchrnul(msg, '\n') - msg.  Then a caller can
do

printf("Applying: %.*s", linelen(msg), msg);

instead of

printf("Applying: %s", firstline(msg));

relying on that the firstline() copies the contents to a static
strbuf that does not have to be freed.

> + struct child_process cp = CHILD_PROCESS_INIT;
> +
> + cp.git_cmd = 1;
> +
> + argv_array_push(&cp.args, "apply");
> +
> + argv_array_push(&cp.args, "--index");
> +
> + argv_array_push(&cp.args, am_path(state, "patch"));

You seem to like blank lines a lot ;-)  While it is a good tool to
separate different groups while grouping related things together,
these three argv-push calls are intimately related, and reads better
without blanks in between.

Looks nicely done so far...
--
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


[PATCH 3/4] apply: add --whole to apply git patch without prefix filtering

2016-03-24 Thread Nguyễn Thái Ngọc Duy
Back in edf2e37 (git-apply: work from subdirectory. - 2005-11-25),
git-apply is made to work from a subdir of a worktree. When applying a
git patch this way, only paths in the subdir are patched, the rest is
filtered out. To apply without filtering, the user has to move back to
toplevel. Add --whole to make it more convenient to do so without moving
cwd around.

Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 Documentation/git-apply.txt |  8 +++-
 builtin/apply.c |  4 +++-
 t/t4111-apply-subdir.sh | 32 
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 8ddb207..47cea57 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -13,7 +13,7 @@ SYNOPSIS
  [--apply] [--no-add] [--build-fake-ancestor=] [-R | --reverse]
  [--allow-binary-replacement | --binary] [--reject] [-z]
  [-p] [-C] [--inaccurate-eof] [--recount] [--cached]
- [--ignore-space-change | --ignore-whitespace]
+ [--ignore-space-change | --ignore-whitespace] [--whole]
  [--whitespace=(nowarn|warn|fix|error|error-all)]
  [--exclude=] [--include=] [--directory=]
  [--verbose] [--unsafe-paths] [...]
@@ -154,6 +154,12 @@ discouraged.
flag was the way to do so.  Currently we always allow binary
patch application, so this is a no-op.
 
+--whole::
+   Normally when running inside a subdirectory of a working area,
+   patched files outside current directory is filtered out. This option
+   makes `git apply` to apply them all. All paths are still subject
+   to `--exclude` and `--include` fitlering if present.
+
 --exclude=::
Don't apply changes to files matching the given path pattern. This can
be useful when importing patchsets, where you want to exclude certain
diff --git a/builtin/apply.c b/builtin/apply.c
index 42c610e..01e1d5e 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -80,6 +80,7 @@ static const char *patch_input_file;
 static struct strbuf root = STRBUF_INIT;
 static int read_stdin = 1;
 static int options;
+static int apply_whole;
 
 static void parse_whitespace_option(const char *option)
 {
@@ -1956,7 +1957,7 @@ static int use_patch(struct patch *p)
int i;
 
/* Paths outside are not touched regardless of "--include" */
-   if (0 < prefix_length) {
+   if (!apply_whole && 0 < prefix_length) {
int pathlen = strlen(pathname);
if (pathlen <= prefix_length ||
memcmp(prefix, pathname, prefix_length))
@@ -4565,6 +4566,7 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
OPT_BIT(0, "recount", &options,
N_("do not trust the line counts in the hunk headers"),
RECOUNT),
+   OPT_BOOL(0, "whole", &apply_whole, N_("apply whole patch")),
{ OPTION_CALLBACK, 0, "directory", NULL, N_("root"),
N_("prepend  to all filenames"),
0, option_parse_directory },
diff --git a/t/t4111-apply-subdir.sh b/t/t4111-apply-subdir.sh
index 1618a6d..e5cd019 100755
--- a/t/t4111-apply-subdir.sh
+++ b/t/t4111-apply-subdir.sh
@@ -153,4 +153,36 @@ test_expect_success 'apply --cached from subdir of .git 
dir' '
test_cmp expected.subdir actual.subdir
 '
 
+test_expect_success 'setup a git patch' '
+   cat >gitpatch <<-\EOF &&
+   diff --git a/file b/file
+   --- a/file
+   +++ b/file
+   @@ -1 +1,2 @@
+1
+   +2
+   EOF
+   gitpatch="$(pwd)/gitpatch"
+'
+
+test_expect_success 'apply a git patch from subdir of toplevel' '
+   reset_subdir other preimage &&
+   (
+   cd sub/dir &&
+   git apply "$gitpatch"
+   ) &&
+   test_cmp preimage sub/dir/file &&
+   test_cmp preimage file
+'
+
+test_expect_success 'apply the whole git patch from subdir of toplevel' '
+   reset_subdir other preimage &&
+   (
+   cd sub/dir &&
+   git apply --whole "$gitpatch"
+   ) &&
+   test_cmp preimage sub/dir/file &&
+   test_cmp postimage file
+'
+
 test_done
-- 
2.8.0.rc0.210.gd302cd2

--
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


[PATCH] apply: clarify "-p" documentation

2018-05-10 Thread Jeff King
On Fri, Apr 27, 2018 at 12:40:05PM -0500, kelly elton wrote:

> >  -p
> > Remove  leading slashes from traditional diff paths. The default is 1.
> 
> This suggests to me the following outcomes:
> 1) home/user/repos/myrepo with -p1 becomes home/user/repos/myrepo
> 2) home/user/repos/myrepo with -p2 becomes home/user/repos/myrepo
> 3) /home/user/repos/myrepo with -p1 becomes home/user/repos/myrepo
> 4) /home/user/repos/myrepo with -p2 becomes home/user/repos/myrepo
> 5) //home/user/repos/myrepo with -p1 becomes /home/user/repos/myrepo
> 6) //home/user/repos/myrepo with -p2 becomes home/user/repos/myrepo
> 
> `Remove  leading slashes`...That's not really what's happening.
> 
> What seems to actually happen is that it is removing directories from the 
> path:
> 1) home/user/repos/myrepo with -p1 becomes home/user/repos/myrepo
> 2) home/user/repos/myrepo with -p2 becomes user/repos/myrepo
> 
> This argument seems to be removing folders from the path, not slashes.

Yes. I agree the current documentation is quite misleading.

How about this?

-- >8 --
Subject: [PATCH] apply: clarify "-p" documentation

We're not really removing slashes, but slash-separated path
components. Let's make that more clear.

Reported-by: kelly elton 
Signed-off-by: Jeff King 
---
 Documentation/git-apply.txt | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index 4ebc3d3271..c993fbf714 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -113,8 +113,10 @@ explained for the configuration variable `core.quotePath` 
(see
 linkgit:git-config[1]).
 
 -p::
-   Remove  leading slashes from traditional diff paths. The
-   default is 1.
+   Remove  leading path components (separated by slashes) from
+   traditional diff paths. E.g., with `-p2`, a patch against
+   `a/dir/file` will be applied directly to `file`. The default is
+   1.
 
 -C::
Ensure at least  lines of surrounding context match before
-- 
2.17.0.984.g9b00a423a4



[PATCH] apply: comment grammar fix

2015-09-09 Thread Giuseppe Bilotta
Signed-off-by: Giuseppe Bilotta 
---
 builtin/apply.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 54aba4e..4aa53f7 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -785,7 +785,7 @@ static int guess_p_value(const char *nameline)
 }
 
 /*
- * Does the ---/+++ line has the POSIX timestamp after the last HT?
+ * Does the ---/+++ line have the POSIX timestamp after the last HT?
  * GNU diff puts epoch there to signal a creation/deletion event.  Is
  * this such a timestamp?
  */
-- 
2.6.0.rc1.170.g51893f9.dirty

--
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


git 2.6.0 apply --cached failed

2015-09-30 Thread 乙酸鋰
Hi,

Using git 2.6.0 on Linux 64-bit
git apply --cached failed

Please test with command with the repository inside the attached tarball.

With git 2.6,
git apply --cached < patch.patch

fatal: corrupt patch at line 27


Expected result: no error

Step to reproduce: Please run the following shell script.

#/bin/sh
set -e
mkdir 2
cd 2

cat > d0c886e2-2cfe-4636-825b-3622fac0b27f <http://vger.kernel.org/majordomo-info.html


Segmentation fault in git apply

2015-01-14 Thread Michael Blume
This is a mac with a fresh build of git from pu branch, commit 53b80d0.

With my gitconfig looking like

[user]
email = blume.m...@gmail.com
name = Michael Blume
[apply]
whitespace = fix
[core]
whitespace = fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4

If I run
git clone g...@github.com:MichaelBlume/clojure.git
cd clojure
git checkout origin/rebase-start
git rebase origin/rebase-base

I get

src/jvm/clojure/lang/Compiler.java  |  26
+-
 test/clojure/test_clojure/compilation.clj   |  33
-
 test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121
+
 3 files changed, 170 insertions(+), 10 deletions(-)
 create mode 100644 test/clojure/test_clojure/compilation/examples_clj_1561.clj
First, rewinding head to replay your work on top of it...
Applying: CLJ-1603 - add reducible cycle, iterate, repeat
Applying: CLJ-1515 Reify range
Applying: CLJ-1499 Direct iterators for PersistentHashMap,
APersistentSet, PersistentQueue, and PersistentStructMap, and records.
Added new IMapIterable interface for key and val iterators.
Applying: CLJ-1602 Make keys and vals return Iterable result
Applying: fix AOT bug preventing overriding of clojure.core functions
Applying: catch multiple rest forms
Applying: zipmap using iterators and transient maps
Applying: Define merge/merge-with after reduce has loaded
Applying: very simple test of the merge function
Applying: Support get on arbitrary java.util.List instances
Applying: CLJ-1451 add take-until
Applying: CLJ-1606 - complete eduction's xform without completing outer rfn
Applying: add unrolled vector implementation
Applying: add transient? predicate
Applying: fix emitted line numbers
Using index info to reconstruct a base tree...
M src/jvm/clojure/lang/Compiler.java
Falling back to patching base and 3-way merge...
Auto-merging src/jvm/clojure/lang/Compiler.java
Applying: just use a not
Applying: trailing whitespace
Applying: don't mix tabs/spaces in clojure.xml/emit-element
Applying: avoid mixing tabs with spaces in clojure core code
Applying: don't optimize for defrecord lookup if keyword is namespaced
Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity
Applying: unrolled impls for maps
Applying: CLJ-703: Remove flush and sync calls when writing class files.
Applying: CLJ-1078: Add queue and queue? to clojure.core
Applying: make RT.boundedLength lazier
Applying: first try for adding compare
Applying: Fix for #CLJ-1565
Applying: CLJ-1074: Read +/- Infinity and NaN
Applying: Fix CLJ-1074 for EdnReader too, see
eaeda2e7bf2697e565decdf14a8a99fbf8588c57
Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms
Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit
Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string
Applying: if test expr of an if statement is a literal, don't emit the
runtime test
Applying: evaluate def symbol metadata only once
Applying: CLJ-1295: Speed up dissoc on array-maps
Applying: some throwing
Applying: don't pass offset to ArrayChunk
Applying: make EMPTY accessible
Applying: add handy create methods
Applying: regenerate
Applying: regenerate
/Users/michael.blume/libexec/git-core/git-am: line 854: 92059
Segmentation fault: 11  git apply --index "$dotest/patch" > /dev/null
2>&1
/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab
in indent.
   IPersistentVector v = (IPersistentVector) asTransient().conj(val)
/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab
in indent.
   .persistent();
/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab
in indent.
   return (IPersistentVector) ((IObj) v).withMeta(meta);
/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab
in indent.
ITransientCollection coll = PersistentVector.EMPTY
/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:27: tab
in indent.
return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.
Using index info to reconstruct a base tree...
M src/jvm/clojure/lang/PersistentUnrolledVector.java
:13: tab in indent.
   IPersistentVector v = (IPersistentVector) asTransient().conj(val)
:14: tab in indent.
   .persistent();
:15: tab in indent.
   return (IPersistentVector) ((IObj) v).withMeta(meta);
:25: tab in indent.
ITransientCollection coll = PersistentVector.EMPTY
:27: tab in indent.
return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)
warning: squelched 1 whitespace error
warning: 6 lines applied after fixing whitespace errors.
Falling back to patching base and 3-way merge...
fatal: Unable to create
'/Users/michael.blume/workspace/clojure/.git/index.lock&#x

Bug Report for git apply

2019-04-11 Thread Can Gemicioglu
Hi,

I noticed a problem when trying to apply a patch file that contained many 
separate patches in a single file. Trying to apply this patch gave me a "No 
such file or directory" error for one of the files in the middle and after 
looking around I realised this file was also created earlier in the patch. I 
tested this myself with these steps and saw a similar error:

1. Create a new file and commit.
2. Move the file to a different folder and commit.
3. Create a single patch for these 2 commits by using git format-patch and 
concatenating the two resulting files (01.patch, 02.patch) into one 
(combined.patch).
4. Roll back to 2 commits earlier.

At that point if I try to use 'git apply combined.patch', it will throw the 
same no such file error. However, if I use 'git am combined.patch' instead it 
works. If I apply the first 2 patches separately instead, using 'git apply 0*' 
it also works but if I first try to check if it will work with 'git apply 
--check 0*' it actually throws the same error again.

I'm guessing there's something like a check to make sure the file exists that 
throws an error even if the file was going to be created by previous commits.

Tested on git version 2.21.0 on Ubuntu 18.04

Best,
Can Gemicioglu


submodule.recurse should apply to clone

2019-01-16 Thread Tim Hutt
For some reason submodule.recurse applies to everything except clone.
Is there a reason for this strange inconsistency?

Cheers,

Tim


git-subtree Patches to Apply

2012-12-31 Thread David A. Greene
Here are all of the patches for git-subtree that have been posted to
the mailing list that I could apply and test in a reasonable amount of
time.  These are all rebased from trunk as of tonight.

Many apologies for being *so* behind.  Work has been a bear but I'm
hoping things will ease up in the new year and I can be more regularly
active.  But still, don't expect same-day service.  :)

These are also available on branch "toupstream" via

git clone gitol...@sources.obbligato.org:git.git

and

http://sources.obbligato.org
http://sources.obbligato.org/?p=git.git;a=summary

Junio, can you apply these?  Thanks!

 -David

--
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


[PATCH] apply: use starts_with() in gitdiff_verify_name()

2017-07-01 Thread René Scharfe
Avoid running over the end of line -- a C string whose length is not
known to this function -- by using starts_with() instead of memcmp(3)
for checking if it starts with "/dev/null".  Also simply include the
newline in the string constant to compare against.  Drop a comment that
just states the obvious.

Signed-off-by: Rene Scharfe 
---
 apply.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/apply.c b/apply.c
index c442b89328..946be4d2f5 100644
--- a/apply.c
+++ b/apply.c
@@ -976,8 +976,7 @@ static int gitdiff_verify_name(struct apply_state *state,
}
free(another);
} else {
-   /* expect "/dev/null" */
-   if (memcmp("/dev/null", line, 9) || line[9] != '\n')
+   if (!starts_with(line, "/dev/null\n"))
return error(_("git apply: bad git-diff - expected 
/dev/null on line %d"), state->linenr);
}
 
-- 
2.13.2


Confusing documentation for git apply -p

2018-04-27 Thread kelly elton
https://git-scm.com/docs/git-apply#git-apply--pltngt

>  -p
> Remove  leading slashes from traditional diff paths. The default is 1.

This suggests to me the following outcomes:
1) home/user/repos/myrepo with -p1 becomes home/user/repos/myrepo
2) home/user/repos/myrepo with -p2 becomes home/user/repos/myrepo
3) /home/user/repos/myrepo with -p1 becomes home/user/repos/myrepo
4) /home/user/repos/myrepo with -p2 becomes home/user/repos/myrepo
5) //home/user/repos/myrepo with -p1 becomes /home/user/repos/myrepo
6) //home/user/repos/myrepo with -p2 becomes home/user/repos/myrepo

`Remove  leading slashes`...That's not really what's happening.

What seems to actually happen is that it is removing directories from the path:
1) home/user/repos/myrepo with -p1 becomes home/user/repos/myrepo
2) home/user/repos/myrepo with -p2 becomes user/repos/myrepo

This argument seems to be removing folders from the path, not slashes.

I'm sure it's doing both removing slashes and folders, but at
different times, which makes it even more confusing to anyone trying
to wrap their head around it.

-p1= /home/a -> home/a
-p1= home/a -> home/a ?? Does this happen, or does it actually remove `home`???
-p2=/home/a -> home/a OR a ??? I have no idea after reading the docs
and seeing different behavior. I literally have to experiment with it
to know what it does in each scenario.
-p2=home/a -> a ?? folder and slash removed.

All of this doesn't have to be so complicated, it's just being
expressed in a complicated way.

Break this out into two separate functions maybe, or update the
documentation so it's clearer how this behaves.

> -p - number of folders in path to remove from the beginning of the path.

Not great, but clearer than what's there.


Thanks,
Kelly Elton
http://www.kellyelton.com


Re: [PATCH] apply: clarify "-p" documentation

2018-05-10 Thread Junio C Hamano
Jeff King  writes:

> How about this?
>
> -- >8 --
> Subject: [PATCH] apply: clarify "-p" documentation
>
> We're not really removing slashes, but slash-separated path
> components. Let's make that more clear.
>
> Reported-by: kelly elton 
> Signed-off-by: Jeff King 
> ---
>  Documentation/git-apply.txt | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
> index 4ebc3d3271..c993fbf714 100644
> --- a/Documentation/git-apply.txt
> +++ b/Documentation/git-apply.txt
> @@ -113,8 +113,10 @@ explained for the configuration variable 
> `core.quotePath` (see
>  linkgit:git-config[1]).
>  
>  -p::
> - Remove  leading slashes from traditional diff paths. The
> - default is 1.
> + Remove  leading path components (separated by slashes) from
> + traditional diff paths. E.g., with `-p2`, a patch against
> + `a/dir/file` will be applied directly to `file`. The default is
> + 1.

Thanks for an obvious improvement.  Will queue.

>  
>  -C::
>   Ensure at least  lines of surrounding context match before


Invalid memory access in `git apply`

2017-11-08 Thread mqudsi
**Resending as it seems that the attachments caused the last email to wind up
in a black hole**

There seems to be bug in the `git apply` that leads to out-of-bounds memory
access when --ignore-space-change is combined with --inaccurate-eof and
applying a patch.

On occasion, this can lead to error output like the following:

 mqudsi@ZBook ~> git apply --ignore-space-change --ignore-whitespace
 --allow-overlap --inaccurate-eof without_whitespace.diff
 *** Error in `git': malloc(): memory corruption: 0x02543530 ***
 === Backtrace: =
 /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fdda79c77e5]
 /lib/x86_64-linux-gnu/libc.so.6(+0x8213e)[0x7fdda79d213e]
 /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7fdda79d4184]
 
/lib/x86_64-linux-gnu/libc.so.6(_IO_file_doallocate+0x55)[0x7fdda79bd1d5]
 /lib/x86_64-linux-gnu/libc.so.6(_IO_doallocbuf+0x34)[0x7fdda79cb594]
 
/lib/x86_64-linux-gnu/libc.so.6(_IO_file_overflow+0x1c8)[0x7fdda79ca8f8]
 /lib/x86_64-linux-gnu/libc.so.6(_IO_file_xsputn+0xad)[0x7fdda79c928d]
 /lib/x86_64-linux-gnu/libc.so.6(fputs+0x98)[0x7fdda79be0c8]
 git[0x5386cd]
 git[0x538714]
 git[0x538940]
 git[0x40e220]
 git[0x410a10]
 git[0x41256e]
 git[0x412df7]
 git[0x415935]
 git[0x406436]
 git[0x40555c]

The original file being patched (clipboard.vim) and the patch file that I had
attempted to apply (without_whitespace.diff) are attached, along with the
full, unabridged output of the memory map as a result of the out-of-bounds
access (memory_map.txt).

The memory map output was generated under git 2.7.4; repeated attempts to
reproduce the memory map dump with both 2.7.4 and 2.15 produce the following
output:

 mqudsi@ZBook ~/.c/nvim> git apply --ignore-space-change  
--inaccurate-eof
 --whitespace=fix without_whitespace.diff
 fatal: BUG: caller miscounted postlen: asked 248, orig = 251, used = 
249

Mahmoud Al-Qudsi
NeoSmart Technologies

--Attachments--

* clipboard.vim: http://termbin.com/u25t
* without_whitespace.diff: http://termbin.com/bu9y
* memory_map.txt: http://termbin.com/cboz




trustExitCode doesn't apply to vimdiff mergetool

2016-11-26 Thread Dun Peal
I'm using vimdiff as my mergetool, and have the following lines in ~/.gitconfig:

[merge]
tool = vimdiff
[mergetool "vimdiff"]
trustExitCode = true


My understanding from the docs is that this sets
mergetool.vimdiff.trustExitCode to true, thereby concluding that a
merge hasn't been successful if vimdiff's exit code is non-zero.

Unfortunately, when I exit Vim using `:cq` - which returns code 1 -
the merge is still presumed to have succeeded.

Is there a way to accomplish the desired effect, such that exiting
vimdiff with a non-zero code would prevent git from resolving the
conflict in the merged file?


Re: git 2.6.0 apply --cached failed

2015-09-30 Thread Junio C Hamano
It probably is this one:

http://thread.gmane.org/gmane.comp.version-control.git/270370/focus=270501

Older Git was loose and did not notice it, but the second hunk of
your patch is judged to be broken, with no added or deleted line
whatsoever, by the latest version.
--
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


[PATCH 60/83] apply: libify init_apply_state()

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

diff --git a/apply.c b/apply.c
index 9c5f258..11bec48 100644
--- a/apply.c
+++ b/apply.c
@@ -56,7 +56,7 @@ int parse_ignorewhitespace_option(struct apply_state *state,
return error(_("unrecognized whitespace ignore option '%s'"), option);
 }
 
-void init_apply_state(struct apply_state *state, const char *prefix)
+int init_apply_state(struct apply_state *state, const char *prefix)
 {
memset(state, 0, sizeof(*state));
state->prefix = prefix;
@@ -73,8 +73,9 @@ void init_apply_state(struct apply_state *state, const char 
*prefix)
 
git_apply_config();
if (apply_default_whitespace && parse_whitespace_option(state, 
apply_default_whitespace))
-   exit(1);
+   return -1;
if (apply_default_ignorewhitespace && 
parse_ignorewhitespace_option(state, apply_default_ignorewhitespace))
-   exit(1);
+   return -1;
+   return 0;
 }
 
diff --git a/apply.h b/apply.h
index 70ab658..021e9e3 100644
--- a/apply.h
+++ b/apply.h
@@ -126,7 +126,7 @@ extern int parse_whitespace_option(struct apply_state 
*state,
 extern int parse_ignorewhitespace_option(struct apply_state *state,
 const char *option);
 
-extern void init_apply_state(struct apply_state *state, const char *prefix);
+extern int init_apply_state(struct apply_state *state, const char *prefix);
 
 
 #endif
diff --git a/builtin/apply.c b/builtin/apply.c
index 1d958fa..e3ee199 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4717,7 +4717,8 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix)
OPT_END()
};
 
-   init_apply_state(&state, prefix);
+   if (init_apply_state(&state, prefix))
+   exit(1);
 
argc = parse_options(argc, argv, state.prefix, builtin_apply_options,
apply_usage, 0);
-- 
2.8.1.300.g5fed0c0

--
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


Should "git apply --check" imply verbose?

2013-08-20 Thread Paul Gortmaker
TL;DR -- "git apply --reject" implies verbose, but the similar
"git apply --check" does not, which seems inconsistent.

Background:  A common (non-git) workflow can be to use "patch --dry-run"
to inspect whether a patch is feasible, and then use patch again
a 2nd time (w/o --dry-run) to actually apply it (and then work
through the rejects).

You can also do the above in a git repo, but you lose out because
"patch" doesn't (yet) capture the patched function names[1] in the
rejected hunks, making it hard to double check your work.

My initial thought was to replace the above two steps with
"git apply --check ..." and then "git apply --reject ..." so
that I could just abandon using patch altogether.

That works great, with just one snag that had me go reading the
source.  It seems that "git apply --reject" is verbose, and kind
of looks like the identical output I'd get if I used patch.  But
"git apply --check" is quite reserved in its output and doesn't
look at all like "patch --dry-run".  I initially believed that
"--check" was stopping at the 1st failure, based on the output.

Only when I read the source did I realize it was checking all the
hunks silently, and adding a "-v" would make it similar to the
output from "patch --dry-run".

Not a critical issue by any means, but having the "-v" implied
by "--check" (or perhaps having both default to non-verbose?)
might save other users from getting confused in the same way.

Thanks,
Paul.
--

[1] https://savannah.gnu.org/bugs/index.php?39819
--
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


Re: Segmentation fault in git apply

2015-01-14 Thread Michael Blume
On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume  wrote:
> This is a mac with a fresh build of git from pu branch, commit 53b80d0.
>
> With my gitconfig looking like
>
> [user]
> email = blume.m...@gmail.com
> name = Michael Blume
> [apply]
> whitespace = fix
> [core]
> whitespace = fix,trailing-space,space-before-tab, tab-in-indent, 
> tabwidth=4
>
> If I run
> git clone g...@github.com:MichaelBlume/clojure.git
> cd clojure
> git checkout origin/rebase-start
> git rebase origin/rebase-base
>
> I get
>
> src/jvm/clojure/lang/Compiler.java  |  26
> +-
>  test/clojure/test_clojure/compilation.clj   |  33
> -
>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121
> +
>  3 files changed, 170 insertions(+), 10 deletions(-)
>  create mode 100644 
> test/clojure/test_clojure/compilation/examples_clj_1561.clj
> First, rewinding head to replay your work on top of it...
> Applying: CLJ-1603 - add reducible cycle, iterate, repeat
> Applying: CLJ-1515 Reify range
> Applying: CLJ-1499 Direct iterators for PersistentHashMap,
> APersistentSet, PersistentQueue, and PersistentStructMap, and records.
> Added new IMapIterable interface for key and val iterators.
> Applying: CLJ-1602 Make keys and vals return Iterable result
> Applying: fix AOT bug preventing overriding of clojure.core functions
> Applying: catch multiple rest forms
> Applying: zipmap using iterators and transient maps
> Applying: Define merge/merge-with after reduce has loaded
> Applying: very simple test of the merge function
> Applying: Support get on arbitrary java.util.List instances
> Applying: CLJ-1451 add take-until
> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn
> Applying: add unrolled vector implementation
> Applying: add transient? predicate
> Applying: fix emitted line numbers
> Using index info to reconstruct a base tree...
> M src/jvm/clojure/lang/Compiler.java
> Falling back to patching base and 3-way merge...
> Auto-merging src/jvm/clojure/lang/Compiler.java
> Applying: just use a not
> Applying: trailing whitespace
> Applying: don't mix tabs/spaces in clojure.xml/emit-element
> Applying: avoid mixing tabs with spaces in clojure core code
> Applying: don't optimize for defrecord lookup if keyword is namespaced
> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity
> Applying: unrolled impls for maps
> Applying: CLJ-703: Remove flush and sync calls when writing class files.
> Applying: CLJ-1078: Add queue and queue? to clojure.core
> Applying: make RT.boundedLength lazier
> Applying: first try for adding compare
> Applying: Fix for #CLJ-1565
> Applying: CLJ-1074: Read +/- Infinity and NaN
> Applying: Fix CLJ-1074 for EdnReader too, see
> eaeda2e7bf2697e565decdf14a8a99fbf8588c57
> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms
> Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit
> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string
> Applying: if test expr of an if statement is a literal, don't emit the
> runtime test
> Applying: evaluate def symbol metadata only once
> Applying: CLJ-1295: Speed up dissoc on array-maps
> Applying: some throwing
> Applying: don't pass offset to ArrayChunk
> Applying: make EMPTY accessible
> Applying: add handy create methods
> Applying: regenerate
> Applying: regenerate
> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059
> Segmentation fault: 11  git apply --index "$dotest/patch" > /dev/null
> 2>&1
> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab
> in indent.
>IPersistentVector v = (IPersistentVector) asTransient().conj(val)
> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab
> in indent.
>.persistent();
> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab
> in indent.
>return (IPersistentVector) ((IObj) v).withMeta(meta);
> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab
> in indent.
> ITransientCollection coll = PersistentVector.EMPTY
> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:27: tab
> in indent.
> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)
> warning: squelched 1 whitespace error
> warning: 6 lines add whitespace errors.
> Using index info to reconstruct a base tree...
> M src/jvm/clojure/lang/PersistentUnrolledVector.java
> :13: tab in ind

Re: Segmentation fault in git apply

2015-01-14 Thread Michael Blume
On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume  wrote:
> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume  wrote:
>> This is a mac with a fresh build of git from pu branch, commit 53b80d0.
>>
>> With my gitconfig looking like
>>
>> [user]
>> email = blume.m...@gmail.com
>> name = Michael Blume
>> [apply]
>> whitespace = fix
>> [core]
>> whitespace = fix,trailing-space,space-before-tab, tab-in-indent, 
>> tabwidth=4
>>
>> If I run
>> git clone g...@github.com:MichaelBlume/clojure.git
>> cd clojure
>> git checkout origin/rebase-start
>> git rebase origin/rebase-base
>>
>> I get
>>
>> src/jvm/clojure/lang/Compiler.java  |  26
>> +-
>>  test/clojure/test_clojure/compilation.clj   |  33
>> -
>>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121
>> +
>>  3 files changed, 170 insertions(+), 10 deletions(-)
>>  create mode 100644 
>> test/clojure/test_clojure/compilation/examples_clj_1561.clj
>> First, rewinding head to replay your work on top of it...
>> Applying: CLJ-1603 - add reducible cycle, iterate, repeat
>> Applying: CLJ-1515 Reify range
>> Applying: CLJ-1499 Direct iterators for PersistentHashMap,
>> APersistentSet, PersistentQueue, and PersistentStructMap, and records.
>> Added new IMapIterable interface for key and val iterators.
>> Applying: CLJ-1602 Make keys and vals return Iterable result
>> Applying: fix AOT bug preventing overriding of clojure.core functions
>> Applying: catch multiple rest forms
>> Applying: zipmap using iterators and transient maps
>> Applying: Define merge/merge-with after reduce has loaded
>> Applying: very simple test of the merge function
>> Applying: Support get on arbitrary java.util.List instances
>> Applying: CLJ-1451 add take-until
>> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn
>> Applying: add unrolled vector implementation
>> Applying: add transient? predicate
>> Applying: fix emitted line numbers
>> Using index info to reconstruct a base tree...
>> M src/jvm/clojure/lang/Compiler.java
>> Falling back to patching base and 3-way merge...
>> Auto-merging src/jvm/clojure/lang/Compiler.java
>> Applying: just use a not
>> Applying: trailing whitespace
>> Applying: don't mix tabs/spaces in clojure.xml/emit-element
>> Applying: avoid mixing tabs with spaces in clojure core code
>> Applying: don't optimize for defrecord lookup if keyword is namespaced
>> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity
>> Applying: unrolled impls for maps
>> Applying: CLJ-703: Remove flush and sync calls when writing class files.
>> Applying: CLJ-1078: Add queue and queue? to clojure.core
>> Applying: make RT.boundedLength lazier
>> Applying: first try for adding compare
>> Applying: Fix for #CLJ-1565
>> Applying: CLJ-1074: Read +/- Infinity and NaN
>> Applying: Fix CLJ-1074 for EdnReader too, see
>> eaeda2e7bf2697e565decdf14a8a99fbf8588c57
>> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms
>> Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit
>> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string
>> Applying: if test expr of an if statement is a literal, don't emit the
>> runtime test
>> Applying: evaluate def symbol metadata only once
>> Applying: CLJ-1295: Speed up dissoc on array-maps
>> Applying: some throwing
>> Applying: don't pass offset to ArrayChunk
>> Applying: make EMPTY accessible
>> Applying: add handy create methods
>> Applying: regenerate
>> Applying: regenerate
>> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059
>> Segmentation fault: 11  git apply --index "$dotest/patch" > /dev/null
>> 2>&1
>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab
>> in indent.
>>IPersistentVector v = (IPersistentVector) asTransient().conj(val)
>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab
>> in indent.
>>.persistent();
>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab
>> in indent.
>>return (IPersistentVector) ((IObj) v).withMeta(meta);
>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab
>> in ind

Re: Segmentation fault in git apply

2015-01-14 Thread Michael Blume
On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume  wrote:
> On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume  wrote:
>> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume  wrote:
>>> This is a mac with a fresh build of git from pu branch, commit 53b80d0.
>>>
>>> With my gitconfig looking like
>>>
>>> [user]
>>> email = blume.m...@gmail.com
>>> name = Michael Blume
>>> [apply]
>>> whitespace = fix
>>> [core]
>>> whitespace = fix,trailing-space,space-before-tab, tab-in-indent, 
>>> tabwidth=4
>>>
>>> If I run
>>> git clone g...@github.com:MichaelBlume/clojure.git
>>> cd clojure
>>> git checkout origin/rebase-start
>>> git rebase origin/rebase-base
>>>
>>> I get
>>>
>>> src/jvm/clojure/lang/Compiler.java  |  26
>>> +-
>>>  test/clojure/test_clojure/compilation.clj   |  33
>>> -
>>>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121
>>> +
>>>  3 files changed, 170 insertions(+), 10 deletions(-)
>>>  create mode 100644 
>>> test/clojure/test_clojure/compilation/examples_clj_1561.clj
>>> First, rewinding head to replay your work on top of it...
>>> Applying: CLJ-1603 - add reducible cycle, iterate, repeat
>>> Applying: CLJ-1515 Reify range
>>> Applying: CLJ-1499 Direct iterators for PersistentHashMap,
>>> APersistentSet, PersistentQueue, and PersistentStructMap, and records.
>>> Added new IMapIterable interface for key and val iterators.
>>> Applying: CLJ-1602 Make keys and vals return Iterable result
>>> Applying: fix AOT bug preventing overriding of clojure.core functions
>>> Applying: catch multiple rest forms
>>> Applying: zipmap using iterators and transient maps
>>> Applying: Define merge/merge-with after reduce has loaded
>>> Applying: very simple test of the merge function
>>> Applying: Support get on arbitrary java.util.List instances
>>> Applying: CLJ-1451 add take-until
>>> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn
>>> Applying: add unrolled vector implementation
>>> Applying: add transient? predicate
>>> Applying: fix emitted line numbers
>>> Using index info to reconstruct a base tree...
>>> M src/jvm/clojure/lang/Compiler.java
>>> Falling back to patching base and 3-way merge...
>>> Auto-merging src/jvm/clojure/lang/Compiler.java
>>> Applying: just use a not
>>> Applying: trailing whitespace
>>> Applying: don't mix tabs/spaces in clojure.xml/emit-element
>>> Applying: avoid mixing tabs with spaces in clojure core code
>>> Applying: don't optimize for defrecord lookup if keyword is namespaced
>>> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity
>>> Applying: unrolled impls for maps
>>> Applying: CLJ-703: Remove flush and sync calls when writing class files.
>>> Applying: CLJ-1078: Add queue and queue? to clojure.core
>>> Applying: make RT.boundedLength lazier
>>> Applying: first try for adding compare
>>> Applying: Fix for #CLJ-1565
>>> Applying: CLJ-1074: Read +/- Infinity and NaN
>>> Applying: Fix CLJ-1074 for EdnReader too, see
>>> eaeda2e7bf2697e565decdf14a8a99fbf8588c57
>>> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms
>>> Applying: CLJ-1472 Locking macro without explicit monitor-enter, 
>>> monitor-exit
>>> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string
>>> Applying: if test expr of an if statement is a literal, don't emit the
>>> runtime test
>>> Applying: evaluate def symbol metadata only once
>>> Applying: CLJ-1295: Speed up dissoc on array-maps
>>> Applying: some throwing
>>> Applying: don't pass offset to ArrayChunk
>>> Applying: make EMPTY accessible
>>> Applying: add handy create methods
>>> Applying: regenerate
>>> Applying: regenerate
>>> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059
>>> Segmentation fault: 11  git apply --index "$dotest/patch" > /dev/null
>>> 2>&1
>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab
>>> in indent.
>>>IPersistentVector v = (IPersisten

Re: Segmentation fault in git apply

2015-01-14 Thread Junio C Hamano
Michael Blume  writes:

> This is a mac with a fresh build of git from pu branch, commit 53b80d0.

Hmm, I do not see anything suspicious between master and pu.  Is it
possible to bisect?

--
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


Re: Segmentation fault in git apply

2015-01-14 Thread Michael Blume
On Wed, Jan 14, 2015 at 10:48 AM, Michael Blume  wrote:
> On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume  wrote:
>> On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume  wrote:
>>> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume  
>>> wrote:
>>>> This is a mac with a fresh build of git from pu branch, commit 53b80d0.
>>>>
>>>> With my gitconfig looking like
>>>>
>>>> [user]
>>>> email = blume.m...@gmail.com
>>>> name = Michael Blume
>>>> [apply]
>>>> whitespace = fix
>>>> [core]
>>>> whitespace = fix,trailing-space,space-before-tab, tab-in-indent, 
>>>> tabwidth=4
>>>>
>>>> If I run
>>>> git clone g...@github.com:MichaelBlume/clojure.git
>>>> cd clojure
>>>> git checkout origin/rebase-start
>>>> git rebase origin/rebase-base
>>>>
>>>> I get
>>>>
>>>> src/jvm/clojure/lang/Compiler.java  |  26
>>>> +-
>>>>  test/clojure/test_clojure/compilation.clj   |  33
>>>> -
>>>>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121
>>>> +
>>>>  3 files changed, 170 insertions(+), 10 deletions(-)
>>>>  create mode 100644 
>>>> test/clojure/test_clojure/compilation/examples_clj_1561.clj
>>>> First, rewinding head to replay your work on top of it...
>>>> Applying: CLJ-1603 - add reducible cycle, iterate, repeat
>>>> Applying: CLJ-1515 Reify range
>>>> Applying: CLJ-1499 Direct iterators for PersistentHashMap,
>>>> APersistentSet, PersistentQueue, and PersistentStructMap, and records.
>>>> Added new IMapIterable interface for key and val iterators.
>>>> Applying: CLJ-1602 Make keys and vals return Iterable result
>>>> Applying: fix AOT bug preventing overriding of clojure.core functions
>>>> Applying: catch multiple rest forms
>>>> Applying: zipmap using iterators and transient maps
>>>> Applying: Define merge/merge-with after reduce has loaded
>>>> Applying: very simple test of the merge function
>>>> Applying: Support get on arbitrary java.util.List instances
>>>> Applying: CLJ-1451 add take-until
>>>> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn
>>>> Applying: add unrolled vector implementation
>>>> Applying: add transient? predicate
>>>> Applying: fix emitted line numbers
>>>> Using index info to reconstruct a base tree...
>>>> M src/jvm/clojure/lang/Compiler.java
>>>> Falling back to patching base and 3-way merge...
>>>> Auto-merging src/jvm/clojure/lang/Compiler.java
>>>> Applying: just use a not
>>>> Applying: trailing whitespace
>>>> Applying: don't mix tabs/spaces in clojure.xml/emit-element
>>>> Applying: avoid mixing tabs with spaces in clojure core code
>>>> Applying: don't optimize for defrecord lookup if keyword is namespaced
>>>> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity
>>>> Applying: unrolled impls for maps
>>>> Applying: CLJ-703: Remove flush and sync calls when writing class files.
>>>> Applying: CLJ-1078: Add queue and queue? to clojure.core
>>>> Applying: make RT.boundedLength lazier
>>>> Applying: first try for adding compare
>>>> Applying: Fix for #CLJ-1565
>>>> Applying: CLJ-1074: Read +/- Infinity and NaN
>>>> Applying: Fix CLJ-1074 for EdnReader too, see
>>>> eaeda2e7bf2697e565decdf14a8a99fbf8588c57
>>>> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms
>>>> Applying: CLJ-1472 Locking macro without explicit monitor-enter, 
>>>> monitor-exit
>>>> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string
>>>> Applying: if test expr of an if statement is a literal, don't emit the
>>>> runtime test
>>>> Applying: evaluate def symbol metadata only once
>>>> Applying: CLJ-1295: Speed up dissoc on array-maps
>>>> Applying: some throwing
>>>> Applying: don't pass offset to ArrayChunk
>>>> Applying: make EMPTY accessible
>>>> Applying: add handy create methods
>>>> Appl

Re: Segmentation fault in git apply

2015-01-14 Thread Michael Blume
On Wed, Jan 14, 2015 at 10:58 AM, Michael Blume  wrote:
> On Wed, Jan 14, 2015 at 10:48 AM, Michael Blume  wrote:
>> On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume  wrote:
>>> On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume  
>>> wrote:
>>>> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume  
>>>> wrote:
>>>>> This is a mac with a fresh build of git from pu branch, commit 53b80d0.
>>>>>
>>>>> With my gitconfig looking like
>>>>>
>>>>> [user]
>>>>> email = blume.m...@gmail.com
>>>>> name = Michael Blume
>>>>> [apply]
>>>>> whitespace = fix
>>>>> [core]
>>>>> whitespace = fix,trailing-space,space-before-tab, tab-in-indent, 
>>>>> tabwidth=4
>>>>>
>>>>> If I run
>>>>> git clone g...@github.com:MichaelBlume/clojure.git
>>>>> cd clojure
>>>>> git checkout origin/rebase-start
>>>>> git rebase origin/rebase-base
>>>>>
>>>>> I get
>>>>>
>>>>> src/jvm/clojure/lang/Compiler.java  |  26
>>>>> +-
>>>>>  test/clojure/test_clojure/compilation.clj   |  33
>>>>> -
>>>>>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121
>>>>> +
>>>>>  3 files changed, 170 insertions(+), 10 deletions(-)
>>>>>  create mode 100644 
>>>>> test/clojure/test_clojure/compilation/examples_clj_1561.clj
>>>>> First, rewinding head to replay your work on top of it...
>>>>> Applying: CLJ-1603 - add reducible cycle, iterate, repeat
>>>>> Applying: CLJ-1515 Reify range
>>>>> Applying: CLJ-1499 Direct iterators for PersistentHashMap,
>>>>> APersistentSet, PersistentQueue, and PersistentStructMap, and records.
>>>>> Added new IMapIterable interface for key and val iterators.
>>>>> Applying: CLJ-1602 Make keys and vals return Iterable result
>>>>> Applying: fix AOT bug preventing overriding of clojure.core functions
>>>>> Applying: catch multiple rest forms
>>>>> Applying: zipmap using iterators and transient maps
>>>>> Applying: Define merge/merge-with after reduce has loaded
>>>>> Applying: very simple test of the merge function
>>>>> Applying: Support get on arbitrary java.util.List instances
>>>>> Applying: CLJ-1451 add take-until
>>>>> Applying: CLJ-1606 - complete eduction's xform without completing outer 
>>>>> rfn
>>>>> Applying: add unrolled vector implementation
>>>>> Applying: add transient? predicate
>>>>> Applying: fix emitted line numbers
>>>>> Using index info to reconstruct a base tree...
>>>>> M src/jvm/clojure/lang/Compiler.java
>>>>> Falling back to patching base and 3-way merge...
>>>>> Auto-merging src/jvm/clojure/lang/Compiler.java
>>>>> Applying: just use a not
>>>>> Applying: trailing whitespace
>>>>> Applying: don't mix tabs/spaces in clojure.xml/emit-element
>>>>> Applying: avoid mixing tabs with spaces in clojure core code
>>>>> Applying: don't optimize for defrecord lookup if keyword is namespaced
>>>>> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity
>>>>> Applying: unrolled impls for maps
>>>>> Applying: CLJ-703: Remove flush and sync calls when writing class files.
>>>>> Applying: CLJ-1078: Add queue and queue? to clojure.core
>>>>> Applying: make RT.boundedLength lazier
>>>>> Applying: first try for adding compare
>>>>> Applying: Fix for #CLJ-1565
>>>>> Applying: CLJ-1074: Read +/- Infinity and NaN
>>>>> Applying: Fix CLJ-1074 for EdnReader too, see
>>>>> eaeda2e7bf2697e565decdf14a8a99fbf8588c57
>>>>> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms
>>>>> Applying: CLJ-1472 Locking macro without explicit monitor-enter, 
>>>>> monitor-exit
>>>>> Applying: CLJ-1449: Add starts-with? ends-with? contains? to 
>>>>> clojure.string
>>>>> Applying: if test expr of an if statement 

Re: Segmentation fault in git apply

2015-01-15 Thread Kyle J. McKay

On Jan 14, 2015, at 11:09, Michael Blume wrote:
On Wed, Jan 14, 2015 at 10:58 AM, Michael Blume  
 wrote:
On Wed, Jan 14, 2015 at 10:48 AM, Michael Blume  
 wrote:
On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume > wrote:
On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume > wrote:
On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume > wrote:
This is a mac with a fresh build of git from pu branch, commit  
53b80d0.


With my gitconfig looking like

[user]
   email = blume.m...@gmail.com
   name = Michael Blume
[apply]
   whitespace = fix
[core]
   whitespace = fix,trailing-space,space-before-tab, tab-in- 
indent, tabwidth=4


If I run
git clone g...@github.com:MichaelBlume/clojure.git
cd clojure
git checkout origin/rebase-start
git rebase origin/rebase-base

I get

[...]

Applying: CLJ-1295: Speed up dissoc on array-maps
Applying: some throwing
Applying: don't pass offset to ArrayChunk
Applying: make EMPTY accessible
Applying: add handy create methods
Applying: regenerate
Applying: regenerate
/Users/michael.blume/libexec/git-core/git-am: line 854: 92059
Segmentation fault: 11  git apply --index "$dotest/patch" > / 
dev/null

2>&1


I can reproduce in a 64-bit v2.1.4 as well, but not in a 32-bit v2.1.4  
build.


My recipe is slightly different to facilitate automation:

cd /tmp
git clone git://github.com/MichaelBlume/clojure.git
cd clojure
git config user.email "blume.m...@gmail.com"
git config user.name "Michael Blume"
git config apply.whitespace fix
git config core.whitespace \
  "fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4"
git checkout origin/rebase-start
git rebase origin/rebase-base

Looks like v1.7.6.6 64-bit works okay.

Running git bisect run...

5782..2890..1445..722..361..179..91..44..23..13..7..3..1..0

And the winner is (first appearing in v1.8.2.2):

commit 250b3c6c992b3cb04e756eb33bed99442fc55193
Author: Junio C Hamano 
Date:   Fri Mar 22 11:10:03 2013 -0700

apply --whitespace=fix: avoid running over the postimage buffer

Originally update-pre-post-images could assume that any whitespace
fixing will make the result only shorter by unexpanding runs of
leading SPs into HTs and removing trailing whitespaces at the end  
of

lines.  Updating the post-image we read from the patch to match the
actual result can be performed in-place under this assumption.
These days, however, we have tab-in-indent (aka Python) rule whose
result can be longer than the original, and we do need to allocate
a larger buffer than the input and replace the result.

Fortunately the support for lengthening rewrite was already added
when we began supporting "match while ignoring whitespace
differences" mode in 86c91f91794c (git apply: option to ignore
whitespace differences, 2009-08-04).  We only need to correctly
count the number of bytes necessary to hold the updated result and
tell the function to allocate a new buffer.

Signed-off-by: Junio C Hamano 

And just to confirm, building with 250b3c6c^ (which also happens to be  
v1.8.0.3) does not fail.


And the stack trace from the crash dump of a debug build of 250b3c6c is:

Thread 0 Crashed:
0   libSystem.B.dylib  0x7fff8290242a szone_free + 1222
1   git0x00019fe9 apply_one_fragment + 2164  
(apply.c:2816)
2   git0x0001a760 apply_fragments + 195  
(apply.c:2959)

3   git0x0001b62d apply_data + 96 (apply.c:3340)
4   git0x0001c0b1 check_patch + 869 (apply.c: 
3559)
5   git0x0001c157 check_patch_list + 83  
(apply.c:3574)
6   git0x0001dc70 apply_patch + 646 (apply.c: 
4189)
7   git0x0001ea3a cmd_apply + 2700 (apply.c: 
4418)

8   git0x00011ae8 run_builtin + 402 (git.c:306)
9   git0x00011c9a handle_internal_command +  
181 (git.c:467)

10  git0x00011dab run_argv + 41 (git.c:516)
11  git0x00011ede main + 258 (git.c:588)
12  git0x00010ee8 start + 52

And the gdb backtrace from the core file:

#0  0x7fff8290242a at szone_free + 1222
#1  0x00019fe9 in apply_one_fragment (img=0x7fff5fbfe640,  
frag=0x100400a60, inaccurate_eof=0, ws_rule=3268, nth_fragment=1) at  
builtin/apply.c:2815
#2  0x0001a760 in apply_fragments (img=0x7fff5fbfe640,  
patch=0x1004005e0) at builtin/apply.c:2959
#3  0x0001b62d in apply_data (patch=0x1004005e0,  
st=0x7fff5fbfe6b0, ce=0x1004072e0) at builtin/apply.c:3340
#4  0x0001c0b1 in check_patch (patch=0x1004005e0) at builtin/ 
apply.c:3559
#5  0x0001c157 in check_patch_list (patch=0x1004005e0) at  
builtin/apply.c:3574
#6  0x0001dc70 in apply_patch (fd=3, filename=0x7fff5fbff33a "/ 
private/tmp/clojure/.git/rebase-apply/patch", options=0) at builtin/ 
apply.c:

Re: Segmentation fault in git apply

2015-01-15 Thread Kyle J. McKay

On Jan 15, 2015, at 00:26, Kyle J. McKay wrote:


On Jan 14, 2015, at 11:09, Michael Blume wrote:
On Wed, Jan 14, 2015 at 10:58 AM, Michael Blume  
 wrote:
On Wed, Jan 14, 2015 at 10:48 AM, Michael Blume > wrote:
On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume > wrote:
On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume > wrote:
On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume > wrote:
This is a mac with a fresh build of git from pu branch, commit  
53b80d0.


With my gitconfig looking like

[user]
  email = blume.m...@gmail.com
  name = Michael Blume
[apply]
  whitespace = fix
[core]
  whitespace = fix,trailing-space,space-before-tab, tab-in- 
indent, tabwidth=4


If I run
git clone g...@github.com:MichaelBlume/clojure.git
cd clojure
git checkout origin/rebase-start
git rebase origin/rebase-base

I get

[...]

Applying: CLJ-1295: Speed up dissoc on array-maps
Applying: some throwing
Applying: don't pass offset to ArrayChunk
Applying: make EMPTY accessible
Applying: add handy create methods
Applying: regenerate
Applying: regenerate
/Users/michael.blume/libexec/git-core/git-am: line 854: 92059
Segmentation fault: 11  git apply --index "$dotest/patch" > / 
dev/null

2>&1


I can reproduce in a 64-bit v2.1.4 as well, but not in a 32-bit  
v2.1.4 build.


My recipe is slightly different to facilitate automation:

cd /tmp
git clone git://github.com/MichaelBlume/clojure.git
cd clojure
git config user.email "blume.m...@gmail.com"
git config user.name "Michael Blume"
git config apply.whitespace fix
git config core.whitespace \
 "fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4"
git checkout origin/rebase-start
git rebase origin/rebase-base

Looks like v1.7.6.6 64-bit works okay.

Running git bisect run...

5782..2890..1445..722..361..179..91..44..23..13..7..3..1..0

And the winner is (first appearing in v1.8.2.2):

commit 250b3c6c992b3cb04e756eb33bed99442fc55193
Author: Junio C Hamano 
Date:   Fri Mar 22 11:10:03 2013 -0700

   apply --whitespace=fix: avoid running over the postimage buffer

[...]
And just to confirm, building with 250b3c6c^ (which also happens to  
be v1.8.0.3) does not fail.

[...]
Running with various MallocCheckHeap and MallocErrorAbort settings  
leads to:


git(12926) malloc: *** error for object 0x10040be80: incorrect  
checksum for freed object - object was probably modified after being  
freed.


And a new backtrace from the core file:

#0  0x7fff82962da6 at __kill + 10
#1  0x7fff829c5af8 at szone_error + 476
#2  0x7fff829c7218 at szone_check + 637
#3  0x7fff829caaf8 at malloc_zone_check + 42
#4  0x7fff829cb11d at internal_check + 14
#5  0x7fff828fc939 at malloc_zone_malloc + 60
#6  0x7fff828fc8e0 at malloc + 44
#7  0x000100131ae4 in xmalloc (size=47378) at wrapper.c:50
#8  0x0001950b in update_image (img=0x7fff5fbfe4a0,  
applied_pos=1569, preimage=0x7fff5fbfe340, postimage=0x7fff5fbfe310)  
at builtin/apply.c:2533
#9  0x00019fa7 in apply_one_fragment (img=0x7fff5fbfe4a0,  
frag=0x100400a60, inaccurate_eof=0, ws_rule=3268, nth_fragment=1) at  
builtin/apply.c:2808
#10 0x0001a760 in apply_fragments (img=0x7fff5fbfe4a0,  
patch=0x1004005e0) at builtin/apply.c:2959
#11 0x0001b62d in apply_data (patch=0x1004005e0,  
st=0x7fff5fbfe510, ce=0x1004072e0) at builtin/apply.c:3340
#12 0x0001c0b1 in check_patch (patch=0x1004005e0) at builtin/ 
apply.c:3559
#13 0x0001c157 in check_patch_list (patch=0x1004005e0) at  
builtin/apply.c:3574
#14 0x0001dc70 in apply_patch (fd=9, filename=0x7fff5fbff1e2  
"/private/tmp/clojure/.git/rebase-apply/patch", options=0) at  
builtin/apply.c:4189
#15 0x0001ea3a in cmd_apply (argc=1, argv=0x7fff5fbfefe0,  
prefix_=0x0) at builtin/apply.c:4418
#16 0x00011ae8 in run_builtin (p=0x1001a7070, argc=3,  
argv=0x7fff5fbfefe0) at git.c:306
#17 0x00011c9a in handle_internal_command (argc=3,  
argv=0x7fff5fbfefe0) at git.c:467
#18 0x00011dab in run_argv (argcp=0x7fff5fbfef9c,  
argv=0x7fff5fbfef90) at git.c:513
#19 0x00011ede in main (argc=3, argv=0x7fff5fbfefe0) at  
git.c:588


I looked at the code a bit, but a fix does not just jump out at me.   
From the debug info it seems pretty clear that some memory's being  
stepped on.


If I make this change on top of 250b3c6c:

diff --git a/builtin/apply.c b/builtin/apply.c
index df773c75..8795e830 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2390,6 +2390,8 @@ static int match_fragment(struct image *img,
fixed_buf = strbuf_detach(&fixed, &fixed_len);
if (postlen < postimage->len)
postlen = 0;
+   if (postlen)
+   postlen = 2 * postimage->len;
update_pre_post_images(preimage, postimage,
   fixed_buf, fixed_len, postlen);
return 1;

Then the problem goes away.  That seems to suggest that postlen is

Re: Segmentation fault in git apply

2015-01-16 Thread Junio C Hamano
"Kyle J. McKay"  writes:

> If I make this change on top of 250b3c6c:
>
> diff --git a/builtin/apply.c b/builtin/apply.c
> index df773c75..8795e830 100644
> --- a/builtin/apply.c
> +++ b/builtin/apply.c
> @@ -2390,6 +2390,8 @@ static int match_fragment(struct image *img,
>   fixed_buf = strbuf_detach(&fixed, &fixed_len);
>   if (postlen < postimage->len)
>   postlen = 0;
> + if (postlen)
> + postlen = 2 * postimage->len;
>   update_pre_post_images(preimage, postimage,
>  fixed_buf, fixed_len, postlen);
>   return 1;
>
> Then the problem goes away.  That seems to suggest that postlen is
> being computed incorrectly, but someone more familiar with
> bulitin/apply.c is going to need to look at it.

Indeed, with this, the test case detects under-counting in the
caller (the caller counts 262 bytes but the expansion consumes 273
bytes).

-- >8 --
Subject: apply: make update_pre_post_images() sanity check the given postlen

---
 builtin/apply.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/builtin/apply.c b/builtin/apply.c
index 622ee16..18b7997 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2174,6 +2174,10 @@ static void update_pre_post_images(struct image 
*preimage,
/* Fix the length of the whole thing */
postimage->len = new - postimage->buf;
postimage->nr -= reduced;
+
+   if (postlen && postlen < (new - postimage->buf))
+   die("BUG: postlen = %d, used = %d",
+   (int)postlen, (int)(new - postimage->buf));
 }
 
 static int match_fragment(struct image *img,
-- 
2.3.0-rc0-149-g0286818

--
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


Re: Bug Report for git apply

2019-04-11 Thread SZEDER Gábor
On Thu, Apr 11, 2019 at 03:16:22PM -0400, Can Gemicioglu wrote:
> I noticed a problem when trying to apply a patch file that contained
> many separate patches in a single file.

To quote the first line of its manpage :) 'git apply' is meant to
"Apply a patch to files and/or to the index".  Note the singular "a
patch"; not multiple patches in the same or multiple files.

Use 'git am' instead, that is its job, and as you noted, it works.

> Trying to apply this patch gave me a "No such file or directory" error for 
> one of the files in the middle and after looking around I realised this file 
> was also created earlier in the patch. I tested this myself with these steps 
> and saw a similar error:
> 
> 1. Create a new file and commit.
> 2. Move the file to a different folder and commit.
> 3. Create a single patch for these 2 commits by using git format-patch and 
> concatenating the two resulting files (01.patch, 02.patch) into one 
> (combined.patch).
> 4. Roll back to 2 commits earlier.
> 
> At that point if I try to use 'git apply combined.patch', it will
> throw the same no such file error. However, if I use 'git am
> combined.patch' instead it works. If I apply the first 2 patches
> separately instead, using 'git apply 0*' it also works but if I
> first try to check if it will work with 'git apply --check 0*' it
> actually throws the same error again.
> 
> I'm guessing there's something like a check to make sure the file exists that 
> throws an error even if the file was going to be created by previous commits.
> 
> Tested on git version 2.21.0 on Ubuntu 18.04
> 
> Best,
> Can Gemicioglu


[PATCH] Remove git-apply-patch-script.

2005-08-26 Thread Junio C Hamano
Now the rebase is rewritten to use git cherry-pick, there is no user
for that ancient script.  I've checked Cogito and StGIT to make sure
they do not use it.

Signed-off-by: Junio C Hamano <[EMAIL PROTECTED]>

---

 Documentation/git-apply-patch-script.txt   |   32 
 Documentation/git.txt  |3 
 .../howto/rebase-from-internal-branch.txt  |2 
 Makefile   |    2 
 git-apply-patch-script |  144 
 git-cherry |   14 --
 6 files changed, 4 insertions(+), 193 deletions(-)
 delete mode 100644 Documentation/git-apply-patch-script.txt
 delete mode 100755 git-apply-patch-script

ad3f5eb30999095f276f8d4664f3e7884296c797
diff --git a/Documentation/git-apply-patch-script.txt 
b/Documentation/git-apply-patch-script.txt
deleted file mode 100644
--- a/Documentation/git-apply-patch-script.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-git-apply-patch-script(1)
-=
-v0.99.4, May 2005
-
-NAME
-
-git-apply-patch-script - Sample script to apply the diffs from git-diff-*
-
-
-SYNOPSIS
-
-'git-apply-patch-script'
-
-DESCRIPTION

-This is a sample script to be used via the 'GIT_EXTERNAL_DIFF'
-environment variable to apply the differences that the "git-diff-*"
-family of commands report to the current work tree.
-
-
-Author
---
-Written by Junio C Hamano <[EMAIL PROTECTED]>
-
-Documentation
---
-Documentation by David Greaves, Junio C Hamano and the git-list 
.
-
-GIT

-Part of the link:git.html[git] suite
-
diff --git a/Documentation/git.txt b/Documentation/git.txt
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -242,9 +242,6 @@ Ancillary Commands
 --
 Manipulators:
 
-link:git-apply-patch-script.html[git-apply-patch-script]::
-   Sample script to apply the diffs from git-diff-*
-
 link:git-convert-cache.html[git-convert-cache]::
Converts old-style GIT repository
 
diff --git a/Documentation/howto/rebase-from-internal-branch.txt 
b/Documentation/howto/rebase-from-internal-branch.txt
--- a/Documentation/howto/rebase-from-internal-branch.txt
+++ b/Documentation/howto/rebase-from-internal-branch.txt
@@ -38,7 +38,7 @@ ancestry graph looked like this:
 So I started from master, made a bunch of edits, and committed:
 
 $ git checkout master
-$ cd Documentation; ed git.txt git-apply-patch-script.txt ...
+$ cd Documentation; ed git.txt ...
 $ cd ..; git add Documentation/*.txt
 $ git commit -s -v
 
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -57,7 +57,7 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powe
 
 
 
-SCRIPTS=git git-apply-patch-script git-merge-one-file-script git-prune-script \
+SCRIPTS=git git-merge-one-file-script git-prune-script \
git-pull-script git-tag-script git-resolve-script git-whatchanged \
git-fetch-script git-status-script git-commit-script \
git-log-script git-shortlog git-cvsimport-script git-diff-script \
diff --git a/git-apply-patch-script b/git-apply-patch-script
deleted file mode 100755
--- a/git-apply-patch-script
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2005 Junio C Hamano
-#
-# Applying diff between two trees to the work tree can be
-# done with the following single command:
-#
-# GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $tree1 $tree2
-#
-
-case "$#" in
-1)
-echo >&2 "cannot handle unmerged diff on path $1."
-exit 1 ;;
-8 | 9)
-echo >&2 "cannot handle rename diff between $1 and $8 yet."
-exit 1 ;;
-esac
-name="$1" tmp1="$2" hex1="$3" mode1="$4" tmp2="$5" hex2="$6" mode2="$7"
-
-type1=f
-case "$mode1" in
-*120???) type1=l  ;;
-*1007??) mode1=+x ;;
-*1006??) mode1=-x ;;
-.)   type1=-  ;; 
-esac
-
-type2=f
-case "$mode2" in
-*120???) type2=l  ;;
-*1007??) mode2=+x ;;
-*1006??) mode2=-x ;;
-.)   type2=-  ;; 
-esac
-
-case "$type1,$type2" in
-
--,?)
-dir=$(dirname "$name")
-case "$dir" in '' | .) ;; *) mkdir -p "$dir" ;; esac || {
-   echo >&2 "cannot create leading path for $name."
-   exit 1
-}
-if test -e "$name"
-then
-   echo >&2 "path $name to be created already exists."
-   exit 1
-fi
-case "$type2" in
-f)
-# creating a regular file
-   cat "$tmp2" >"$name" || {
-   echo >&2 "cannot create a regular file $name."
-   exit 1
-   } 
-   case "$mode2" in
-   +x)
-   echo >&2 "created a regular file $name with mode +x."
-   chmod "$mode2" "$name"
-   

Behavior of stash apply vs merge

2013-01-27 Thread Robin Rosenberg
Hi,

What good reason is it that 'git stash apply' gives hairy conflict markers, 
while 'git merge stash' does not. No renames involved.

-- robin
--
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


[PATCH 2/3] apply: simplify build_fake_ancestor()

2013-01-31 Thread Junio C Hamano
The local variable sha1_ptr in the build_fake_ancestor() function
used to either point at the null_sha1[] (if the ancestor did not
have the path) or at sha1[] (if we read the object name into the
local array), but 7a98869 (apply: get rid of --index-info in favor
of --build-fake-ancestor, 2007-09-17) made the "missing in the
ancestor" case unnecessary, hence sha1_ptr, when used, always points
at the local array.

Get rid of the unneeded variable, and restructure the if/else
cascade a bit to make it easier to read.  There should be no
behaviour change.

Signed-off-by: Junio C Hamano 
---
 builtin/apply.c | 26 --
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 156b3ce..a1db7b4 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -3598,7 +3598,6 @@ static void build_fake_ancestor(struct patch *list, const 
char *filename)
 * worth showing the new sha1 prefix, but until then...
 */
for (patch = list; patch; patch = patch->next) {
-   const unsigned char *sha1_ptr;
unsigned char sha1[20];
struct cache_entry *ce;
const char *name;
@@ -3606,20 +3605,19 @@ static void build_fake_ancestor(struct patch *list, 
const char *filename)
name = patch->old_name ? patch->old_name : patch->new_name;
if (0 < patch->is_new)
continue;
-   else if (get_sha1_blob(patch->old_sha1_prefix, sha1))
-   /* git diff has no index line for mode/type changes */
-   if (!patch->lines_added && !patch->lines_deleted) {
-   if (get_current_sha1(patch->old_name, sha1))
-   die("mode change for %s, which is not "
-   "in current HEAD", name);
-   sha1_ptr = sha1;
-   } else
-   die("sha1 information is lacking or useless "
-   "(%s).", name);
-   else
-   sha1_ptr = sha1;
 
-   ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0);
+   if (!get_sha1_blob(patch->old_sha1_prefix, sha1)) {
+   ; /* ok */
+   } else if (!patch->lines_added && !patch->lines_deleted) {
+   /* mode-only change: update the current */
+   if (get_current_sha1(patch->old_name, sha1))
+   die("mode change for %s, which is not "
+   "in current HEAD", name);
+   } else
+   die("sha1 information is lacking or useless "
+   "(%s).", name);
+
+   ce = make_cache_entry(patch->old_mode, sha1, name, 0, 0);
if (!ce)
die(_("make_cache_entry failed for path '%s'"), name);
if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))
-- 
1.8.1.2.612.g09f4be5

--
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


Re: Invalid memory access in `git apply`

2017-11-11 Thread René Scharfe
Am 08.11.2017 um 17:58 schrieb mqu...@neosmart.net:
> **Resending as it seems that the attachments caused the last email to wind up
> in a black hole**
> 
> There seems to be bug in the `git apply` that leads to out-of-bounds memory
> access when --ignore-space-change is combined with --inaccurate-eof and
> applying a patch.
> 
> On occasion, this can lead to error output like the following:
> 
>    mqudsi@ZBook ~> git apply --ignore-space-change --ignore-whitespace
>--allow-overlap --inaccurate-eof without_whitespace.diff
>*** Error in `git': malloc(): memory corruption: 0x02543530 ***
>=== Backtrace: =
>/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fdda79c77e5]
>/lib/x86_64-linux-gnu/libc.so.6(+0x8213e)[0x7fdda79d213e]
>/lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7fdda79d4184]
>
> /lib/x86_64-linux-gnu/libc.so.6(_IO_file_doallocate+0x55)[0x7fdda79bd1d5]
>/lib/x86_64-linux-gnu/libc.so.6(_IO_doallocbuf+0x34)[0x7fdda79cb594]
>
> /lib/x86_64-linux-gnu/libc.so.6(_IO_file_overflow+0x1c8)[0x7fdda79ca8f8]
>/lib/x86_64-linux-gnu/libc.so.6(_IO_file_xsputn+0xad)[0x7fdda79c928d]
>/lib/x86_64-linux-gnu/libc.so.6(fputs+0x98)[0x7fdda79be0c8]
>git[0x5386cd]
>git[0x538714]
>git[0x538940]
>git[0x40e220]
>git[0x410a10]
>git[0x41256e]
>git[0x412df7]
>git[0x415935]
>git[0x406436]
>git[0x40555c]
> 
> The original file being patched (clipboard.vim) and the patch file that I had
> attempted to apply (without_whitespace.diff) are attached, along with the
> full, unabridged output of the memory map as a result of the out-of-bounds
> access (memory_map.txt).
> 
> The memory map output was generated under git 2.7.4; repeated attempts to
> reproduce the memory map dump with both 2.7.4 and 2.15 produce the following
> output:
> 
>mqudsi@ZBook ~/.c/nvim> git apply --ignore-space-change  
> --inaccurate-eof
>--whitespace=fix without_whitespace.diff
>fatal: BUG: caller miscounted postlen: asked 248, orig = 251, used = 
> 249
> 
> Mahmoud Al-Qudsi
> NeoSmart Technologies
> 
> --Attachments--
> 
> * clipboard.vim: http://termbin.com/u25t
> * without_whitespace.diff: http://termbin.com/bu9y
> * memory_map.txt: http://termbin.com/cboz

Thank you for reporting the issue!

There seem to be at least two bugs in git apply and two problems on your
end.  You don't seem need the option --inaccurate-eof and it's causing
trouble for you; I suggest to leave it out.

And the second hunk of your diff doesn't apply because the "endif"
context line doesn't match the "endif" line in clipboard.vim which has
no leading whitespace.  --ignore-space-change ignores changes in the
number of whitespace characters, but that number cannot be 0 on only one
side.

If you adjust the diff by removing the tab from that context line or add
one or more spaces in clipboard.vim before the last "endif" then it will
apply without --inaccurate-eof.


One of the bugs is that fuzzy_matchlines() does out-of-bounds reads in
some cases.  You should only notice it with a tool like Valgrind, ASan
or perhaps a hardened malloc(3).  I'll send a separate patch for that.

The second bug is that --inaccurate-eof triggers a sanity check when
used together with --ignore-space-change.  Here's a simpler reproduction
recipe:

  git init repo
  cd repo

  echo 1 >a
  git add a
  git commit -m initial

  echo 2 >a
  git diff >a.diff

  git reset --hard
  git apply --ignore-space-change --inaccurate-eof a.diff

Which yields this error message:

  fatal: BUG: caller miscounted postlen: asked 1, orig = 1, used = 2

Perhaps the first thing we'd need would be a couple of tests showing
the expected behavior of git apply --inaccurate-eof with and without
trailing newlines..

René


[PATCH] apply: remove prefix_length member from apply_state

2017-08-09 Thread René Scharfe
Use a NULL-and-NUL check to see if we have a prefix and consistently use
C string functions on it instead of storing its length in a member of
struct apply_state.  This avoids strlen() calls and simplifies the code.

Signed-off-by: Rene Scharfe 
---
 apply.c | 12 +---
 apply.h |  1 -
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/apply.c b/apply.c
index 970bed6d41..168dfe3d16 100644
--- a/apply.c
+++ b/apply.c
@@ -80,7 +80,6 @@ int init_apply_state(struct apply_state *state,
 {
memset(state, 0, sizeof(*state));
state->prefix = prefix;
-   state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
state->lock_file = lock_file;
state->newfd = -1;
    state->apply = 1;
@@ -786,11 +785,11 @@ static int guess_p_value(struct apply_state *state, const 
char *nameline)
 * Does it begin with "a/$our-prefix" and such?  Then this is
     * very likely to apply to our directory.
 */
-   if (!strncmp(name, state->prefix, state->prefix_length))
+   if (starts_with(name, state->prefix))
val = count_slashes(state->prefix);
else {
cp++;
-   if (!strncmp(cp, state->prefix, state->prefix_length))
+   if (starts_with(cp, state->prefix))
val = count_slashes(state->prefix) + 1;
}
}
@@ -2088,10 +2087,9 @@ static int use_patch(struct apply_state *state, struct 
patch *p)
int i;
 
/* Paths outside are not touched regardless of "--include" */
-   if (0 < state->prefix_length) {
-   int pathlen = strlen(pathname);
-   if (pathlen <= state->prefix_length ||
-   memcmp(state->prefix, pathname, state->prefix_length))
+   if (state->prefix && *state->prefix) {
+   const char *rest;
+   if (!skip_prefix(pathname, state->prefix, &rest) || !*rest)
return 0;
}
 
diff --git a/apply.h b/apply.h
index b3d6783d55..d9b3957703 100644
--- a/apply.h
+++ b/apply.h
@@ -35,7 +35,6 @@ enum apply_verbosity {
 
 struct apply_state {
const char *prefix;
-   int prefix_length;
 
/* These are lock_file related */
struct lock_file *lock_file;
-- 
2.14.0


Apply for your loan today at 2%

2017-09-03 Thread Dario
Apply for your loan today at a very low interest rate of 2%..We offer loan to 
every Individuals and Company's... If you are in need of any kinds of loan, do 
contact us now for more info


[PATCH] apply: fix grammar error in comment

2018-06-06 Thread Elijah Newren
Signed-off-by: Elijah Newren 
---
 apply.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/apply.c b/apply.c
index d79e61591b..85f2c92740 100644
--- a/apply.c
+++ b/apply.c
@@ -4053,7 +4053,7 @@ static int preimage_oid_in_gitlink_patch(struct patch *p, 
struct object_id *oid)
return get_oid_hex(p->old_sha1_prefix, oid);
 }
 
-/* Build an index that contains the just the files needed for a 3way merge */
+/* Build an index that contains just the files needed for a 3way merge */
 static int build_fake_ancestor(struct apply_state *state, struct patch *list)
 {
struct patch *patch;
-- 
2.18.0.rc0.46.g9cee8fce43



[PATCH] cvsimport: apply shell-quoting regex globally

2017-12-08 Thread Jeff King
Commit 5b4efea666 (cvsimport: shell-quote variable used in
backticks, 2017-09-11) tried to shell-quote a variable, but
forgot to use the "/g" modifier to apply the quoting to the
whole variable. This means we'd miss any embedded
single-quotes after the first one.

Reported-by: 
Signed-off-by: Jeff King 
---
 git-cvsimport.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 36929921ea..2d8df83172 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -642,7 +642,7 @@ sub is_sha1 {
 
 sub get_headref ($) {
my $name = shift;
-   $name =~ s/'/'\\''/;
+   $name =~ s/'/'\\''/g;
my $r = `git rev-parse --verify '$name' 2>/dev/null`;
return undef unless $? == 0;
chomp $r;
-- 
2.15.1.659.g8bd2eae3ea


[PATCH 07/37] apply: rename 'try' variables

2018-01-29 Thread Brandon Williams
Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams 
---
 apply.c | 68 -
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/apply.c b/apply.c
index 321a9fa68..071f653c6 100644
--- a/apply.c
+++ b/apply.c
@@ -2386,8 +2386,8 @@ static void update_pre_post_images(struct image *preimage,
 static int line_by_line_fuzzy_match(struct image *img,
struct image *preimage,
struct image *postimage,
-   unsigned long try,
-   int try_lno,
+   unsigned long current,
+   int current_lno,
int preimage_limit)
 {
int i;
@@ -2404,9 +2404,9 @@ static int line_by_line_fuzzy_match(struct image *img,
 
for (i = 0; i < preimage_limit; i++) {
size_t prelen = preimage->line[i].len;
-   size_t imglen = img->line[try_lno+i].len;
+   size_t imglen = img->line[current_lno+i].len;
 
-   if (!fuzzy_matchlines(img->buf + try + imgoff, imglen,
+   if (!fuzzy_matchlines(img->buf + current + imgoff, imglen,
  preimage->buf + preoff, prelen))
return 0;
if (preimage->line[i].flag & LINE_COMMON)
@@ -2443,7 +2443,7 @@ static int line_by_line_fuzzy_match(struct image *img,
 */
extra_chars = preimage_end - preimage_eof;
strbuf_init(&fixed, imgoff + extra_chars);
-   strbuf_add(&fixed, img->buf + try, imgoff);
+   strbuf_add(&fixed, img->buf + current, imgoff);
strbuf_add(&fixed, preimage_eof, extra_chars);
fixed_buf = strbuf_detach(&fixed, &fixed_len);
update_pre_post_images(preimage, postimage,
@@ -2455,8 +2455,8 @@ static int match_fragment(struct apply_state *state,
  struct image *img,
  struct image *preimage,
  struct image *postimage,
- unsigned long try,
- int try_lno,
+ unsigned long current,
+ int current_lno,
  unsigned ws_rule,
  int match_beginning, int match_end)
 {
@@ -2466,12 +2466,12 @@ static int match_fragment(struct apply_state *state,
size_t fixed_len, postlen;
int preimage_limit;
 
-   if (preimage->nr + try_lno <= img->nr) {
+   if (preimage->nr + current_lno <= img->nr) {
/*
 * The hunk falls within the boundaries of img.
 */
preimage_limit = preimage->nr;
-   if (match_end && (preimage->nr + try_lno != img->nr))
+   if (match_end && (preimage->nr + current_lno != img->nr))
return 0;
} else if (state->ws_error_action == correct_ws_error &&
   (ws_rule & WS_BLANK_AT_EOF)) {
@@ -2482,7 +2482,7 @@ static int match_fragment(struct apply_state *state,
 * match with img, and the remainder of the preimage
 * must be blank.
 */
-   preimage_limit = img->nr - try_lno;
+   preimage_limit = img->nr - current_lno;
} else {
/*
 * The hunk extends beyond the end of the img and
@@ -2492,27 +2492,27 @@ static int match_fragment(struct apply_state *state,
return 0;
}
 
-   if (match_beginning && try_lno)
+   if (match_beginning && current_lno)
return 0;
 
/* Quick hash check */
for (i = 0; i < preimage_limit; i++)
-   if ((img->line[try_lno + i].flag & LINE_PATCHED) ||
-   (preimage->line[i].hash != img->line[try_lno + i].hash))
+   if ((img->line[current_lno + i].flag & LINE_PATCHED) ||
+   (preimage->line[i].hash != img->line[current_lno + i].hash))
return 0;
 
if (preimage_limit == preimage->nr) {
/*
 * Do we have an exact match?  If we were told to match
-* at the end, size must be exactly at try+fragsize,
-* otherwise try+fragsize must be still within the preimage,
+* at the end, size must be exactly at current+fragsize,
+* otherwise current+fragsize must be still within the preimage,
 * and either case, the old piece should match the preimage
 * exactly.
 */
if ((match_end
-? (try + preimage->len == img->len)
-: (try + preimage->len <= img->len)) &&
-   !memcmp(img->buf + try, preimage->buf, p

[PATCH 08/37] apply: rename 'new' variables

2018-01-29 Thread Brandon Williams
Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams 
---
 apply.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/apply.c b/apply.c
index 071f653c6..657c73930 100644
--- a/apply.c
+++ b/apply.c
@@ -2301,7 +2301,7 @@ static void update_pre_post_images(struct image *preimage,
   size_t len, size_t postlen)
 {
int i, ctx, reduced;
-   char *new, *old, *fixed;
+   char *new_buf, *old, *fixed;
struct image fixed_preimage;
 
/*
@@ -2329,18 +2329,18 @@ static void update_pre_post_images(struct image 
*preimage,
 */
old = postimage->buf;
if (postlen)
-   new = postimage->buf = xmalloc(postlen);
+   new_buf = postimage->buf = xmalloc(postlen);
else
-   new = old;
+   new_buf = old;
fixed = preimage->buf;
 
for (i = reduced = ctx = 0; i < postimage->nr; i++) {
size_t l_len = postimage->line[i].len;
if (!(postimage->line[i].flag & LINE_COMMON)) {
/* an added line -- no counterparts in preimage */
-   memmove(new, old, l_len);
+   memmove(new_buf, old, l_len);
old += l_len;
-   new += l_len;
+   new_buf += l_len;
continue;
}
 
@@ -2365,21 +2365,21 @@ static void update_pre_post_images(struct image 
*preimage,
 
/* and copy it in, while fixing the line length */
l_len = preimage->line[ctx].len;
-   memcpy(new, fixed, l_len);
-   new += l_len;
+   memcpy(new_buf, fixed, l_len);
+   new_buf += l_len;
fixed += l_len;
postimage->line[i].len = l_len;
ctx++;
}
 
if (postlen
-   ? postlen < new - postimage->buf
-   : postimage->len < new - postimage->buf)
+   ? postlen < new_buf - postimage->buf
+   : postimage->len < new_buf - postimage->buf)
die("BUG: caller miscounted postlen: asked %d, orig = %d, used 
= %d",
-   (int)postlen, (int) postimage->len, (int)(new - 
postimage->buf));
+   (int)postlen, (int) postimage->len, (int)(new_buf - 
postimage->buf));
 
/* Fix the length of the whole thing */
-   postimage->len = new - postimage->buf;
+   postimage->len = new_buf - postimage->buf;
postimage->nr -= reduced;
 }
 
@@ -4163,30 +4163,30 @@ static void show_mode_change(struct patch *p, int 
show_name)
 static void show_rename_copy(struct patch *p)
 {
const char *renamecopy = p->is_rename ? "rename" : "copy";
-   const char *old, *new;
+   const char *old, *new_name;
 
/* Find common prefix */
old = p->old_name;
-   new = p->new_name;
+   new_name = p->new_name;
while (1) {
const char *slash_old, *slash_new;
slash_old = strchr(old, '/');
-   slash_new = strchr(new, '/');
+   slash_new = strchr(new_name, '/');
if (!slash_old ||
!slash_new ||
-   slash_old - old != slash_new - new ||
-   memcmp(old, new, slash_new - new))
+   slash_old - old != slash_new - new_name ||
+   memcmp(old, new_name, slash_new - new_name))
break;
old = slash_old + 1;
-   new = slash_new + 1;
+   new_name = slash_new + 1;
}
-   /* p->old_name thru old is the common prefix, and old and new
+   /* p->old_name thru old is the common prefix, and old and new_name
 * through the end of names are renames
 */
if (old != p->old_name)
printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
   (int)(old - p->old_name), p->old_name,
-  old, new, p->score);
+  old, new_name, p->score);
else
printf(" %s %s => %s (%d%%)\n", renamecopy,
   p->old_name, p->new_name, p->score);
-- 
2.16.0.rc1.238.g530d649a79-goog



Different result with `git apply` and `patch`

2015-07-08 Thread Benjamin Poirier
Hi,

Is it expected that `git apply` and `patch` produce a different result
when given a patch that applies cleanly but with offsets?

Specifically, using the source file and patch file found here:
https://gist.github.com/benthaman/d4e80e1e2e5e0273f874
https://gist.github.com/benthaman/d48d017179a8292c3f75

ben@f1:/tmp/report$ mkdir p g
ben@f1:/tmp/report$ cp ib_isert.c p
ben@f1:/tmp/report$ cp ib_isert.c g
ben@f1:/tmp/report$ cd p/
ben@f1:/tmp/report/p$ patch -p5 < 
../0123-IB-isert-pass-scatterlist-instead-of-cmd-to-fast_reg.patch
patching file ib_isert.c
Hunk #1 succeeded at 2322 (offset 131 lines).
Hunk #2 succeeded at 2408 (offset 131 lines).
Hunk #3 succeeded at 2474 (offset 131 lines).
ben@f1:/tmp/report/p$ cd ../g
ben@f1:/tmp/report/g$ git apply -p5 -v < 
../0123-IB-isert-pass-scatterlist-instead-of-cmd-to-fast_reg.patch
Checking patch ib_isert.c...
Hunk #1 succeeded at 2322 (offset 131 lines).
Hunk #2 succeeded at 2199 (offset -78 lines).
Hunk #3 succeeded at 2474 (offset 131 lines).
Applied patch ib_isert.c cleanly.


ben@f1:/tmp/report$ git --version
git version 2.4.3
ben@f1:/tmp/report$ patch --version
GNU patch 2.7.1
[...]

I see why it happens, but I'd like the two tools to produce the same
result!

Thanks,
-Benjamin
--
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


[PATCH] builtin/apply: include declaration of cmd_apply()

2016-06-29 Thread Ramsay Jones

Signed-off-by: Ramsay Jones 
---

Hi Christian,

If you need to re-roll your 'cc/apply-am' branch, could you please
squash this into the relevant patch. Commit 95a3b0ba ("apply: move
libified code from builtin/apply.c to apply.{c,h}", 22-04-2016)
removed this '#include "builtin.h"' line, which causes sparse to
issue a warning.

Thanks!

ATB,
Ramsay Jones

 builtin/apply.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtin/apply.c b/builtin/apply.c
index 066cb29..9c66474 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "builtin.h"
 #include "parse-options.h"
 #include "lockfile.h"
 #include "apply.h"
-- 
2.9.0
--
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


Re: trustExitCode doesn't apply to vimdiff mergetool

2016-11-26 Thread Jeff King
On Sat, Nov 26, 2016 at 09:44:36PM -0500, Dun Peal wrote:

> I'm using vimdiff as my mergetool, and have the following lines in
> ~/.gitconfig:
> 
> [merge]
> tool = vimdiff
> [mergetool "vimdiff"]
> trustExitCode = true
> 
> 
> My understanding from the docs is that this sets
> mergetool.vimdiff.trustExitCode to true, thereby concluding that a
> merge hasn't been successful if vimdiff's exit code is non-zero.
> 
> Unfortunately, when I exit Vim using `:cq` - which returns code 1 -
> the merge is still presumed to have succeeded.
> 
> Is there a way to accomplish the desired effect, such that exiting
> vimdiff with a non-zero code would prevent git from resolving the
> conflict in the merged file?

I don't use mergetool myself, but peeking at the code, it looks like
trustExitCode is used only for a "user" tool, not for the builtin tool
profiles. That sounds kind of confusing to me, but I'll leave discussion
of that to people more interested in mergetool.

However, I think you can work around it by defining your own tool that
runs vimdiff:

  git config merge.tool foo
  git config mergetool.foo.cmd 'vimdiff "$LOCAL" "$BASE" "$REMOTE" "$MERGED"'
  git config mergetool.foo.trustExitCode true

Though note that the builtin vimdiff invocation is a little more
complicated than that. You may want to adapt what is in git.git's
mergetools/vimdiff to your liking.

-Peff


Re: trustExitCode doesn't apply to vimdiff mergetool

2016-11-27 Thread Dun Peal
Thanks, Jeff.

Ignoring a non-zero exit code from the merge tool, and assuming a
successful merge in that case, seems like the wrong default behavior
to me.

If your merge tool quit with an error, it is more sensible to assume
that the resolution you were working on has not been successfully
concluded.

In the rare case where one did successfully conclude the resolution,
you can always quickly mark the file resolved. I'm not even sure how
to do that short of `git checkout -m -- file`, which would lose any
work you've already done towards the merge.

Long story short, I hope the developers change this default, or at
least let us override it for the builtin invocations.

Finally, if you're not using mergetools, how do you resolve conflicts?

On Sun, Nov 27, 2016 at 12:08 AM, Jeff King  wrote:
> On Sat, Nov 26, 2016 at 09:44:36PM -0500, Dun Peal wrote:
>
>> I'm using vimdiff as my mergetool, and have the following lines in
>> ~/.gitconfig:
>>
>> [merge]
>> tool = vimdiff
>> [mergetool "vimdiff"]
>> trustExitCode = true
>>
>>
>> My understanding from the docs is that this sets
>> mergetool.vimdiff.trustExitCode to true, thereby concluding that a
>> merge hasn't been successful if vimdiff's exit code is non-zero.
>>
>> Unfortunately, when I exit Vim using `:cq` - which returns code 1 -
>> the merge is still presumed to have succeeded.
>>
>> Is there a way to accomplish the desired effect, such that exiting
>> vimdiff with a non-zero code would prevent git from resolving the
>> conflict in the merged file?
>
> I don't use mergetool myself, but peeking at the code, it looks like
> trustExitCode is used only for a "user" tool, not for the builtin tool
> profiles. That sounds kind of confusing to me, but I'll leave discussion
> of that to people more interested in mergetool.
>
> However, I think you can work around it by defining your own tool that
> runs vimdiff:
>
>   git config merge.tool foo
>   git config mergetool.foo.cmd 'vimdiff "$LOCAL" "$BASE" "$REMOTE" "$MERGED"'
>   git config mergetool.foo.trustExitCode true
>
> Though note that the builtin vimdiff invocation is a little more
> complicated than that. You may want to adapt what is in git.git's
> mergetools/vimdiff to your liking.
>
> -Peff


Re: trustExitCode doesn't apply to vimdiff mergetool

2016-11-27 Thread Jeff King
On Sun, Nov 27, 2016 at 08:46:40AM -0500, Dun Peal wrote:

> Ignoring a non-zero exit code from the merge tool, and assuming a
> successful merge in that case, seems like the wrong default behavior
> to me.

Yeah, I'm inclined to agree. But like I said, I'm not too familiar with
this area, so maybe there are subtle things I'm missing.

> Finally, if you're not using mergetools, how do you resolve conflicts?

I just edit the conflicted sections in vim. I do use git-jump (see
contrib/git-jump), but that's just to get to them quickly.

-Peff


Re: trustExitCode doesn't apply to vimdiff mergetool

2016-11-27 Thread David Aguilar
On Sun, Nov 27, 2016 at 11:55:59AM -0500, Jeff King wrote:
> On Sun, Nov 27, 2016 at 08:46:40AM -0500, Dun Peal wrote:
> 
> > Ignoring a non-zero exit code from the merge tool, and assuming a
> > successful merge in that case, seems like the wrong default behavior
> > to me.
> 
> Yeah, I'm inclined to agree. But like I said, I'm not too familiar with
> this area, so maybe there are subtle things I'm missing.

I think this may have been an oversight in how the
trust-exit-code feature is implemented across builtins.

Right now, specific builtin tools could in theory opt-in to the
feature, but I think it should be handled in a central place.
For vimdiff, the exit code is not considered because the
scriptlet calls check_unchanged(), which only cares about
modifciation time.

I have a patch that makes it so that none of the tools do the
check_unchanged logic themselves and instead rely on the
library code to handle it for them.  This makes the
implementation uniform across all tools, and allows tools to
opt-in to trustExitCode=true.

This means that all of the builtin tools will default to
trustExitCode=false, and they can opt-in by setting the
configuration variable.

For tkdiff and kdiff3, this is a subtle change in behavior, but
not one that should be problematic, and the upside is that we'll
have consistency across all tools.

In this scenario specifically, what happens is that the
scriptlet is calling check_unchanged(), which checks the
modification time of the file, and if the file is new then it
assumes that the merge succeeded.  check_unchanged() is clearing
the exit code.

Try the patch below.  I tested it with vimdiff and it seems to
provide the desired behavior:
- the modificaiton time behavior is the default
- setting mergetool.vimdiff.trustExitCode = true will make it
  honor vim's exit code via :cq

One possible idea that could avoid the subtle tkdiff/kdiff3
change in behavior would be to allow the scriptlets to advertise
their preference for the default trustExitCode setting.  These
tools could say, "default to true", and the rest can assume
false.

If others feel that this is worth the extra machinery, and the
mental burden of tools having different defaults, then that
could be implemented as a follow-up patch.  IMO I'd be okay with
not needing it and only adding it if someone notices, but if
others feel otherwise we can do it sooner rather than later.

Thoughts?

--- 8< ---
Date: Sun, 27 Nov 2016 17:26:55 -0800
Subject: [PATCH] mergetool: honor mergetool..trustExitCode for all tools

The built-in mergetools originally required that each tool scriptlet
opt-in to the trustExitCode behavior, based on whether or not the tool
called check_unchanged() itself.

Refactor the functions so that run_merge_cmd() (rather than merge_cmd())
takes care of calling check_unchanged() so that all tools handle
the trustExitCode behavior uniformly.

Remove the check_unchanged() calls from the scriptlets.
A subtle benefit of this change is that the responsibility of
merge_cmd() has been narrowed to running the command only,
rather than also needing to deal with the backup file and
checking for changes.

Reported-by: Dun Peal 
Signed-off-by: David Aguilar 
---
 git-mergetool--lib.sh| 24 ++--
 mergetools/araxis|  2 --
 mergetools/bc|  2 --
 mergetools/codecompare   |  2 --
 mergetools/diffuse   |  2 --
 mergetools/ecmerge   |  2 --
 mergetools/examdiff  |  2 --
 mergetools/meld  |  3 +--
 mergetools/opendiff  |  2 --
 mergetools/p4merge   |  2 --
 mergetools/tortoisemerge |  2 --
 mergetools/vimdiff   |  2 --
 mergetools/winmerge  |  2 --
 mergetools/xxdiff|  2 --
 14 files changed, 15 insertions(+), 36 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 9abd00be2..3d8a873ab 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -125,16 +125,7 @@ setup_user_tool () {
}
 
merge_cmd () {
-   trust_exit_code=$(git config --bool \
-   "mergetool.$1.trustExitCode" || echo false)
-   if test "$trust_exit_code" = "false"
-   then
-   touch "$BACKUP"
-   ( eval $merge_tool_cmd )
-   check_unchanged
-   else
-   ( eval $merge_tool_cmd )
-   fi
+   ( eval $merge_tool_cmd )
}
 }
 
@@ -225,7 +216,20 @@ run_diff_cmd () {
 
 # Run a either a configured or built-in merge tool
 run_merge_cmd () {
+   touch "$BACKUP"
+
merge_cmd "$1"
+   status=$?
+
+   trust_exit_code=$(git config --bool \
+   "mergetool.$1.trustExitCode" || echo false)
+   if test "$trust_exit_code" = "false"
+   then
+   check_unchanged
+   status=$?
+   fi
+
+   return $status
 }
 
 list_merge_tool_candidates () {
diff --git a/mergetools/araxis b/mergetools/araxis
index 64f97c5e

Re: trustExitCode doesn't apply to vimdiff mergetool

2016-11-27 Thread Jeff King
On Sun, Nov 27, 2016 at 05:45:38PM -0800, David Aguilar wrote:

> I have a patch that makes it so that none of the tools do the
> check_unchanged logic themselves and instead rely on the
> library code to handle it for them.  This makes the
> implementation uniform across all tools, and allows tools to
> opt-in to trustExitCode=true.
> 
> This means that all of the builtin tools will default to
> trustExitCode=false, and they can opt-in by setting the
> configuration variable.

FWIW, that was the refactoring that came to mind when I looked at the
code yesterday. This is the first time I've looked at the mergetool
code, though, so you can take that with the appropriate grain of salt.

Your patch looks mostly good to me. One minor comment:

>   merge_cmd () {
> - trust_exit_code=$(git config --bool \
> - "mergetool.$1.trustExitCode" || echo false)
> - if test "$trust_exit_code" = "false"
> - then
> - touch "$BACKUP"
> - ( eval $merge_tool_cmd )
> - check_unchanged
> - else
> - ( eval $merge_tool_cmd )
> - fi
> + ( eval $merge_tool_cmd )
>   }
>  }
>  
> @@ -225,7 +216,20 @@ run_diff_cmd () {
>  
>  # Run a either a configured or built-in merge tool
>  run_merge_cmd () {
> + touch "$BACKUP"
> +
>   merge_cmd "$1"
> + status=$?
> +
> + trust_exit_code=$(git config --bool \
> + "mergetool.$1.trustExitCode" || echo false)
> + if test "$trust_exit_code" = "false"
> + then
> + check_unchanged
> + status=$?
> + fi
> +

In the original, we only touch $BACKUP if we care about timestamps. I
can't think of a reason it would matter to do the touch in the
trustExitCode=true case, but you could also write it as:

  if test "$trust_exit_code" = "false"
  then
touch "$BACKUP"
merge_cmd "$1"
check_unchanged
  else
merge_cmd "$1"
  fi

  # now $? is from either merge_cmd or check_unchanged

Yours is arguably less subtle, though, which may be a good thing.

-Peff


Re: trustExitCode doesn't apply to vimdiff mergetool

2016-11-27 Thread David Aguilar
On Sun, Nov 27, 2016 at 05:45:38PM -0800, David Aguilar wrote:
> On Sun, Nov 27, 2016 at 11:55:59AM -0500, Jeff King wrote:
> > On Sun, Nov 27, 2016 at 08:46:40AM -0500, Dun Peal wrote:
> > 
> > > Ignoring a non-zero exit code from the merge tool, and assuming a
> > > successful merge in that case, seems like the wrong default behavior
> > > to me.
> > 
> > Yeah, I'm inclined to agree. But like I said, I'm not too familiar with
> > this area, so maybe there are subtle things I'm missing.
> 
> I think this may have been an oversight in how the
> trust-exit-code feature is implemented across builtins.
> 
> Right now, specific builtin tools could in theory opt-in to the
> feature, but I think it should be handled in a central place.
> For vimdiff, the exit code is not considered because the
> scriptlet calls check_unchanged(), which only cares about
> modifciation time.
> 
> I have a patch that makes it so that none of the tools do the
> check_unchanged logic themselves and instead rely on the
> library code to handle it for them.  This makes the
> implementation uniform across all tools, and allows tools to
> opt-in to trustExitCode=true.
> 
> This means that all of the builtin tools will default to
> trustExitCode=false, and they can opt-in by setting the
> configuration variable.
> 
> For tkdiff and kdiff3, this is a subtle change in behavior, but
> not one that should be problematic, and the upside is that we'll
> have consistency across all tools.
> 
> In this scenario specifically, what happens is that the
> scriptlet is calling check_unchanged(), which checks the
> modification time of the file, and if the file is new then it
> assumes that the merge succeeded.  check_unchanged() is clearing
> the exit code.
> 
> Try the patch below.  I tested it with vimdiff and it seems to
> provide the desired behavior:
> - the modificaiton time behavior is the default
> - setting mergetool.vimdiff.trustExitCode = true will make it
>   honor vim's exit code via :cq
> 
> One possible idea that could avoid the subtle tkdiff/kdiff3
> change in behavior would be to allow the scriptlets to advertise
> their preference for the default trustExitCode setting.  These
> tools could say, "default to true", and the rest can assume
> false.
> 
> If others feel that this is worth the extra machinery, and the
> mental burden of tools having different defaults, then that
> could be implemented as a follow-up patch.  IMO I'd be okay with
> not needing it and only adding it if someone notices, but if
> others feel otherwise we can do it sooner rather than later.
> 
> Thoughts?

For the curious, here is what that patch might look like.
This allows scriptlets to redefine trust_exit_code() so that
they can advertise that they prefer default=true.

The main benefit of this is that we're preserving the original
behavior before these patches.  I'll let this sit out here for
comments for a few days to see what others think.

--- >8 ---
Date: Sun, 27 Nov 2016 18:08:08 -0800
Subject: [PATCH] mergetool: restore trustExitCode behavior for builtins tools

deltawalker, diffmerge, emerge, kdiff3, kompare, and tkdiff originally
provided behavior that matched trustExitCode=true.

The default for all tools is trustExitCode=false, which conflicts with
these tools' defaults.  Allow tools to advertise their own default value
for trustExitCode so that users do not need to opt-in to the original
behavior.

While this makes the default inconsistent between tools, it can still be
overridden, and it makes it consistent with the current Git behavior.

Signed-off-by: David Aguilar 
---
 git-mergetool--lib.sh  | 15 +--
 mergetools/deltawalker |  6 ++
 mergetools/diffmerge   |  6 ++
 mergetools/emerge  |  6 ++
 mergetools/kdiff3  |  6 ++
 mergetools/kompare |  6 ++
 mergetools/tkdiff  |  6 ++
 7 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 3d8a873ab..be079723a 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -120,6 +120,12 @@ setup_user_tool () {
merge_tool_cmd=$(get_merge_tool_cmd "$tool")
test -n "$merge_tool_cmd" || return 1
 
+   trust_exit_code () {
+   # user-defined tools default to trustExitCode = false
+   git config --bool "mergetool.$1.trustExitCode" ||
+   echo false
+   }
+
diff_cmd () {
( eval $merge_tool_cmd )
}
@@ -153,6 +159,12 @@ setup_tool () {
echo "$1"
}
 
+   trust_exit_code () {
+   # built-in tools default to trustExitCode = false
+   git config --bool "mergetool.$1.trustExitCode" ||
+   echo false
+   }
+
if ! test -f "$MERGE_TOOLS_DIR/$tool"
then
setup_user_tool
@@ -221,8 +233,7 @@ run_merge_cmd () {
merge_cmd "$1"
status=$?
 
-   trust_exit_code=$(git config --bool \
-   "mergetoo

Re: trustExitCode doesn't apply to vimdiff mergetool

2016-11-28 Thread Junio C Hamano
David Aguilar  writes:

> deltawalker, diffmerge, emerge, kdiff3, kompare, and tkdiff originally
> provided behavior that matched trustExitCode=true.
>
> The default for all tools is trustExitCode=false, which conflicts with
> these tools' defaults.  Allow tools to advertise their own default value
> for trustExitCode so that users do not need to opt-in to the original
> behavior.
>
> While this makes the default inconsistent between tools, it can still be
> overridden, and it makes it consistent with the current Git behavior.

I think this is sensible, because the way I look at this issue is
that in an ideal world, we would want all tool backends consistently
give us usable exit codes, but some tools are known to give unusable
exit codes, so we ignore their exit codes by default.

As to the implementation, I think you can reduce the duplication by
having each tool backend 

 - export a new function that echos "true" or "false"; or
 - export a new function that returns true or false; or
 - set a variable whose value is either "true" or "false"

and use that from the trust_exit_code() in git-mergetool--lib.sh.
Something like this (for the second alternative).

trust_exit_code () {
if git config --bool "mergtool.$.trustExitCode"
then
:; # OK
elif mergetool_exitcode_trustable
then
echo true
else
echo false
fi
}


[PATCH 2/5] apply: use SWAP macro

2017-01-28 Thread René Scharfe
Use the exported macro SWAP instead of the file-scoped macro swap and
remove the latter's definition.

Signed-off-by: Rene Scharfe 
---
 apply.c | 23 +++
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/apply.c b/apply.c
index 2ed808d429..0e2caeab9c 100644
--- a/apply.c
+++ b/apply.c
@@ -2187,29 +2187,20 @@ static int parse_chunk(struct apply_state *state, char 
*buffer, unsigned long si
return offset + hdrsize + patchsize;
 }
 
-#define swap(a,b) myswap((a),(b),sizeof(a))
-
-#define myswap(a, b, size) do {\
-   unsigned char mytmp[size];  \
-   memcpy(mytmp, &a, size);\
-   memcpy(&a, &b, size);   \
-   memcpy(&b, mytmp, size);\
-} while (0)
-
 static void reverse_patches(struct patch *p)
 {
for (; p; p = p->next) {
struct fragment *frag = p->fragments;
 
-   swap(p->new_name, p->old_name);
-   swap(p->new_mode, p->old_mode);
-   swap(p->is_new, p->is_delete);
-   swap(p->lines_added, p->lines_deleted);
-   swap(p->old_sha1_prefix, p->new_sha1_prefix);
+   SWAP(p->new_name, p->old_name);
+   SWAP(p->new_mode, p->old_mode);
+   SWAP(p->is_new, p->is_delete);
+   SWAP(p->lines_added, p->lines_deleted);
+   SWAP(p->old_sha1_prefix, p->new_sha1_prefix);
 
for (; frag; frag = frag->next) {
-   swap(frag->newpos, frag->oldpos);
-   swap(frag->newlines, frag->oldlines);
+   SWAP(frag->newpos, frag->oldpos);
+   SWAP(frag->newlines, frag->oldlines);
}
}
 }
-- 
2.11.0



[PATCH] apply: remove unused parameters from name_terminate()

2016-05-28 Thread René Scharfe
Signed-off-by: Rene Scharfe 
---
 builtin/apply.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 8e4da2e..c770d7d 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -442,7 +442,7 @@ static int is_dev_null(const char *str)
 #define TERM_SPACE 1
 #define TERM_TAB   2
 
-static int name_terminate(const char *name, int namelen, int c, int terminate)
+static int name_terminate(int c, int terminate)
 {
if (c == ' ' && !(terminate & TERM_SPACE))
return 0;
@@ -671,7 +671,7 @@ static char *find_name_common(const char *line, const char 
*def,
if (!end && isspace(c)) {
if (c == '\n')
break;
-   if (name_terminate(start, line-start, c, terminate))
+   if (name_terminate(c, terminate))
break;
}
line++;
-- 
2.8.3

--
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


[PATCH] builtin/apply: exit when parse_binary() fails

2016-03-19 Thread Christian Couder
In parse_binary() there is:

forward = parse_binary_hunk(&buffer, &size, &status, &used);
if (!forward && !status)
/* there has to be one hunk (forward hunk) */
return error(_("unrecognized binary patch at line %d"), 
linenr-1);

so parse_binary() can return -1, because that's what error() returns.

Also parse_binary_hunk() sets "status" to -1 in case of error and
parse_binary() does "if (status) return status;".

In this case parse_chunk() should just exit, rather than add -1 to the
patchsize it computes.

Signed-off-by: Christian Couder 
---
 builtin/apply.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/builtin/apply.c b/builtin/apply.c
index 42c610e..18dec0f 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1872,6 +1872,11 @@ static struct fragment *parse_binary_hunk(char **buf_p,
return NULL;
 }
 
+/*
+ * Returns:
+ *   -1 in case of error,
+ *   the length of the parsed binary patch otherwise
+ */
 static int parse_binary(char *buffer, unsigned long size, struct patch *patch)
 {
/*
@@ -2017,6 +2022,8 @@ static int parse_chunk(char *buffer, unsigned long size, 
struct patch *patch)
linenr++;
used = parse_binary(buffer + hd + llen,
size - hd - llen, patch);
+   if (used < 0)
+   exit(1);
if (used)
patchsize = used + llen;
else
-- 
2.8.0.rc2.54.g810e8ee

--
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


[PATCH v3] builtin/apply: handle parse_binary() failure

2016-03-19 Thread Christian Couder
In parse_binary() there is:

forward = parse_binary_hunk(&buffer, &size, &status, &used);
if (!forward && !status)
/* there has to be one hunk (forward hunk) */
return error(_("unrecognized binary patch at line %d"), 
linenr-1);

so parse_binary() can return -1, because that's what error() returns.

Also parse_binary_hunk() sets "status" to -1 in case of error and
parse_binary() does "if (status) return status;".

In this case parse_chunk() should not add -1 to the patchsize it computes.
It is better for future libification efforts to make it just return -1.

Signed-off-by: Christian Couder 
---
Only the title of the patch changed in this version compared to v2.

 builtin/apply.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/builtin/apply.c b/builtin/apply.c
index 42c610e..c399c97 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1872,6 +1872,11 @@ static struct fragment *parse_binary_hunk(char **buf_p,
return NULL;
 }
 
+/*
+ * Returns:
+ *   -1 in case of error,
+ *   the length of the parsed binary patch otherwise
+ */
 static int parse_binary(char *buffer, unsigned long size, struct patch *patch)
 {
/*
@@ -2017,6 +2022,8 @@ static int parse_chunk(char *buffer, unsigned long size, 
struct patch *patch)
linenr++;
used = parse_binary(buffer + hd + llen,
size - hd - llen, patch);
+   if (used < 0)
+   return -1;
if (used)
patchsize = used + llen;
else
-- 
2.8.0.rc2.56.gc9044db

--
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


Issue: `git apply` doesn't respect `--work-tree`

2016-03-26 Thread Ciprian Dorin Craciun
[I've quickly looked at the mailing list archive and didn't see this
issue reported.  However I might be wrong.]


The issue is simple:  `git apply` does not respect the `--work-tree`
argument when called outside the repository.

The version of Git I used is OpenSUSE's official 2.1.4 but also 2.7.4
from their repositories.

The command I used is:
  git --work-tree /.../some-repo --git-dir /.../some-repo/.git apply
/.../some-patch

The current working directory is completely unrelated with the
targeted work-tree (i.e. it is not a subdirectory of the work-tree).


I confirmed the above by using `strace -f -e file -- git ...`, and
although Git picks the correct path for the target work-tree and
switches there, it then switches back to the initial working directory
(the one being invoked from).  See bellow the (redacted) output of
`strace`:


getcwd("{current-working-dir}", 129) = 79
stat("{target-working-dir}/.git", {st_mode=S_IFDIR|0700, st_size=300, ...}) = 0
lstat("{target-working-dir}/.git/HEAD", {st_mode=S_IFREG|0600,
st_size=23, ...}) = 0
open("{target-working-dir}/.git/HEAD", O_RDONLY)  = 3
lstat("{target-working-dir}/.git/commondir", 0x7ffe0231eb90) = -1
ENOENT (No such file or directory)
access("{target-working-dir}/.git/objects", X_OK) = 0
access("{target-working-dir}/.git/refs", X_OK)= 0
lstat("{target-working-dir}/.git/commondir", 0x7ffe0231eb80) = -1
ENOENT (No such file or directory)
access("{home}/.config/git/config", R_OK) = -1 ENOENT (No such file or
directory)
access("{home}/.gitconfig", R_OK) = 0
open("{home}/.gitconfig", O_RDONLY) = 3
access("{target-working-dir}/.git/config", R_OK)  = 0
open("{target-working-dir}/.git/config", O_RDONLY) = 3
stat("{target-working-dir}", {st_mode=S_IFDIR|0700, st_size=880, ...}) = 0
getcwd("{current-working-dir}", 129) = 79
chdir("{target-working-dir}") = 0
getcwd("{target-working-dir}", 139)   = 11
lstat("{target-working-dir}", {st_mode=S_IFDIR|0700, st_size=880, ...}) = 0
chdir("{current-working-dir}") = 0
stat("{target-working-dir}/.git", {st_mode=S_IFDIR|0700, st_size=300, ...}) = 0
lstat("{target-working-dir}/.git/commondir", 0x7ffe0231eb40) = -1
ENOENT (No such file or directory)
access("{home}/.config/git/config", R_OK) = -1 ENOENT (No such file or
directory)
access("{home}/.gitconfig", R_OK) = 0
open("{home}/.gitconfig", O_RDONLY) = 3
access("{target-working-dir}/.git/config", R_OK)  = 0
open("{target-working-dir}/.git/config", O_RDONLY) = 3
open("{target-diff}", O_RDONLY)   = 3
open("{home}/.config/git/attributes", O_RDONLY) = -1 ENOENT (No such
file or directory)
open(".gitattributes", O_RDONLY)= -1 ENOENT (No such file or directory)
open("{target-working-dir}/.git/info/attributes", O_RDONLY) = -1
ENOENT (No such file or directory)
lstat("{file-to-be-patched}", 0x7ffe0231e1f0)   = -1 ENOENT (No
such file or directory)
error: {file-to-be-patched}: No such file or directory
+++ exited with 1 +++


Hope it helps,
Ciprian.
--
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


[PATCH] gitweb: apply fallback encoding before highlight

2016-04-20 Thread Shin Kojima
Some multi-byte character encodings (such as Shift_JIS and GBK) have
characters whose final bytes is an ASCII '\' (0x5c), and they
will be displayed as funny-characters even if $fallback_encoding is
correct.  This is because `highlight` command always expects UTF-8
encoded strings from STDIN.

$ echo 'my $v = "申";' | highlight --syntax perl | w3m -T text/html -dump
my $v = "申";

$ echo 'my $v = "申";' | iconv -f UTF-8 -t Shift_JIS | highlight \
--syntax perl | iconv -f Shift_JIS -t UTF-8 | w3m -T text/html -dump

iconv: (stdin):9:135: cannot convert
my $v = "

This patch prepare git blob objects to be encoded into UTF-8 before
highlighting in the manner of `to_utf8` subroutine.
---
 gitweb/gitweb.perl | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 05d7910..2fddf75 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3935,6 +3935,9 @@ sub run_highlighter {
 
close $fd;
open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
+ quote_command($^X, '-CO', '-MEncode=decode,FB_DEFAULT', 
'-pse',
+   '$_ = decode($fe, $_, FB_DEFAULT) if !utf8::decode($_);',
+   '--', "-fe=$fallback_encoding")." | ".
  quote_command($highlight_bin).
  " --replace-tabs=8 --fragment --syntax $syntax |"
or die_error(500, "Couldn't open file or run syntax 
highlighter");
-- 
2.8.1

--
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


[PATCH 61/83] builtin/apply: libify check_apply_state()

2016-04-24 Thread Christian Couder
Signed-off-by: Christian Couder 
---
 builtin/apply.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index e3ee199..7576ec5 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4534,17 +4534,17 @@ static int option_parse_directory(const struct option 
*opt,
return 0;
 }
 
-static void check_apply_state(struct apply_state *state, int force_apply)
+static int check_apply_state(struct apply_state *state, int force_apply)
 {
int is_not_gitdir = !startup_info->have_repository;
 
if (state->apply_with_reject && state->threeway)
-   die("--reject and --3way cannot be used together.");
+   return error("--reject and --3way cannot be used together.");
if (state->cached && state->threeway)
-   die("--cached and --3way cannot be used together.");
+   return error("--cached and --3way cannot be used together.");
if (state->threeway) {
if (is_not_gitdir)
-   die(_("--3way outside a repository"));
+   return error(_("--3way outside a repository"));
state->check_index = 1;
}
if (state->apply_with_reject)
@@ -4552,14 +4552,15 @@ static void check_apply_state(struct apply_state 
*state, int force_apply)
if (!force_apply && (state->diffstat || state->numstat || 
state->summary || state->check || state->fake_ancestor))
state->apply = 0;
if (state->check_index && is_not_gitdir)
-   die(_("--index outside a repository"));
+   return error(_("--index outside a repository"));
if (state->cached) {
if (is_not_gitdir)
-   die(_("--cached outside a repository"));
+   return error(_("--cached outside a repository"));
state->check_index = 1;
}
if (state->check_index)
state->unsafe_paths = 0;
+   return 0;
 }
 
 static int apply_all_patches(struct apply_state *state,
@@ -4723,7 +4724,8 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix)
argc = parse_options(argc, argv, state.prefix, builtin_apply_options,
apply_usage, 0);
 
-   check_apply_state(&state, force_apply);
+   if (check_apply_state(&state, force_apply))
+   exit(1);
 
return apply_all_patches(&state, argc, argv, options);
 }
-- 
2.8.1.300.g5fed0c0

--
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


[PATCH 58/83] builtin/apply: libify parse_ignorewhitespace_option()

2016-04-24 Thread Christian Couder
Signed-off-by: Christian Couder 
---
 builtin/apply.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 8d96f70..2f89922 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -57,20 +57,20 @@ static int parse_whitespace_option(struct apply_state 
*state, const char *option
return error(_("unrecognized whitespace option '%s'"), option);
 }
 
-static void parse_ignorewhitespace_option(struct apply_state *state,
- const char *option)
+static int parse_ignorewhitespace_option(struct apply_state *state,
+const char *option)
 {
if (!option || !strcmp(option, "no") ||
!strcmp(option, "false") || !strcmp(option, "never") ||
!strcmp(option, "none")) {
state->ws_ignore_action = ignore_ws_none;
-   return;
+   return 0;
}
if (!strcmp(option, "change")) {
state->ws_ignore_action = ignore_ws_change;
-   return;
+   return 0;
}
-   die(_("unrecognized whitespace ignore option '%s'"), option);
+   return error(_("unrecognized whitespace ignore option '%s'"), option);
 }
 
 static void set_default_whitespace_mode(struct apply_state *state)
@@ -4605,8 +4605,8 @@ static void init_apply_state(struct apply_state *state, 
const char *prefix)
git_apply_config();
if (apply_default_whitespace && parse_whitespace_option(state, 
apply_default_whitespace))
exit(1);
-   if (apply_default_ignorewhitespace)
-   parse_ignorewhitespace_option(state, 
apply_default_ignorewhitespace);
+   if (apply_default_ignorewhitespace && 
parse_ignorewhitespace_option(state, apply_default_ignorewhitespace))
+   exit(1);
 }
 
 static void check_apply_state(struct apply_state *state, int force_apply)
-- 
2.8.1.300.g5fed0c0

--
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


[PATCH 57/83] builtin/apply: libify parse_whitespace_option()

2016-04-24 Thread Christian Couder
Signed-off-by: Christian Couder 
---
 builtin/apply.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index 1c1ac7d..8d96f70 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -27,34 +27,34 @@ static const char * const apply_usage[] = {
NULL
 };
 
-static void parse_whitespace_option(struct apply_state *state, const char 
*option)
+static int parse_whitespace_option(struct apply_state *state, const char 
*option)
 {
if (!option) {
state->ws_error_action = warn_on_ws_error;
-   return;
+   return 0;
}
if (!strcmp(option, "warn")) {
state->ws_error_action = warn_on_ws_error;
-   return;
+   return 0;
}
if (!strcmp(option, "nowarn")) {
state->ws_error_action = nowarn_ws_error;
-   return;
+   return 0;
}
if (!strcmp(option, "error")) {
state->ws_error_action = die_on_ws_error;
-   return;
+   return 0;
}
if (!strcmp(option, "error-all")) {
state->ws_error_action = die_on_ws_error;
state->squelch_whitespace_errors = 0;
-   return;
+   return 0;
}
if (!strcmp(option, "strip") || !strcmp(option, "fix")) {
state->ws_error_action = correct_ws_error;
-   return;
+   return 0;
}
-   die(_("unrecognized whitespace option '%s'"), option);
+   return error(_("unrecognized whitespace option '%s'"), option);
 }
 
 static void parse_ignorewhitespace_option(struct apply_state *state,
@@ -4572,7 +4572,8 @@ static int option_parse_whitespace(const struct option 
*opt,
 {
struct apply_state *state = opt->value;
state->whitespace_option = arg;
-   parse_whitespace_option(state, arg);
+   if (parse_whitespace_option(state, arg))
+   exit(1);
return 0;
 }
 
@@ -4602,8 +4603,8 @@ static void init_apply_state(struct apply_state *state, 
const char *prefix)
strbuf_init(&state->root, 0);
 
git_apply_config();
-   if (apply_default_whitespace)
-   parse_whitespace_option(state, apply_default_whitespace);
+   if (apply_default_whitespace && parse_whitespace_option(state, 
apply_default_whitespace))
+   exit(1);
if (apply_default_ignorewhitespace)
parse_ignorewhitespace_option(state, 
apply_default_ignorewhitespace);
 }
-- 
2.8.1.300.g5fed0c0

--
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


[RFC/PATCH 00/48] Libifying git apply

2016-03-09 Thread Christian Couder
This is a patch series about libifying "git apply" functionality, to
be able to use this functionality in "git am" without spawning new
processes. This should make "git am" and "git rebase" significantly
faster.

This has been discussed in the following thread:

http://thread.gmane.org/gmane.comp.version-control.git/287236/

This RFC patch series for now just gets rid of the global variables
and refactors the code around a bit.

As suggested by Junio the global variables in builtin/apply.c are just
thrown into a single "apply_state" structure that is passed around the
callchain. A new parameter called "state" that is a pointer to the
"apply_state" structure comes at the beginning of the helper functions
that need it.

Before I make further changes to handle erroneous input and make the
libified functions not die() and properly clean things up, I'd be
happy to get some feedback.

One point I'd especially welcome feedback about is the fact that there
are many boolean options that are using OPT_BOOL(...), so they use an
int. And there are a few others that are using OPT_BIT(...), so they
use just a bit. I wonder if it is worth it to try to be consistent,
and maybe also to try to save some memory.

Related to this, some of the variables for these options have not been
moved into the "apply_state" structure, because they are not global to
the file, but maybe for consistency they should be.

Christian Couder (48):
  builtin/apply: avoid parameter shadowing 'p_value' global
  builtin/apply: avoid parameter shadowing 'linenr' global
  builtin/apply: avoid local variable shadowing 'len' parameter
  builtin/apply: extract line_by_line_fuzzy_match() from
match_fragment()
  builtin/apply: move 'options' variable into cmd_apply()
  builtin/apply: introduce 'struct apply_state' to start libifying
  builtin/apply: move 'newfd' global into 'struct apply_state'
  builtin/apply: move 'unidiff_zero' global into 'struct apply_state'
  builtin/apply: move 'check' global into 'struct apply_state'
  builtin/apply: move 'check_index' global into 'struct apply_state'
  builtin/apply: move 'apply_in_reverse' global into 'struct
apply_state'
  builtin/apply: move 'apply_with_reject' global into 'struct
apply_state'
  builtin/apply: move 'apply_verbosely' global into 'struct apply_state'
  builtin/apply: move 'update_index' global into 'struct apply_state'
  builtin/apply: move 'allow_overlap' global into 'struct apply_state'
  builtin/apply: move 'cached' global into 'struct apply_state'
  builtin/apply: move 'diffstat' global into 'struct apply_state'
  builtin/apply: move 'numstat' global into 'struct apply_state'
  builtin/apply: move 'summary' global into 'struct apply_state'
  builtin/apply: move 'threeway' global into 'struct apply_state'
  builtin/apply: move 'no-add' global into 'struct apply_state'
  builtin/apply: move 'unsafe_paths' global into 'struct apply_state'
  builtin/apply: move 'line_termination' global into 'struct
apply_state'
  builtin/apply: move 'fake_ancestor' global into 'struct apply_state'
  builtin/apply: move 'p_context' global into 'struct apply_state'
  builtin/apply: move 'apply' global into 'struct apply_state'
  builtin/apply: move 'read_stdin' global into cmd_apply()
  builtin/apply: move 'lock_file' global into 'struct apply_state'
  builtin/apply: move 'patch_input_file' global into 'struct
apply_state'
  builtin/apply: move 'limit_by_name' global into 'struct apply_state'
  builtin/apply: move 'has_include' global into 'struct apply_state'
  builtin/apply: move 'p_value' global into 'struct apply_state'
  builtin/apply: move 'p_value_known' global into 'struct apply_state'
  builtin/apply: move 'root' global into 'struct apply_state'
  builtin/apply: move 'whitespace_error' global into 'struct
apply_state'
  builtin/apply: move 'whitespace_option' into 'struct apply_state'
  builtin/apply: remove whitespace_option arg from
set_default_whitespace_mode()
  builtin/apply: move 'squelch_whitespace_errors' into 'struct
apply_state'
  builtin/apply: move 'applied_after_fixing_ws' into 'struct
apply_state'
  builtin/apply: move 'ws_error_action' into 'struct apply_state'
  bui

Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Junio C Hamano
Paul Gortmaker  writes:

> TL;DR -- "git apply --reject" implies verbose, but the similar
> "git apply --check" does not, which seems inconsistent.

Hmmm, I am of two minds.  From purely idealistic point of view, I
can see why defaulting both to non-verbose may look a more
attractive way to go, but I have my reservations that is more than
the usual change-aversion.

Historically, "check" was primarily meant to see if the patch is
applicable cleanly in scripts, and we never thought it would make
any sense to make it verbose by default.  

On the other hand, the operation of "reject", which was a much later
invention, was primarily meant to be observed by humans to see how
the patch failed to cleanly apply and where, to help them decide
where to look in the target to wiggle the rejected hunk into (even
when it is driven from a script).  It did not make much sense to
squelch its output.

In addition, because "check" is an idempotent operation that does
not touch anything in the index or the working tree, running with
"check" and then "check verbose" is possible if somebody runs it
without verbose and then decides later that s/he wants to see the
details.  But "reject" does touch the working tree files with
applicable hunks, so after a quiet "reject", there is no way to see
the verbose output like you can with "check".
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Paul Gortmaker
On 13-08-20 01:57 PM, Junio C Hamano wrote:
> Paul Gortmaker  writes:
> 
>> TL;DR -- "git apply --reject" implies verbose, but the similar
>> "git apply --check" does not, which seems inconsistent.
> 
> Hmmm, I am of two minds.  From purely idealistic point of view, I
> can see why defaulting both to non-verbose may look a more
> attractive way to go, but I have my reservations that is more than
> the usual change-aversion.

OK, so given your feedback, how do you feel about a patch to the
documentation that indicates to use "-v" in combination with the
"--check" to get equivalent "patch --dry-run" behaviour?   If that
had existed, I'd have not gone rummaging around in the source, so
that should be good enough to help others avoid the same...

P.
--

> 
> Historically, "check" was primarily meant to see if the patch is
> applicable cleanly in scripts, and we never thought it would make
> any sense to make it verbose by default.  
> 
> On the other hand, the operation of "reject", which was a much later
> invention, was primarily meant to be observed by humans to see how
> the patch failed to cleanly apply and where, to help them decide
> where to look in the target to wiggle the rejected hunk into (even
> when it is driven from a script).  It did not make much sense to
> squelch its output.
> 
> In addition, because "check" is an idempotent operation that does
> not touch anything in the index or the working tree, running with
> "check" and then "check verbose" is possible if somebody runs it
> without verbose and then decides later that s/he wants to see the
> details.  But "reject" does touch the working tree files with
> applicable hunks, so after a quiet "reject", there is no way to see
> the verbose output like you can with "check".
> 
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Jonathan Nieder
Hi Paul,

Paul Gortmaker wrote:

> OK, so given your feedback, how do you feel about a patch to the
> documentation that indicates to use "-v" in combination with the
> "--check" to get equivalent "patch --dry-run" behaviour?

Sounds like a good idea to me.

I assume you mean a note in the OPTIONS or EXAMPLES section of
Documentation/git-apply.txt?

Thanks,
Jonathan
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Junio C Hamano
Paul Gortmaker  writes:

> OK, so given your feedback, how do you feel about a patch to the
> documentation that indicates to use "-v" in combination with the
> "--check" to get equivalent "patch --dry-run" behaviour?   If that
> had existed, I'd have not gone rummaging around in the source, so
> that should be good enough to help others avoid the same...

I do not think it is necessarily a good idea to assume that people
who are learning "git apply" know how GNU patch works.

But I do agree that the description of -v, --verbose has a lot of
room for improvement.

Report progress to stderr. By default, only a message about the
current patch being applied will be printed. This option will cause
additional information to be reported.

It is totally unclear what "additional information" is reported at
all.

Thanks.
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Paul Gortmaker
On 13-08-20 02:51 PM, Jonathan Nieder wrote:
> Hi Paul,
> 
> Paul Gortmaker wrote:
> 
>> OK, so given your feedback, how do you feel about a patch to the
>> documentation that indicates to use "-v" in combination with the
>> "--check" to get equivalent "patch --dry-run" behaviour?
> 
> Sounds like a good idea to me.
> 
> I assume you mean a note in the OPTIONS or EXAMPLES section of
> Documentation/git-apply.txt?

I hadn't looked exactly where yet, but wherever makes sense and
wherever appears in TFM.

P.
--

> 
> Thanks,
> Jonathan
> 
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Steven Rostedt
On Tue, 20 Aug 2013 12:07:18 -0700
Junio C Hamano  wrote:

> Paul Gortmaker  writes:
> 
> > OK, so given your feedback, how do you feel about a patch to the
> > documentation that indicates to use "-v" in combination with the
> > "--check" to get equivalent "patch --dry-run" behaviour?   If that
> > had existed, I'd have not gone rummaging around in the source, so
> > that should be good enough to help others avoid the same...
> 
> I do not think it is necessarily a good idea to assume that people
> who are learning "git apply" know how GNU patch works.

Linus told me that "git apply" was basically a replacement for patch.
Why would you think it would not be a good idea to assume that people
would not be familiar with how GNU patch works?

Is it because you expect "git apply" to eventually replace patch all
out, and want no dependencies on its knowledge?

-- Steve


> 
> But I do agree that the description of -v, --verbose has a lot of
> room for improvement.
> 
>   Report progress to stderr. By default, only a message about the
>   current patch being applied will be printed. This option will cause
>   additional information to be reported.
> 
> It is totally unclear what "additional information" is reported at
> all.
> 
> Thanks.

--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Junio C Hamano
Steven Rostedt  writes:

>> I do not think it is necessarily a good idea to assume that people
>> who are learning "git apply" know how GNU patch works.
>
> Linus told me that "git apply" was basically a replacement for patch.
> Why would you think it would not be a good idea to assume that people
> would not be familiar with how GNU patch works?

The audience of Git these days are far more widely spread than the
kernel circle.  I am not opposed to _helping_ those who happen to
know "patch", but I was against a description that assumes readers
know it, i.e. making it a requirement to know "patch" to understand
"apply".

>> But I do agree that the description of -v, --verbose has a lot of
>> room for improvement.
>> 
>>  Report progress to stderr. By default, only a message about the
>>  current patch being applied will be printed. This option will cause
>>  additional information to be reported.
>> 
>> It is totally unclear what "additional information" is reported at
>> all.

In other words, your enhancement to the documentation could go like:

... By default, ... With this option, you will additionally
see such and such and such in the output (this is similar to
what "patch --dry-run" would give you).  See the EXAMPLES
section to get a feel of how it looks like.

and I would not be opposed, as long as "such and such and such" are
written in such a way that the reader does not have to have a prior
experience with GNU patch in order to understand it.

Clear?

--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Steven Rostedt
On Tue, 20 Aug 2013 12:45:03 -0700
Junio C Hamano  wrote:

> Steven Rostedt  writes:
> 
> >> I do not think it is necessarily a good idea to assume that people
> >> who are learning "git apply" know how GNU patch works.
> >
> > Linus told me that "git apply" was basically a replacement for patch.
> > Why would you think it would not be a good idea to assume that people
> > would not be familiar with how GNU patch works?
> 
> The audience of Git these days are far more widely spread than the
> kernel circle.  I am not opposed to _helping_ those who happen to
> know "patch", but I was against a description that assumes readers
> know it, i.e. making it a requirement to know "patch" to understand
> "apply".

Patch is used by much more than just the kernel folks ;-)  I've been
using patch much longer than I've been doing kernel development.


> 
> >> But I do agree that the description of -v, --verbose has a lot of
> >> room for improvement.
> >> 
> >>Report progress to stderr. By default, only a message about the
> >>current patch being applied will be printed. This option will cause
> >>additional information to be reported.
> >> 
> >> It is totally unclear what "additional information" is reported at
> >> all.
> 
> In other words, your enhancement to the documentation could go like:
> 
>   ... By default, ... With this option, you will additionally
>   see such and such and such in the output (this is similar to
>   what "patch --dry-run" would give you).  See the EXAMPLES
>   section to get a feel of how it looks like.
> 
> and I would not be opposed, as long as "such and such and such" are
> written in such a way that the reader does not have to have a prior
> experience with GNU patch in order to understand it.
> 
> Clear?

Looks good to me. Paul, what do you think?

Thanks,

-- Steve
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Junio C Hamano
Paul Gortmaker  writes:

>> Looks good to me. Paul, what do you think?
>
> Yep, I'll write something up tomorrow which loosely matches the above.

Thanks.
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Junio C Hamano
Steven Rostedt  writes:

>> > Linus told me that "git apply" was basically a replacement for patch.
>> > Why would you think it would not be a good idea to assume that people
>> > would not be familiar with how GNU patch works?
>> 
>> The audience of Git these days are far more widely spread than the
>> kernel circle.  I am not opposed to _helping_ those who happen to
>> know "patch", but I was against a description that assumes readers
>> know it, i.e. making it a requirement to know "patch" to understand
>> "apply".
>
> Patch is used by much more than just the kernel folks ;-)  I've been
> using patch much longer than I've been doing kernel development.

Yeah, I was familiar with "patch" when I started Git, too ;-).

But only folks in the kernel circle will be told by Linus the
similarity between apply and patch, no?

In any case...

>> In other words, your enhancement to the documentation could go like:
>> 
>>  ... By default, ... With this option, you will additionally
>>  see such and such and such in the output (this is similar to
>>  what "patch --dry-run" would give you).  See the EXAMPLES
>>  section to get a feel of how it looks like.
>> 
>> and I would not be opposed, as long as "such and such and such" are
>> written in such a way that the reader does not have to have a prior
>> experience with GNU patch in order to understand it.

... I forgot to also add: And by mentioning "similar to", people who
are familiar with "patch" are also helped by their pre-existing
knowledge, so both kinds of people win.

Thanks.
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Steven Rostedt
On Tue, 20 Aug 2013 14:43:56 -0700
Junio C Hamano  wrote:

 
> But only folks in the kernel circle will be told by Linus the
> similarity between apply and patch, no?

Well, there was a time when Linus was making his rounds showcasing git
more than Linux, to people that were not kernel developers.

-- Steve
--
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


Re: Should "git apply --check" imply verbose?

2013-08-20 Thread Paul Gortmaker
On 13-08-20 03:54 PM, Steven Rostedt wrote:
> On Tue, 20 Aug 2013 12:45:03 -0700
> Junio C Hamano  wrote:
> 
>> Steven Rostedt  writes:
>>
>>>> I do not think it is necessarily a good idea to assume that people
>>>> who are learning "git apply" know how GNU patch works.
>>>
>>> Linus told me that "git apply" was basically a replacement for patch.
>>> Why would you think it would not be a good idea to assume that people
>>> would not be familiar with how GNU patch works?
>>
>> The audience of Git these days are far more widely spread than the
>> kernel circle.  I am not opposed to _helping_ those who happen to
>> know "patch", but I was against a description that assumes readers
>> know it, i.e. making it a requirement to know "patch" to understand
>> "apply".
> 
> Patch is used by much more than just the kernel folks ;-)  I've been
> using patch much longer than I've been doing kernel development.
> 
> 
>>
>>>> But I do agree that the description of -v, --verbose has a lot of
>>>> room for improvement.
>>>>
>>>>Report progress to stderr. By default, only a message about the
>>>>current patch being applied will be printed. This option will cause
>>>>additional information to be reported.
>>>>
>>>> It is totally unclear what "additional information" is reported at
>>>> all.
>>
>> In other words, your enhancement to the documentation could go like:
>>
>>  ... By default, ... With this option, you will additionally
>>  see such and such and such in the output (this is similar to
>>  what "patch --dry-run" would give you).  See the EXAMPLES
>>  section to get a feel of how it looks like.
>>
>> and I would not be opposed, as long as "such and such and such" are
>> written in such a way that the reader does not have to have a prior
>> experience with GNU patch in order to understand it.
>>
>> Clear?
> 
> Looks good to me. Paul, what do you think?

Yep, I'll write something up tomorrow which loosely matches the above.

Thanks,
Paul.
--

> 
> Thanks,
> 
> -- Steve
> 
--
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


[PATCH 7/9] apply: add --stage option

2013-08-29 Thread Felipe Contreras
Synonym for --index.

Signed-off-by: Felipe Contreras 
---
 Documentation/git-apply.txt | 5 -
 builtin/apply.c | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index f605327..ce44327 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -12,7 +12,7 @@ SYNOPSIS
 'git apply' [--stat] [--numstat] [--summary] [--check] [--index] [--3way]
      [--apply] [--no-add] [--build-fake-ancestor=] [-R | --reverse]
  [--allow-binary-replacement | --binary] [--reject] [-z]
- [-p] [-C] [--inaccurate-eof] [--recount] [--cached]
+ [-p] [-C] [--inaccurate-eof] [--recount] [--cached|--staged]
  [--ignore-space-change | --ignore-whitespace ]
  [--whitespace=(nowarn|warn|fix|error|error-all)]
  [--exclude=] [--include=] [--directory=]
@@ -67,6 +67,9 @@ OPTIONS
up-to-date, it is flagged as an error.  This flag also
causes the index file to be updated.
 
+--staged::
+   Synonym for --index.
+
 --cached::
    Apply a patch without touching the working tree. Instead take the
cached data, apply the patch, and store the result in the index
diff --git a/builtin/apply.c b/builtin/apply.c
index 50912c9..42b5a4b 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -4377,6 +4377,8 @@ int cmd_apply(int argc, const char **argv, const char 
*prefix_)
N_("instead of applying the patch, see if the patch is 
applicable")),
OPT_BOOLEAN(0, "index", &check_index,
N_("make sure the patch is applicable to the current 
index")),
+   OPT_BOOLEAN(0, "stage", &check_index,
+   N_("make sure the patch is applicable to the current 
index")),
    OPT_BOOLEAN(0, "cached", &cached,
N_("apply a patch without touching the working tree")),
OPT_BOOLEAN(0, "apply", &force_apply,
-- 
1.8.4-fc

--
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


  1   2   3   4   5   6   7   8   9   10   >