Do not reuse old session group names when a new session is the same as

its original session, GitHub issue 5704.
This commit is contained in:
nicm
2026-10-12 07:52:05 +00:00
committed by tmux update bot
parent f510adb754
commit 12c93f50f0

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: cmd-new-session.c,v 1.153 2026/10/09 13:12:14 nicm Exp $ */
/* $OpenBSD: cmd-new-session.c,v 1.154 2026/10/12 07:52:05 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -82,7 +82,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
char *cause, *cwd = NULL, *cp, *ename;
char *wname = NULL, *sname = NULL, *prefix = NULL;
int detached, already_attached, is_control = 0;
u_int sx, sy, dsx, dsy, count = args_count(args);
u_int sx, sy, dsx, dsy, idx;
u_int count = args_count(args);
struct spawn_context sc = { 0 };
enum cmd_retval retval;
struct cmd_find_state fs;
@@ -316,12 +317,17 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
* so add it to the group and synchronize.
*/
if (group != NULL) {
if (sg == NULL) {
if (groupwith != NULL) {
sg = session_group_new(groupwith->name);
session_group_add(sg, groupwith);
} else
sg = session_group_new(group);
if (sg == NULL && groupwith == NULL)
sg = session_group_new(group);
else if (sg == NULL) {
cp = xstrdup(groupwith->name);
for (idx = 1; session_group_find(cp) != NULL; idx++) {
free(cp);
xasprintf(&cp, "%s-%u", groupwith->name, idx);
}
sg = session_group_new(cp);
free(cp);
session_group_add(sg, groupwith);
}
session_group_add(sg, s);
session_group_synchronize_to(s);