Re: [PATCH v6 41/44] am: use be_silent in 'struct apply_state' to shut up applying patches

2016-06-11 Thread Christian Couder
On Sat, Jun 11, 2016 at 12:07 AM, Junio C Hamano  wrote:
> The update in 33/44 to make am call into apply that is not ready to
> be called (e.g. the caller needs the dup(2) dance with /dev/null to
> be silent) gets finally corrected with this step, which makes the
> progress of the topic somewhat ugly and reviewing it a bit harder
> than necessary.  As it stands, the last several patches in the
> series smells more like "oops, we realize these things were not done
> properly the first time, and here are the follow-up patches to fix
> them up".
>
> I wonder if it is a good idea to delay integrating the apply
> machinery into "am" until it is ready?

Ok, I will do that and I think it should also avoid the build failures
on Windows.

Thanks,
Christian.
--
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 v6 41/44] am: use be_silent in 'struct apply_state' to shut up applying patches

2016-06-10 Thread Junio C Hamano
The update in 33/44 to make am call into apply that is not ready to
be called (e.g. the caller needs the dup(2) dance with /dev/null to
be silent) gets finally corrected with this step, which makes the
progress of the topic somewhat ugly and reviewing it a bit harder
than necessary.  As it stands, the last several patches in the
series smells more like "oops, we realize these things were not done
properly the first time, and here are the follow-up patches to fix
them up".

I wonder if it is a good idea to delay integrating the apply
machinery into "am" until it is ready?
--
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 41/44] am: use be_silent in 'struct apply_state' to shut up applying patches

2016-06-10 Thread Christian Couder
Signed-off-by: Christian Couder 
---
 builtin/am.c | 29 -
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/builtin/am.c b/builtin/am.c
index a16b06c..43f7316 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1525,7 +1525,6 @@ static int run_apply(const struct am_state *state, const 
char *index_file)
struct argv_array apply_paths = ARGV_ARRAY_INIT;
struct argv_array apply_opts = ARGV_ARRAY_INIT;
struct apply_state apply_state;
-   int save_stdout_fd, save_stderr_fd;
int res, opts_left;
char *save_index_file;
static struct lock_file lock_file;
@@ -1559,18 +1558,6 @@ static int run_apply(const struct am_state *state, const 
char *index_file)
OPT_END()
};
 
-   /*
-* If we are allowed to fall back on 3-way merge, don't give false
-* errors during the initial attempt.
-*/
-
-   if (state->threeway && !index_file) {
-   save_stdout_fd = dup(1);
-   dup_devnull(1);
-   save_stderr_fd = dup(2);
-   dup_devnull(2);
-   }
-
if (index_file) {
save_index_file = get_index_file();
set_index_file((char *)index_file);
@@ -1593,6 +1580,14 @@ static int run_apply(const struct am_state *state, const 
char *index_file)
else
apply_state.check_index = 1;
 
+   /*
+* If we are allowed to fall back on 3-way merge, don't give false
+* errors during the initial attempt.
+*/
+
+   if (state->threeway && !index_file)
+   apply_state.be_silent = 1;
+
if (check_apply_state(&apply_state, 0))
die("check_apply_state() failed");
 
@@ -1600,14 +1595,6 @@ static int run_apply(const struct am_state *state, const 
char *index_file)
 
res = apply_all_patches(&apply_state, apply_paths.argc, 
apply_paths.argv, 0);
 
-   /* Restore stdout and stderr */
-   if (state->threeway && !index_file) {
-   dup2(save_stdout_fd, 1);
-   close(save_stdout_fd);
-   dup2(save_stderr_fd, 2);
-   close(save_stderr_fd);
-   }
-
if (index_file)
set_index_file(save_index_file);
 
-- 
2.9.0.rc2.362.g3cd93d0

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