Thread (48 messages) 48 messages, 3 authors, 2016-06-16

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

STALE3762d

From: Christian Couder <hidden>
Date: 2016-06-16 02:19:51
Subsystem: the rest · Maintainer: Linus Torvalds

Revision v6 of 4 in this series.

Revisions (4)
  1. v6 current
  2. v8 [diff vs current]
  3. v9 [diff vs current]
  4. v14 [diff vs current]
Signed-off-by: Christian Couder <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help