The branch, hooks has been updated
       via  037113a9728de72d6cb1b0026a3c39138623efe6 (commit)
      from  47c174816efe404595fa05267ead6a8852468620 (commit)

- Log -----------------------------------------------------------------
commit 037113a9728de72d6cb1b0026a3c39138623efe6
Author: Thomas Adam <tho...@xteddy.org>
Commit: Thomas Adam <tho...@xteddy.org>

    new-session: Finish off converting to new flags
---
 cmd-new-session.c |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/cmd-new-session.c b/cmd-new-session.c
index affb881..087bfda 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -41,7 +41,7 @@ const struct cmd_entry cmd_new_session_entry = {
        "[-AdDP] [-c start-directory] [-F format] [-n window-name] "
        "[-s session-name] " CMD_TARGET_SESSION_USAGE " [-x width] "
        "[-y height] [command]",
-       CMD_STARTSERVER|CMD_CANTNEST,
+       CMD_STARTSERVER|CMD_CANTNEST|CMD_PREP_CANFAIL|CMD_PREP_SESSION_T,
        cmd_new_session_exec
 };
 
@@ -57,12 +57,13 @@ enum cmd_retval
 cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args             *args = self->args;
-       struct client           *c = cmdq->client, *c0;
-       struct session          *s, *attach_sess, *groupwith;
+       struct client           *c = cmdq->client;
+       struct session          *s, *attach_sess;
+       struct session          *groupwith = cmdq->state.tflag.s;
        struct window           *w;
        struct environ           env;
        struct termios           tio, *tiop;
-       const char              *newname, *target, *update, *errstr, *template;
+       const char              *newname, *update, *errstr, *template;
        const char              *path;
        char                   **argv, *cmd, *cause, *cp;
        int                      detached, already_attached, idx, cwd, fd = -1;
@@ -107,14 +108,6 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
                }
        }
 
-       target = args_get(args, 't');
-       if (target != NULL) {
-               groupwith = cmd_find_session(cmdq, target, 0);
-               if (groupwith == NULL)
-                       return (CMD_RETURN_ERROR);
-       } else
-               groupwith = NULL;
-
        /* Set -d if no client. */
        detached = args_has(args, 'd');
        if (c == NULL)
@@ -128,8 +121,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
        /* Get the new session working directory. */
        if (args_has(args, 'c')) {
                ft = format_create();
-               if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)
-                       format_client(ft, c0);
+               format_client(ft, c);
                cp = format_expand(ft, args_get(args, 'c'));
                format_free(ft);
 
@@ -146,8 +138,6 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
                cwd = fd;
        } else if (c != NULL && c->session == NULL)
                cwd = c->cwd;
-       else if ((c0 = cmd_current_client(cmdq)) != NULL)
-               cwd = c0->session->cwd;
        else {
                fd = open(".", O_RDONLY);
                cwd = fd;
@@ -210,10 +200,10 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
        /* Figure out the command for the new window. */
        argc = -1;
        argv = NULL;
-       if (target == NULL && args->argc != 0) {
+       if (!args_has(args, 't') && args->argc != 0) {
                argc = args->argc;
                argv = args->argv;
-       } else if (target == NULL) {
+       } else {
                cmd = options_get_string(&global_s_options, "default-command");
                if (cmd != NULL && *cmd != '\0') {
                        argc = 1;
@@ -260,7 +250,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
         * If a target session is given, this is to be part of a session group,
         * so add it to the group and synchronize.
         */
-       if (groupwith != NULL) {
+       if (args_has(args, 't')) {
                session_group_add(groupwith, s);
                session_group_synchronize_to(s);
                session_select(s, RB_ROOT(&s->windows)->idx);
@@ -296,8 +286,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
                        template = NEW_SESSION_TEMPLATE;
 
                ft = format_create();
-               if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)
-                       format_client(ft, c0);
+               format_client(ft, c);
                format_session(ft, s);
 
                cp = format_expand(ft, template);


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

Summary of changes:
 cmd-new-session.c |   31 ++++++++++---------------------
 1 files changed, 10 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to