The branch, hooks has been updated
       via  019529294f41bbccdbb895869cb7aa2dd7468bed (commit)
      from  91864cfde34a8810d5f36164b5cd92c7d1699351 (commit)

- Log -----------------------------------------------------------------
commit 019529294f41bbccdbb895869cb7aa2dd7468bed
Author: Thomas Adam <tho...@xteddy.org>
Commit: Thomas Adam <tho...@xteddy.org>

    new/attach use new prepare flags
    
    Switch new/attach to using the new prepare flags.  Because new -A exists, 
ensure
    the session from new is copied across so that attach uses the correct 
session,
    etc.
---
 cmd-attach-session.c |   37 +++++++++----------------------------
 cmd-new-session.c    |   13 ++++++++++---
 tmux.h               |    3 +--
 3 files changed, 20 insertions(+), 33 deletions(-)

diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index 160f2a8..3364509 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -36,19 +36,17 @@ const struct cmd_entry cmd_attach_session_entry = {
        "attach-session", "attach",
        "c:drt:", 0, 0,
        "[-dr] [-c working-directory] " CMD_TARGET_SESSION_USAGE,
-       CMD_CANTNEST|CMD_STARTSERVER,
+       CMD_CANTNEST|CMD_STARTSERVER|CMD_PREP_SESSION_T|CMD_PREP_PANE_T,
        cmd_attach_session_exec
 };
 
 enum cmd_retval
-cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
-    const char *cflag)
+cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag)
 {
-       struct session          *s;
-       struct client           *c;
-       struct winlink          *wl = NULL;
-       struct window           *w = NULL;
-       struct window_pane      *wp = NULL;
+       struct session          *s = cmdq->state.tflag.s;
+       struct client           *c = cmdq->state.c;
+       struct winlink          *wl = cmdq->state.tflag.wl;
+       struct window_pane      *wp = cmdq->state.tflag.wp;
        const char              *update;
        char                    *cause;
        u_int                    i;
@@ -61,22 +59,6 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, 
int dflag, int rflag,
                return (CMD_RETURN_ERROR);
        }
 
-       if (tflag == NULL) {
-               if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
-                       return (CMD_RETURN_ERROR);
-       } else if (tflag[strcspn(tflag, ":.")] != '\0') {
-               if ((wl = cmd_find_pane(cmdq, tflag, &s, &wp)) == NULL)
-                       return (CMD_RETURN_ERROR);
-       } else {
-               if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL)
-                       return (CMD_RETURN_ERROR);
-               w = cmd_lookup_windowid(tflag);
-               if (w == NULL && (wp = cmd_lookup_paneid(tflag)) != NULL)
-                       w = wp->window;
-               if (w != NULL)
-                       wl = winlink_find_by_window(&s->windows, w);
-       }
-
        if (cmdq->client == NULL)
                return (CMD_RETURN_NORMAL);
 
@@ -106,8 +88,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, 
int dflag, int rflag,
 
                if (cflag != NULL) {
                        ft = format_create();
-                       if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
-                               format_client(ft, c);
+                       format_client(ft, c);
                        format_session(ft, s);
                        format_winlink(ft, s, s->curw);
                        format_window_pane(ft, s->curw->window->active);
@@ -189,6 +170,6 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_q 
*cmdq)
 {
        struct args     *args = self->args;
 
-       return (cmd_attach_session(cmdq, args_get(args, 't'),
-           args_has(args, 'd'), args_has(args, 'r'), args_get(args, 'c')));
+       return (cmd_attach_session(cmdq, args_has(args, 'd'),
+           args_has(args, 'r'), args_get(args, 'c')));
 }
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 6057d1c..affb881 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -58,7 +58,7 @@ 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, *groupwith;
+       struct session          *s, *attach_sess, *groupwith;
        struct window           *w;
        struct environ           env;
        struct termios           tio, *tiop;
@@ -90,9 +90,16 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
                        cmdq_error(cmdq, "bad session name: %s", newname);
                        return (CMD_RETURN_ERROR);
                }
-               if (session_find(newname) != NULL) {
+               if ((attach_sess = session_find(newname)) != NULL) {
                        if (args_has(args, 'A')) {
-                               return (cmd_attach_session(cmdq, newname,
+                               /*
+                                * This cmdq is now destined for
+                                * attach-session.  Because attach-session
+                                * will have already been prepared, copy this
+                                * session into its tflag so it can be used.
+                                */
+                               cmdq->state.tflag.s = attach_sess;
+                               return (cmd_attach_session(cmdq,
                                    args_has(args, 'D'), 0, NULL));
                        }
                        cmdq_error(cmdq, "duplicate session: %s", newname);
diff --git a/tmux.h b/tmux.h
index 843d0eb..03098e7 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1885,8 +1885,7 @@ extern const struct cmd_entry cmd_up_pane_entry;
 extern const struct cmd_entry cmd_wait_for_entry;
 
 /* cmd-attach-session.c */
-enum cmd_retval         cmd_attach_session(struct cmd_q *, const char *, int, 
int,
-                    const char *);
+enum cmd_retval         cmd_attach_session(struct cmd_q *, int, int, const 
char *);
 
 /* cmd-list.c */
 struct cmd_list        *cmd_list_parse(int, char **, const char *, u_int, char 
**);


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

Summary of changes:
 cmd-attach-session.c |   37 +++++++++----------------------------
 cmd-new-session.c    |   13 ++++++++++---
 tmux.h               |    3 +--
 3 files changed, 20 insertions(+), 33 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