[BACK]Return to cmd-new-session.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-new-session.c between version 1.100 and 1.101

version 1.100, 2017/02/06 15:00:41 version 1.101, 2017/02/09 15:04:53
Line 68 
Line 68 
 {  {
         struct args             *args = self->args;          struct args             *args = self->args;
         struct client           *c = item->client;          struct client           *c = item->client;
         struct session          *s, *as;          struct session          *s, *as, *groupwith;
         struct session          *groupwith = item->state.tflag.s;  
         struct window           *w;          struct window           *w;
         struct environ          *env;          struct environ          *env;
         struct termios           tio, *tiop;          struct termios           tio, *tiop;
         const char              *newname, *target, *errstr, *template;          struct session_group    *sg;
           const char              *newname, *errstr, *template, *group, *prefix;
         const char              *path, *cmd, *cwd, *to_free = NULL;          const char              *path, *cmd, *cwd, *to_free = NULL;
         char                   **argv, *cause, *cp;          char                   **argv, *cause, *cp;
         int                      detached, already_attached, idx, argc;          int                      detached, already_attached, idx, argc;
Line 119 
Line 119 
                 }                  }
         }          }
   
         if ((target = args_get(args, 't')) != NULL) {          /* Is this going to be part of a session group? */
           group = args_get(args, 't');
           if (group != NULL) {
                   groupwith = item->state.tflag.s;
                 if (groupwith == NULL) {                  if (groupwith == NULL) {
                         cmdq_error(item, "no such session: %s", target);                          if (!session_check_name(group)) {
                         goto error;                                  cmdq_error(item, "bad group name: %s", group);
                 }                                  goto error;
         } else                          }
                           sg = session_group_find(group);
                   } else
                           sg = session_group_contains(groupwith);
                   if (sg != NULL)
                           prefix = sg->name;
                   else if (groupwith != NULL)
                           prefix = groupwith->name;
                   else
                           prefix = group;
           } else {
                 groupwith = NULL;                  groupwith = NULL;
                   sg = NULL;
                   prefix = NULL;
           }
   
         /* Set -d if no client. */          /* Set -d if no client. */
         detached = args_has(args, 'd');          detached = args_has(args, 'd');
Line 213 
Line 229 
         if (!args_has(args, 't') && args->argc != 0) {          if (!args_has(args, 't') && args->argc != 0) {
                 argc = args->argc;                  argc = args->argc;
                 argv = args->argv;                  argv = args->argv;
         } else if (groupwith == NULL) {          } else if (sg == NULL && groupwith == NULL) {
                 cmd = options_get_string(global_s_options, "default-command");                  cmd = options_get_string(global_s_options, "default-command");
                 if (cmd != NULL && *cmd != '\0') {                  if (cmd != NULL && *cmd != '\0') {
                         argc = 1;                          argc = 1;
Line 239 
Line 255 
   
         /* Create the new session. */          /* Create the new session. */
         idx = -1 - options_get_number(global_s_options, "base-index");          idx = -1 - options_get_number(global_s_options, "base-index");
         s = session_create(newname, argc, argv, path, cwd, env, tiop, idx, sx,          s = session_create(prefix, newname, argc, argv, path, cwd, env, tiop,
             sy, &cause);              idx, sx, sy, &cause);
         environ_free(env);          environ_free(env);
         if (s == NULL) {          if (s == NULL) {
                 cmdq_error(item, "create session failed: %s", cause);                  cmdq_error(item, "create session failed: %s", cause);
Line 259 
Line 275 
          * If a target session is given, this is to be part of a session group,           * If a target session is given, this is to be part of a session group,
          * so add it to the group and synchronize.           * so add it to the group and synchronize.
          */           */
         if (groupwith != NULL) {          if (group != NULL) {
                 session_group_add(groupwith, s);                  if (sg == NULL) {
                           if (groupwith != NULL) {
                                   sg = session_group_new(groupwith->name);
                                   session_group_add(sg, groupwith);
                           } else
                                   sg = session_group_new(group);
                   }
                   session_group_add(sg, s);
                 session_group_synchronize_to(s);                  session_group_synchronize_to(s);
                 session_select(s, RB_MIN(winlinks, &s->windows)->idx);                  session_select(s, RB_MIN(winlinks, &s->windows)->idx);
         }          }

Legend:
Removed from v.1.100  
changed lines
  Added in v.1.101