From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C6241D5CC6 for ; Sun, 15 Mar 2026 11:19:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773573557; cv=none; b=UurgECFSNZfdrZ/Zn7VpuQG9BbetgKAEEBgafQJ/6Ep2oEO/ey/cxEAusdt8GhFqMF8KAfEmYIyIm/YXjLxoagAQVbUFOjHqj2Oe6qlyQaRQjQrKafs3qFT9ofNl4FXBLiUJYpUTvR0xJDtBReXykSi94GEdrmq67AiMXtaqEEM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773573557; c=relaxed/simple; bh=3pwwIwK7KwFWwCM/PN4/4IjOV9q2OOfXLFqkwqDlI2s=; h=Message-Id:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=IaoU4eGmvU+scxcIlJFJmwsK9zOVBBMbbyOWd5Z3N5wObVY2FHUlzK23BNqxAIrQo4LqvRCGuDrx+/4aia6PceOV3N9n8RMfjQGmDLHJI+bbMroqGQLenFU4BYG+StIg0Ley4KLcIXFdl39+hwRZQzl9WP9pmwS3ASS5fYLhEQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kiKRQe9M; arc=none smtp.client-ip=74.125.82.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kiKRQe9M" Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-2c0bcd8f194so441445eec.1 for ; Sun, 15 Mar 2026 04:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773573555; x=1774178355; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=pfrcaOcAPAuxlqMX56ZJ4gIup8pT6bOgld5jWlpLg2M=; b=kiKRQe9MwJInKQLU/tyvScb6b6I0d2Eq4GC0GMU5OKUeCDgAr2cZ/tXDE+drmEFqmC VgdtYtJ+0q+K9Zc3VWRMKYHs2yhxwIrcSD4VQtUgU4aYaKkS/LFDXxAb88nud96rqtM7 l4EUmRQCBr/LhWI5XyAlm+qy4H5MRAK76Zte6LYwY7HLf5lexgHDObniQNIXOAGDuQKh uDq+QZjO7vfvqX1dBVw0h0ooQQCyI71FVusG6YbCQJwKEmpJz9vRe2pQMYgWr7jCsLLH RtDdJc6VUNL6V5EesfT5T1SBRvJ2M/2+JnGkdiW8HPtCABJW8MDdGUjAJjteY56Wzm8q LGwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773573555; x=1774178355; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pfrcaOcAPAuxlqMX56ZJ4gIup8pT6bOgld5jWlpLg2M=; b=NqJy8WEjKRFUIhGUujdvjnFkniWIMpjiuOEMIYQnQY3t2buyLZzXjemylsPmjyYx62 ofAopQARZxGMmPAB5TgqKE8eqLrLKHCfjm93ckdxWHOB+tmEcf6dQ9RA8RATY2sDUx7E K0WmwyRV7F7EX3M5xHehHlYcI8GFAD9UIprADh2XAjh8dRww8Mko8YEYYvchNDgok6N6 eGi4lmBH+IAedXsVYpHvNFzpEbJFbbePPMw2eOSiilpl3kymeMzo8+3iA0RA1PBbgfds 4BlJuRmm3af4eGRKanZ+hLem7b4tgNlc6rRz7FKM5pBMpGCjlkikwa6Qc7fLha9ytKze k2gg== X-Gm-Message-State: AOJu0YwtcxejWDwWcr6C8MVliw8Lp2PolYq+6fma0BSnBGyOdbQPnGFX JCBHJbElssP/2sJLcc21fj0rbenzlSMEmr8HfVJMfVlSlrzbQCeVdW8E7Lxz8w== X-Gm-Gg: ATEYQzw0I2f5H3tRw6HmkYTwYGlxo7+YyM/JfCTPVwY5HZLSzvz9jhSydQbsKP6aebw AXjI4J7fdFiEPaLr2YkHthB1NhnL0gx4tH/WT1Wse35yCwKGvxX2vngCV1Fv9zaVLulHnqWYZui O+h0mPSyV1YCLGvy2nTPRWqtC1gp/78SGF4EnuFhIi45TYdkrO3jnzmW99wg9UmaOituCK/rAsy EZFrH8OOxZYORF0oY84vG9v3K9nG6Vh4iBsOp54rNqsy0IbkfywJLprFvKHXqRzjGay78DS22iy lmGM9TQxwWcaj5ZviwSDMA+VEkMBenIen5nJMz2hPfztx+h8x/PCVCfOFyHPVo5Jsrs4EgwBCHP q1Yl9I4wzuIj9apWXiaizk8sJXmxEVr0BLLzz0yCGJZibPMu4FuESfRc0humPGbpoUY40/0gc6L FFB6NAXsAaEGO9iFNZaa672HzUX/Q= X-Received: by 2002:a05:7300:7b90:b0:2ba:a60a:15ef with SMTP id 5a478bee46e88-2bea54500e2mr3913813eec.1.1773573554728; Sun, 15 Mar 2026 04:19:14 -0700 (PDT) Received: from [127.0.0.1] ([172.215.216.194]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2beab3eec52sm11577557eec.14.2026.03.15.04.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2026 04:19:14 -0700 (PDT) Message-Id: In-Reply-To: References: From: "Harald Nordgren via GitGitGadget" Date: Sun, 15 Mar 2026 11:19:09 +0000 Subject: [PATCH v5 0/4] checkout: 'autostash' for branch switching Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Harald Nordgren cc: Phillip Wood phillip.wood123@gmail.com Harald Nordgren (4): stash: add --ours-label, --theirs-label, --base-label for apply sequencer: allow create_autostash to run silently sequencer: teach autostash apply to take optional conflict marker labels checkout: -m (--merge) uses autostash when switching branches Documentation/git-checkout.adoc | 58 +++++----- Documentation/git-stash.adoc | 11 +- Documentation/git-switch.adoc | 27 ++--- builtin/checkout.c | 180 ++++++++++++++++++-------------- builtin/stash.c | 32 ++++-- sequencer.c | 67 +++++++++--- sequencer.h | 4 + t/t3420-rebase-autostash.sh | 24 +++-- t/t3903-stash.sh | 18 ++++ t/t7201-co.sh | 160 ++++++++++++++++++++++++++++ t/t7600-merge.sh | 2 +- xdiff-interface.c | 12 +++ xdiff-interface.h | 1 + 13 files changed, 447 insertions(+), 149 deletions(-) base-commit: dc6ecd5354dca88d51b6d6562777fc8fc10d77e1 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2234%2FHaraldNordgren%2Fcheckout_autostash-v5 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2234/HaraldNordgren/checkout_autostash-v5 Pull-Request: https://github.com/git/git/pull/2234 Range-diff vs v4: -: ---------- > 1: 00d8920498 stash: add --ours-label, --theirs-label, --base-label for apply -: ---------- > 2: 5d176f1700 sequencer: allow create_autostash to run silently -: ---------- > 3: 3d6829438a sequencer: teach autostash apply to take optional conflict marker labels 1: 5d49c0031a ! 4: 7f3735d40e checkout: -m (--merge) uses autostash when switching branches @@ Documentation/git-checkout.adoc: working tree, by copying them from elsewhere, e + afterwards. If the local changes do not overlap with the + differences between branches, the switch proceeds without + stashing. If reapplying the stash results in conflicts, the -+ entry is saved to the stash list so you can use `git stash -+ pop` to recover and `git stash drop` when done. ++ entry is saved to the stash list. Resolve the conflicts ++ and run `git stash drop` when done, or clear the working ++ tree (e.g. with `git reset --hard`) before running `git stash ++ pop` later to re-apply your changes. + When checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths. This option cannot be @@ Documentation/git-checkout.adoc: $ git checkout mytopic -You can give the `-m` flag to the command, which would try a -three-way merge: -+You can give the `-m` flag to the command, which would save the local -+changes in a stash entry and reset the working tree to allow switching: ++You can give the `-m` flag to the command, which would carry your local ++changes to the new branch: ------------ $ git checkout -m mytopic -Auto-merging frotz -+Applied autostash. ++Switched to branch 'mytopic' ------------ -After this three-way merge, the local modifications are _not_ @@ Documentation/git-switch.adoc: variable. + local changes do not overlap with the differences between + branches, the switch proceeds without stashing. If + reapplying the stash results in conflicts, the entry is -+ saved to the stash list so you can use `git stash pop` to -+ recover and `git stash drop` when done. ++ saved to the stash list. Resolve the conflicts and run ++ `git stash drop` when done, or clear the working tree ++ (e.g. with `git reset --hard`) before running `git stash pop` ++ later to re-apply your changes. `--conflict=