The branch, hooks has been updated
       via  6e80058d23751e100ec99ef21e9a1abf1fa28a2d (commit)
       via  74b929cf81ef1c3ec52cd31a009cf7a66c86511b (commit)
      from  5d86a369be23403d0ed5c3a68b687e12d8a2979a (commit)

- Log -----------------------------------------------------------------
commit 6e80058d23751e100ec99ef21e9a1abf1fa28a2d
Merge: 74b929c 5d86a36
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Merge branch 'hooks' of ssh://git.code.sf.net/p/tmux/tmux-code into hooks

 cmd-pipe-pane.c     |   10 +++-------
 cmd-resize-pane.c   |   12 ++++--------
 cmd-select-layout.c |   10 ++++------
 3 files changed, 11 insertions(+), 21 deletions(-)


commit 74b929cf81ef1c3ec52cd31a009cf7a66c86511b
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Use prepare flags in cmd-{set,show}-{environment,hooks}.c.
---
 cmd-set-environment.c  |   10 +++-------
 cmd-set-hook.c         |    8 ++++----
 cmd-show-environment.c |   10 +++-------
 cmd-show-hooks.c       |    8 ++++----
 4 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/cmd-set-environment.c b/cmd-set-environment.c
index 83e63b4..5221c3d 100644
--- a/cmd-set-environment.c
+++ b/cmd-set-environment.c
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_set_environment_entry = {
        "set-environment", "setenv",
        "grt:u", 1, 2,
        "[-gru] " CMD_TARGET_SESSION_USAGE " name [value]",
-       0,
+       CMD_PREP_SESSION_T,
        cmd_set_environment_exec
 };
 
@@ -41,7 +41,6 @@ enum cmd_retval
 cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args     *args = self->args;
-       struct session  *s;
        struct environ  *env;
        const char      *name, *value;
 
@@ -62,11 +61,8 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q 
*cmdq)
 
        if (args_has(self->args, 'g'))
                env = &global_environ;
-       else {
-               if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == 
NULL)
-                       return (CMD_RETURN_ERROR);
-               env = &s->environ;
-       }
+       else
+               env = &cmdq->state.tflag.s->environ;
 
        if (args_has(self->args, 'u')) {
                if (value != NULL) {
diff --git a/cmd-set-hook.c b/cmd-set-hook.c
index 511d387..7f12850 100644
--- a/cmd-set-hook.c
+++ b/cmd-set-hook.c
@@ -41,16 +41,16 @@ enum cmd_retval
 cmd_set_hook_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args     *args = self->args;
-       struct session  *s;
        struct cmd_list *cmdlist;
        struct hooks    *hooks;
        struct hook     *hook;
        char            *cause;
        const char      *name, *cmd;
 
-       if ((s = cmdq->state.tflag.s) == NULL)
-               return (CMD_RETURN_ERROR);
-       hooks = args_has(args, 'g') ? &global_hooks : &s->hooks;
+       if (args_has(args, 'g'))
+               hooks = &global_hooks;
+       else
+               hooks = &cmdq->state.tflag.s->hooks;
 
        name = args->argv[0];
        if (*name == '\0') {
diff --git a/cmd-show-environment.c b/cmd-show-environment.c
index 7737752..afe7cb1 100644
--- a/cmd-show-environment.c
+++ b/cmd-show-environment.c
@@ -33,7 +33,7 @@ const struct cmd_entry cmd_show_environment_entry = {
        "show-environment", "showenv",
        "gt:", 0, 1,
        "[-g] " CMD_TARGET_SESSION_USAGE " [name]",
-       0,
+       CMD_PREP_SESSION_T,
        cmd_show_environment_exec
 };
 
@@ -41,17 +41,13 @@ enum cmd_retval
 cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args             *args = self->args;
-       struct session          *s;
        struct environ          *env;
        struct environ_entry    *envent;
 
        if (args_has(self->args, 'g'))
                env = &global_environ;
-       else {
-               if ((s = cmd_find_session(cmdq, args_get(args, 't'), 0)) == 
NULL)
-                       return (CMD_RETURN_ERROR);
-               env = &s->environ;
-       }
+       else
+               env = &cmdq->state.tflag.s->environ;
 
        if (args->argc != 0) {
                envent = environ_find(env, args->argv[0]);
diff --git a/cmd-show-hooks.c b/cmd-show-hooks.c
index 85b6556..fa01d5b 100644
--- a/cmd-show-hooks.c
+++ b/cmd-show-hooks.c
@@ -41,15 +41,15 @@ enum cmd_retval
 cmd_show_hooks_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args     *args = self->args;
-       struct session  *s;
        struct hooks    *hooks;
        struct hook     *hook;
        char             tmp[BUFSIZ];
        size_t           used;
 
-       if ((s = cmdq->state.tflag.s) == NULL)
-               return (CMD_RETURN_ERROR);
-       hooks = args_has(args, 'g') ? &global_hooks : &s->hooks;
+       if (args_has(args, 'g'))
+               hooks = &global_hooks;
+       else
+               hooks = &cmdq->state.tflag.s->hooks;
 
        RB_FOREACH(hook, hooks_tree, &hooks->tree) {
                used = xsnprintf(tmp, sizeof tmp, "%s -> ", hook->name);


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

Summary of changes:
 cmd-set-environment.c  |   10 +++-------
 cmd-set-hook.c         |    8 ++++----
 cmd-show-environment.c |   10 +++-------
 cmd-show-hooks.c       |    8 ++++----
 4 files changed, 14 insertions(+), 22 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