The branch, master has been updated
       via  3a2e9d805a80e683078994d86a5390bf5deed9fc (commit)
       via  911ef4e69a483d11045551628971761e8d1ecc22 (commit)
      from  1994ae4640077ad43430e5a94886546976239b36 (commit)

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

    Fix error reporting for client commands by adding a flag to cmd_find_client 
to
    tell it whether or not to show errors, sometimes it's needed and sometimes 
not.
---
 cmd-break-pane.c      |    2 +-
 cmd-command-prompt.c  |    2 +-
 cmd-confirm-before.c  |    2 +-
 cmd-detach-client.c   |    2 +-
 cmd-display-message.c |    4 +---
 cmd-display-panes.c   |    2 +-
 cmd-lock-server.c     |    2 +-
 cmd-new-window.c      |    2 +-
 cmd-pipe-pane.c       |    2 +-
 cmd-refresh-client.c  |    2 +-
 cmd-show-messages.c   |    2 +-
 cmd-split-window.c    |    2 +-
 cmd-suspend-client.c  |    2 +-
 cmd-switch-client.c   |    2 +-
 cmd.c                 |   12 ++++++++----
 tmux.h                |    2 +-
 16 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/cmd-break-pane.c b/cmd-break-pane.c
index a4350fe..c270ca0 100644
--- a/cmd-break-pane.c
+++ b/cmd-break-pane.c
@@ -97,7 +97,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
                        template = BREAK_PANE_TEMPLATE;
 
                ft = format_create();
-               if ((c = cmd_find_client(ctx, NULL)) != NULL)
+               if ((c = cmd_find_client(ctx, NULL, 1)) != NULL)
                        format_client(ft, c);
                format_session(ft, s);
                format_winlink(ft, s, wl);
diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c
index e1db3dd..9728489 100644
--- a/cmd-command-prompt.c
+++ b/cmd-command-prompt.c
@@ -94,7 +94,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
        char                            *prompt, *ptr, *input = NULL;
        size_t                           n;
 
-       if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
+       if ((c = cmd_find_client(ctx, args_get(args, 't'), 0)) == NULL)
                return (CMD_RETURN_ERROR);
 
        if (c->prompt_string != NULL)
diff --git a/cmd-confirm-before.c b/cmd-confirm-before.c
index 0b41592..30db5bd 100644
--- a/cmd-confirm-before.c
+++ b/cmd-confirm-before.c
@@ -79,7 +79,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
                return (CMD_RETURN_ERROR);
        }
 
-       if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
+       if ((c = cmd_find_client(ctx, args_get(args, 't'), 0)) == NULL)
                return (CMD_RETURN_ERROR);
 
        if ((prompt = args_get(args, 'p')) != NULL)
diff --git a/cmd-detach-client.c b/cmd-detach-client.c
index f75b37a..4b447e1 100644
--- a/cmd-detach-client.c
+++ b/cmd-detach-client.c
@@ -61,7 +61,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
                                server_write_client(c, msgtype, NULL, 0);
                }
        } else {
-               c = cmd_find_client(ctx, args_get(args, 't'));
+               c = cmd_find_client(ctx, args_get(args, 't'), 0);
                if (c == NULL)
                        return (CMD_RETURN_ERROR);
 
diff --git a/cmd-display-message.c b/cmd-display-message.c
index 8bcd43f..f0cd66c 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -55,8 +55,6 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx 
*ctx)
        time_t                   t;
        size_t                   len;
 
-       c = cmd_find_client(ctx, args_get(args, 'c'));
-
        if (args_has(args, 't')) {
                wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
                if (wl == NULL)
@@ -79,7 +77,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx 
*ctx)
                template = DISPLAY_MESSAGE_TEMPLATE;
 
        ft = format_create();
-       if (c != NULL)
+       if ((c = cmd_find_client(ctx, args_get(args, 'c'), 1)) != NULL)
                format_client(ft, c);
        format_session(ft, s);
        format_winlink(ft, s, wl);
diff --git a/cmd-display-panes.c b/cmd-display-panes.c
index 2745ac5..dd4a333 100644
--- a/cmd-display-panes.c
+++ b/cmd-display-panes.c
@@ -42,7 +42,7 @@ cmd_display_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
        struct args     *args = self->args;
        struct client   *c;
 
-       if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
+       if ((c = cmd_find_client(ctx, args_get(args, 't'), 0)) == NULL)
                return (CMD_RETURN_ERROR);
 
        server_set_identify(c);
diff --git a/cmd-lock-server.c b/cmd-lock-server.c
index db0b7dc..4eb0b70 100644
--- a/cmd-lock-server.c
+++ b/cmd-lock-server.c
@@ -74,7 +74,7 @@ cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx 
*ctx)
                        return (CMD_RETURN_ERROR);
                server_lock_session(s);
        } else {
-               if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
+               if ((c = cmd_find_client(ctx, args_get(args, 't'), 0)) == NULL)
                        return (CMD_RETURN_ERROR);
                server_lock_client(c);
        }
diff --git a/cmd-new-window.c b/cmd-new-window.c
index d8c576a..e50b234 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -126,7 +126,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
                        template = NEW_WINDOW_TEMPLATE;
 
                ft = format_create();
-               if ((c = cmd_find_client(ctx, NULL)) != NULL)
+               if ((c = cmd_find_client(ctx, NULL, 1)) != NULL)
                    format_client(ft, c);
                format_session(ft, s);
                format_winlink(ft, s, wl);
diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c
index 8f53b6e..3c6211d 100644
--- a/cmd-pipe-pane.c
+++ b/cmd-pipe-pane.c
@@ -56,7 +56,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 
        if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
                return (CMD_RETURN_ERROR);
-       c = cmd_find_client(ctx, NULL);
+       c = cmd_find_client(ctx, NULL, 1);
 
        /* Destroy the old pipe. */
        old_fd = wp->pipe_fd;
diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c
index 849154d..7bec520 100644
--- a/cmd-refresh-client.c
+++ b/cmd-refresh-client.c
@@ -44,7 +44,7 @@ cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
        const char      *size;
        u_int            w, h;
 
-       if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
+       if ((c = cmd_find_client(ctx, args_get(args, 't'), 0)) == NULL)
                return (CMD_RETURN_ERROR);
 
        if (args_has(args, 'C')) {
diff --git a/cmd-show-messages.c b/cmd-show-messages.c
index d8c1851..728e170 100644
--- a/cmd-show-messages.c
+++ b/cmd-show-messages.c
@@ -48,7 +48,7 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
        char                    *tim;
        u_int                    i;
 
-       if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
+       if ((c = cmd_find_client(ctx, args_get(args, 't'), 0)) == NULL)
                return (CMD_RETURN_ERROR);
 
        for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 859d5fd..54d5bcd 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -151,7 +151,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
                        template = SPLIT_WINDOW_TEMPLATE;
 
                ft = format_create();
-               if ((c = cmd_find_client(ctx, NULL)) != NULL)
+               if ((c = cmd_find_client(ctx, NULL, 1)) != NULL)
                    format_client(ft, c);
                format_session(ft, s);
                format_winlink(ft, s, wl);
diff --git a/cmd-suspend-client.c b/cmd-suspend-client.c
index 95278f9..68affac 100644
--- a/cmd-suspend-client.c
+++ b/cmd-suspend-client.c
@@ -45,7 +45,7 @@ cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
        struct args     *args = self->args;
        struct client   *c;
 
-       if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
+       if ((c = cmd_find_client(ctx, args_get(args, 't'), 0)) == NULL)
                return (CMD_RETURN_ERROR);
 
        tty_stop_tty(&c->tty);
diff --git a/cmd-switch-client.c b/cmd-switch-client.c
index 1ca0c41..29a3d78 100644
--- a/cmd-switch-client.c
+++ b/cmd-switch-client.c
@@ -64,7 +64,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
        struct client   *c;
        struct session  *s;
 
-       if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
+       if ((c = cmd_find_client(ctx, args_get(args, 'c'), 0)) == NULL)
                return (CMD_RETURN_ERROR);
 
        if (args_has(args, 'r')) {
diff --git a/cmd.c b/cmd.c
index 5c02314..461d39f 100644
--- a/cmd.c
+++ b/cmd.c
@@ -516,15 +516,19 @@ cmd_choose_client(struct clients *cc)
 
 /* Find the target client or report an error and return NULL. */
 struct client *
-cmd_find_client(struct cmd_ctx *ctx, const char *arg)
+cmd_find_client(struct cmd_ctx *ctx, const char *arg, int quiet)
 {
        struct client   *c;
        char            *tmparg;
        size_t           arglen;
 
        /* A NULL argument means the current client. */
-       if (arg == NULL)
-               return (cmd_current_client(ctx));
+       if (arg == NULL) {
+               c = cmd_current_client(ctx);
+               if (c == NULL && !quiet)
+                       ctx->error(ctx, "no clients");
+               return (c);
+       }
        tmparg = xstrdup(arg);
 
        /* Trim a single trailing colon if any. */
@@ -536,7 +540,7 @@ cmd_find_client(struct cmd_ctx *ctx, const char *arg)
        c = cmd_lookup_client(tmparg);
 
        /* If no client found, report an error. */
-       if (c == NULL)
+       if (c == NULL && !quiet)
                ctx->error(ctx, "client not found: %s", tmparg);
 
        free(tmparg);
diff --git a/tmux.h b/tmux.h
index b80face..c905b66 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1728,7 +1728,7 @@ struct cmd        *cmd_parse(int, char **, char **);
 size_t          cmd_print(struct cmd *, char *, size_t);
 struct session *cmd_current_session(struct cmd_ctx *, int);
 struct client  *cmd_current_client(struct cmd_ctx *);
-struct client  *cmd_find_client(struct cmd_ctx *, const char *);
+struct client  *cmd_find_client(struct cmd_ctx *, const char *, int);
 struct session *cmd_find_session(struct cmd_ctx *, const char *, int);
 struct winlink *cmd_find_window(
                     struct cmd_ctx *, const char *, struct session **);


commit 911ef4e69a483d11045551628971761e8d1ecc22
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Allow display-message with no curclient.
---
 cmd-display-message.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd-display-message.c b/cmd-display-message.c
index 244c557..8bcd43f 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -55,8 +55,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx 
*ctx)
        time_t                   t;
        size_t                   len;
 
-       if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
-               return (CMD_RETURN_ERROR);
+       c = cmd_find_client(ctx, args_get(args, 'c'));
 
        if (args_has(args, 't')) {
                wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
@@ -80,7 +79,8 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx 
*ctx)
                template = DISPLAY_MESSAGE_TEMPLATE;
 
        ft = format_create();
-       format_client(ft, c);
+       if (c != NULL)
+               format_client(ft, c);
        format_session(ft, s);
        format_winlink(ft, s, wl);
        format_window_pane(ft, wp);


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

Summary of changes:
 cmd-break-pane.c      |    2 +-
 cmd-command-prompt.c  |    2 +-
 cmd-confirm-before.c  |    2 +-
 cmd-detach-client.c   |    2 +-
 cmd-display-message.c |    6 ++----
 cmd-display-panes.c   |    2 +-
 cmd-lock-server.c     |    2 +-
 cmd-new-window.c      |    2 +-
 cmd-pipe-pane.c       |    2 +-
 cmd-refresh-client.c  |    2 +-
 cmd-show-messages.c   |    2 +-
 cmd-split-window.c    |    2 +-
 cmd-suspend-client.c  |    2 +-
 cmd-switch-client.c   |    2 +-
 cmd.c                 |   12 ++++++++----
 tmux.h                |    2 +-
 16 files changed, 24 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to