The branch, hooks has been updated
       via  24825bab1dd049380c5a8dd81569a99165f715a3 (commit)
       via  145a8b9343322cfdf3c4d0e50c7c529ed986b8a1 (commit)
       via  681ac92926001e158bf7e6579ab3479f7d9b7fff (commit)
       via  79c443d526f6683f6fa6a52e787be7f2883b3f4c (commit)
      from  46c21eb3b9818a9cec9fedf76a4446c27ce115a8 (commit)

- Log -----------------------------------------------------------------
commit 24825bab1dd049380c5a8dd81569a99165f715a3
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Use prep flags for refresh-client.
---
 cmd-refresh-client.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c
index f693872..e398398 100644
--- a/cmd-refresh-client.c
+++ b/cmd-refresh-client.c
@@ -30,7 +30,7 @@ const struct cmd_entry cmd_refresh_client_entry = {
        "refresh-client", "refresh",
        "C:St:", 0, 0,
        "[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
-       0,
+       CMD_PREP_CLIENT_T,
        cmd_refresh_client_exec
 };
 
@@ -38,13 +38,10 @@ enum cmd_retval
 cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args     *args = self->args;
-       struct client   *c;
+       struct client   *c = cmdq->state.c;
        const char      *size;
        u_int            w, h;
 
-       if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL)
-               return (CMD_RETURN_ERROR);
-
        if (args_has(args, 'C')) {
                if ((size = args_get(args, 'C')) == NULL) {
                        cmdq_error(cmdq, "missing size");


commit 145a8b9343322cfdf3c4d0e50c7c529ed986b8a1
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Hooks need to go between guards too.
---
 cmd-queue.c |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/cmd-queue.c b/cmd-queue.c
index a0d707d..d364ba8 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -206,15 +206,18 @@ cmdq_continue(struct cmd_q *cmdq)
                        log_debug("cmdq %p: %s (client %d)", cmdq, s,
                            cmdq->client != NULL ? cmdq->client->ibuf.fd : -1);
 
-                       if (cmd_prepare_state(cmd, cmdq) != 0)
-                               break;
-
                        cmdq->time = time(NULL);
                        cmdq->number++;
 
                        flags = !!(cmd->flags & CMD_CONTROL);
                        guard = cmdq_guard(cmdq, "begin", flags);
 
+                       if (cmd_prepare_state(cmd, cmdq) != 0) {
+                               if (guard)
+                                       cmdq_guard(cmdq, "error", flags);
+                               break;
+                       }
+
                        if (cmdq->state.tflag.s != NULL)
                                hooks = &cmdq->state.tflag.s->hooks;
                        else if (cmdq->state.sflag.s != NULL)
@@ -232,18 +235,16 @@ cmdq_continue(struct cmd_q *cmdq)
                                retval = CMD_RETURN_ERROR;
                        else
                                retval = cmd->entry->exec(cmd, cmdq);
-                       if (retval != CMD_RETURN_ERROR)
-                               cmdq_run_hook(hooks, "after", cmd, cmdq);
-
-                       if (guard) {
-                               if (retval == CMD_RETURN_ERROR)
+                       if (retval == CMD_RETURN_ERROR) {
+                               if (guard)
                                        cmdq_guard(cmdq, "error", flags);
-                               else
-                                       cmdq_guard(cmdq, "end", flags);
+                               break;
                        }
+                       cmdq_run_hook(hooks, "after", cmd, cmdq);
+
+                       if (guard)
+                               cmdq_guard(cmdq, "end", flags);
 
-                       if (retval == CMD_RETURN_ERROR)
-                               break;
                        if (retval == CMD_RETURN_WAIT)
                                goto out;
                        if (retval == CMD_RETURN_STOP) {


commit 681ac92926001e158bf7e6579ab3479f7d9b7fff
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Tidy cmd_continue loop order and don't drop %error when prepare fails.
---
 cmd-queue.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/cmd-queue.c b/cmd-queue.c
index bcb54df..a0d707d 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -180,6 +180,7 @@ int
 cmdq_continue(struct cmd_q *cmdq)
 {
        struct cmd_q_item       *next;
+       struct cmd              *cmd;
        struct hooks            *hooks;
        enum cmd_retval          retval;
        int                      empty, guard, flags;
@@ -199,39 +200,40 @@ cmdq_continue(struct cmd_q *cmdq)
 
        do {
                while (cmdq->cmd != NULL) {
-                       if (cmd_prepare_state(cmdq->cmd, cmdq) != 0)
-                               break;
-
-                       if (cmdq->state.tflag.s != NULL)
-                               hooks = &cmdq->state.tflag.s->hooks;
-                       else if (cmdq->state.sflag.s != NULL)
-                               hooks = &cmdq->state.sflag.s->hooks;
-                       else
-                               hooks = &global_hooks;
+                       cmd = cmdq->cmd;
 
-                       cmd_print(cmdq->cmd, s, sizeof s);
+                       cmd_print(cmd, s, sizeof s);
                        log_debug("cmdq %p: %s (client %d)", cmdq, s,
                            cmdq->client != NULL ? cmdq->client->ibuf.fd : -1);
 
+                       if (cmd_prepare_state(cmd, cmdq) != 0)
+                               break;
+
                        cmdq->time = time(NULL);
                        cmdq->number++;
 
-                       flags = !!(cmdq->cmd->flags & CMD_CONTROL);
+                       flags = !!(cmd->flags & CMD_CONTROL);
                        guard = cmdq_guard(cmdq, "begin", flags);
 
-                       cmdq_run_hook(hooks, "before", cmdq->cmd, cmdq);
+                       if (cmdq->state.tflag.s != NULL)
+                               hooks = &cmdq->state.tflag.s->hooks;
+                       else if (cmdq->state.sflag.s != NULL)
+                               hooks = &cmdq->state.sflag.s->hooks;
+                       else
+                               hooks = &global_hooks;
+                       cmdq_run_hook(hooks, "before", cmd, cmdq);
 
                        /*
                         * hooks_run will change the state before each hook, so
                         * it needs to be restored afterwards. XXX not very
                         * obvious how this works from here...
                         */
-                       if (cmd_prepare_state(cmdq->cmd, cmdq) != 0)
-                               break;
-
-                       retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
+                       if (cmd_prepare_state(cmd, cmdq) != 0)
+                               retval = CMD_RETURN_ERROR;
+                       else
+                               retval = cmd->entry->exec(cmd, cmdq);
                        if (retval != CMD_RETURN_ERROR)
-                               cmdq_run_hook(hooks, "after", cmdq->cmd, cmdq);
+                               cmdq_run_hook(hooks, "after", cmd, cmdq);
 
                        if (guard) {
                                if (retval == CMD_RETURN_ERROR)


commit 79c443d526f6683f6fa6a52e787be7f2883b3f4c
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Do not break on error before printing guards.
---
 cmd-queue.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/cmd-queue.c b/cmd-queue.c
index d63e219..bcb54df 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -230,9 +230,8 @@ cmdq_continue(struct cmd_q *cmdq)
                                break;
 
                        retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
-                       if (retval == CMD_RETURN_ERROR)
-                               break;
-                       cmdq_run_hook(hooks, "after", cmdq->cmd, cmdq);
+                       if (retval != CMD_RETURN_ERROR)
+                               cmdq_run_hook(hooks, "after", cmdq->cmd, cmdq);
 
                        if (guard) {
                                if (retval == CMD_RETURN_ERROR)


-----------------------------------------------------------------------

Summary of changes:
 cmd-queue.c          |   54 +++++++++++++++++++++++++------------------------
 cmd-refresh-client.c |    7 +----
 2 files changed, 30 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to