Article View: linux.kernel.git
Article #4100[RFC] stash: interaction between -u and -a
From: ιη°δΈθ
Date: Mon, 30 Nov 2026 06:12
Date: Mon, 30 Nov 2026 06:12
151 lines
17027 bytes
17027 bytes
Hi,
While preparing an RFC about adding option support to
`git stash create`, I was looking more closely at `-u` and
`-a` when I noticed something interesting about how they
behave in `git stash push` and `git stash save`.
The `-u` option includes untracked files, while `-a` includes
both untracked and ignored files.
However, when both options are given, their order matters:
git stash push -u -a
untracked and ignored files
git stash push -a -u
untracked files only
Both `--no-include-untracked` and `--no-all` cancel the
selection of untracked and ignored files, regardless of
whether `-u` or `-a` was specified earlier:
git stash push -a --no-include-untracked
neither untracked nor ignored files
git stash push -a --no-include-untracked -u
untracked files only
The documentation explains each option separately, but not what
happens when they are combined. This may be confusing for users.
We could change how these options interact, but that raises
several questions, as I'll discuss below. Another possibility
would be to document the current behavior.
For example, the documentation could say something like:
With `stash push` and `stash save`, `-u` and `-a` are
processed in the order given. When both are specified,
the last one takes effect. Thus, `-u -a` includes both
untracked and ignored files, while `-a -u` includes
only untracked files.
Either `--no-include-untracked` or `--no-all` clears
the selection, regardless of whether it came from `-u`
or `-a`. A later `-u` or `-a` can make a new selection.
Documenting the current behavior as it stands might lead
users to expect it to remain unchanged. Perhaps it would
be better not to document it. On the other hand, leaving it
undocumented means users have to discover these interactions
themselves.
Now, I'd like to think a little about how `-u` and `-a`
could behave when used together.
(A) Make `-a` take precedence over `-u` when both are enabled,
regardless of order.
Both `-u -a` and `-a -u` would include untracked and ignored
files. Today, `-a -u` leaves ignored files alone.
(B) Treat `-u` and `-a` as mutually exclusive, as `git add`
does with `-u` and `-A`.
If both remain enabled after option parsing, this would be an
error. Both `-u -a` and `-a -u` would then fail, whereas they
are currently accepted.
For (A) and (B), I'll assume `-u` and `-a` are tracked
separately, with each negated option canceling only its
corresponding positive option. This seems easier to
reason about, so I'll use that assumption here. A
negated option would not cause an error even if its
positive option had not been given.
For example, `-a -u --no-all` would leave `-u` enabled,
selecting untracked files only, whereas it currently
selects neither class.
Similarly, `-a --no-include-untracked` would leave
`-a` enabled and select both untracked and ignored files,
unlike today.
(C) Add `-X` (or `--include-ignored`) for ignored files only,
similar to `git clean -X`.
For (C), I'll consider `-u` and `-X` as two independent
flags instead.
Here, `-a` would be an alias for `-u -X`, and `--no-all`
would be an alias for `--no-include-untracked` and
`--no-include-ignored` together.
This would allow untracked and ignored files to be selected
independently. Both `-u -a` and `-a -u` would select both
classes.
The negated options would also work independently.
One possible advantage is that each option's effect would
follow directly from its meaning, even in combinations.
For example:
-a --no-include-untracked
ignored files only
-a --no-include-ignored
untracked files only
-a --no-all
neither untracked nor ignored files
`-a --no-include-untracked` illustrates the difference:
unlike (A) and (B), (C) would remove untracked files from
the selection, as the negated option suggests. This would
also differ from today's behavior.
To compare some less obvious combinations, I made this
table. I assume the documentation would describe (B)'s
conflict error and (C)'s aliases. Each cell shows the
result and whether I find it intuitive (Yes/No):
Option sequence Current A B C
-u -a UI/Yes UI/Yes Err/Yes UI/Yes
-a -u U/No UI/Yes Err/Yes UI/Yes
-a --no-include-untracked -/No UI/No UI/No I/Yes
-a -u --no-all -/Yes U/No U/No -/Yes
-u -a --no-all -/Yes U/No U/No -/Yes
-a -u --no-include-untracked -/No UI/No UI/No I/Yes
-a --no-include-untracked -u U/No UI/Yes Err/Yes UI/Yes
-a --no-all -u U/Yes U/Yes U/Yes U/Yes
-a --no-include-ignored N/A/- N/A/- N/A/- U/Yes
Here, U means untracked files, I ignored files, UI both,
and "-" neither. Err means an error; N/A means the option
is not available.
Writing this out, I find (C) more consistent than I had
expected, and I'm tempted to favor it. But it would change
the behavior of some existing combinations, so backward
compatibility is still a concern.
(I'm not sure how difficult (C) would be to implement.)
For now, I think documenting the current behavior would
be the better step. If needed, we could continue to discuss
possible changes separately. What do you think?
Thanks,
Kazumasa
Technical Details
Message-ID:
<CANUHOw0B3xeCw9TDBDV1n5pkwRLBgYEBuY4ZuBmTpeVgDU09Pw@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76657-linux-kernel-git=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76657-linux-kernel-git=dewy.ru
From: kazumasa.shigeta@kanamei.com (ιη°δΈθ)
Newsgroups: linux.kernel.git
Subject: [RFC] stash: interaction between -u and -a
Date: Mon, 30 Nov 2026 00:12:04 -0600
Organization: Usenet Network
Message-ID: <CANUHOw0B3xeCw9TDBDV1n5pkwRLBgYEBuY4ZuBmTpeVgDU09Pw@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: usenet.network;
logging-data="1351474"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:wHdIubJxJQjDcSeylL+Gp6WkLoo= sha256:HouPXo7culBO6RlCf+uAMrCPKe6+QuKYe4uKUca5WHY=
sha1:UQEnbHdvy+1YtzJ2cfiDw9xI8LQ= sha256:WCaU7HuUd8fqQ7g3sWWeVw8J5Ry8UjfglS99skTrJPU=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 3D467125FC6; Mon, 30 Nov 2026 09:12:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.951
X-Spam-Status: No, score=-1.951 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=kanamei.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id TyOdvNYI3xil;
Mon, 30 Nov 2026 09:12:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76657-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=kanamei.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 57177125FC5; Mon, 30 Nov 2026 09:12:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 85D2729B9B; Mon, 30 Nov 2026 06:12:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796019128;
b=YHG+nsfUegEC110+ts5SDmM4+h1V86CvXS3PxalhWD5Ilh7q81LGiXtM2vlv+6WA30En
1TP0fDwR7DRRL8bzwM6Qr+xyRMrB6AelZj/iB8ISxDEuLefEycJvNVW/6tbkyvSj8mkIC
WH392o6DTfw3p3EvJYo6A8ioHxFlnBJdvWqNp8xHtehNtKZ/maLNfehwT531w5xXjZA33
HyAsznldy3dvrWnnxEsD9jhX3AwwQ9vlGRTukj59HGv8YeEc2WsnatXqkjZlDHpMPWvgI
BetlZC4q5vyrv11ibI/qbNVU1v89JIQ/G96KgETPrHukV522uFNyziV9wjUXIDtr0dw==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796019128;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Received:Received:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
From:Date:X-Gm-Features:Message-ID:Subject:To:Content-Type;
bh=I38uxHkR99ia/JwiaYZmPQSH05TsFYd7MmCYe2cN7XI=;
b=sRb9xbD9rHSRsKPjP2Tm029cKh/3HAg74gg2BeuH1g/QAB37bH9QDV25Uz4I3QzKNsi2
0Pph5HYxHhe3C8oBGNe+a861Q7Q3arKPEIII8r8J63cRllcqDByAJErlQxlpZe/W+4myX
ZlWlyR69nifx75xtrqWvJgXGfa4Q1PeuNFnivEd57DWEIDQa0A3t9tQa7NVNf2kSUmD+P
ASXPbONY6yRHx6otr9iQX/jsvUI9N+ycAiyzdEZAmSXlR+Yg8K5Rg2vNIxW60mlemku9R
/jzu3j+IjI97z43e2iFRvaXD1X408hMWiD5nVY/pGKI8y14tQWFKatwUIQGEkEXoQ1A==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=kanamei.com header.i=@kanamei.com header.a=rsa-sha256 header.s=google header.b=r1hXZT6p;
dmarc=none header.from=kanamei.com;
spf=pass smtp.mailfrom=kanamei.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F0D7606A32C;
Mon, 30 Nov 2026 06:12:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=kanamei.com header.i=@kanamei.com header.a=rsa-sha256 header.s=google header.b=r1hXZT6p
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=74.125.82.173
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796019127;
b=SdgZ7Aid8jIF71WlpoWFsriC/t9t4jjgdJNfxeyWUTqNGDMgyClSKhvCVthOMfYa/rWl
0LZ/iOksUT3FroEOMm0RIlXIgv0yKEjr9zHQkoAaVJIzorxJt3nyrbV8mipKATd1IsLBP
TpWdxgvU3QOYhro4fqAlT2z+NHoEwAwcZftNERNLhORf41DakGXYKtCxd7SVDYtboX38A
HE6LsKeb57r1BdzTznzDNMeGDPvyv6+5cVNYE3oLVvu3JYLuNE1CaQmJZkryiYv3pwgcR
7SifucOtMJkTIWi9qIxurhIUjyJLGnRsJCVjO0sosCE+rcKGjP1AeCw/ZzqN+A2evZw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796019127;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Received:Received:
MIME-Version:From:Date:X-Gm-Features:Message-ID:Subject:To:
Content-Type;
bh=I38uxHkR99ia/JwiaYZmPQSH05TsFYd7MmCYe2cN7XI=;
b=xdIh9+nT4AhEdwvkdLAiEo4zG+iTVBvzsYGrAx19O+Bp8dmHTLhxyTYDwQBYnxAzP23g
knfHp8r0JkNQ3J4KWoMtlNlfcnRk+mMsPCpAyNJNSRglkgqW5g6TdDpfXT0NKIpjxhzPz
dwKiLOZ1V9IIyWY8tJu23IKvm5+kfOM8BedGDfejDuLbg8JbJTcklcA1ghwNbtsYeuOJ0
MYnjV+PmoIcwEKGvVUWmzwVP7SSmxI+m9EtnluI1xNULknv19sx07aJxT//zzJG7WxCm1
6GUkwUXnZ4bryYwv+mtrlfy6JK4gVKsZMnWOPZxEmffvlS0izhE4H6EXFLFS1K5datA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=none header.from=kanamei.com;
spf=pass smtp.mailfrom=kanamei.com;
dkim=pass header.d=kanamei.com header.i=@kanamei.com header.a=rsa-sha256 header.s=google header.b=r1hXZT6p;
arc=pass header.oldest-pass=0 smtp.remote-ip=74.125.82.173
X-Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00483606A31C
for <git@vger.kernel.org>; Mon, 30 Nov 2026 06:12:06 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 00483606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kanamei.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kanamei.com
X-Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-386c4d2e2ccso9045009eec.0
for <git@vger.kernel.org>; Sun, 29 Nov 2026 22:12:06 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1796019126; cv=none;
d=google.com; s=arc-20260327;
b=DDCMhf4KDCKIyucQhScDQgNCmQA8V2yeyLydpq0spQ9CQolIvPjE+h2QYlcxYkGiTM
QkIj45dQEWym5roa60DJXVGHs9KEbopL6rxcp6r5uVcP2H2Ku/FA67RHOfNa4t7vMtra
sMhCTfBzpR10C1+m/1/94Q+gMdVdZlpXv2xn2/34TEudyA//+EGeqI440T1lyoSUxSIA
IyYplRlX9DXlItzzUM2EsWo1wo6tJWuHou394IpsreqhRwAuFtnRsphvnnv9MNmx+aZi
IcV9g4hnthJucVpdoR+eTjDKJLQGkMKUD5Mf9MTaedrdw9hJbvcmlOXkDigWadpL7SB9
Entg==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=to:subject:message-id:date:from:mime-version:dkim-signature;
bh=I38uxHkR99ia/JwiaYZmPQSH05TsFYd7MmCYe2cN7XI=;
fh=AdLvfp5rDLFEqEXBqPWoMWgsTSDK6pd8NZNu0VEubK4=;
b=kDLYYWvJ+uMaV4POHe3aFvpzDikCd/TX2d+JEuWpQKccAX736MYYCTTbFwuIy4xGIi
Ri7HwXvFuw10jiYSih0Kty+Ak0dbohepaUWif5Uiohi+pMQFdr5fBScky4VK3BqTIZwm
M1eMwGee/U/Mc0w+8Mt351puyIA1pUSshy3SCEDLGv7YYT7REYjdWuGX8iXVfX5pMJJQ
2EVfCBpzo/t7Y4PRad7zE2JSADdGfoV54D4mS59Tsk+RjGFOqQX1DAjhe5SbWxMckZ9P
AJTgVCW4u7m1IPGrKRg1Zpk6uHXiRMJ5hFNPhYJV2Ao7fxYf50SWaqeeIG3n1fCvEyoq
DcXw==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=kanamei.com; s=google; t=1796019126; x=1796623926; darn=vger.kernel.org;
h=content-type:to:subject:message-id:date:from:mime-version:from:to
:cc:subject:date:message-id:reply-to:content-type;
bh=I38uxHkR99ia/JwiaYZmPQSH05TsFYd7MmCYe2cN7XI=;
b=r1hXZT6pMYuAhYetCLvtmwVug1yt3+NtO/YKyD6JH7qOMUQlDWA256T9y/K0o+w0uQ
sn1Y1I2Iv8sKoixJ3qsf02+rGljlg4wfRc9wwIXX2xQvhFuJI8Gh5HWsnlg0M2/KjXFf
X/+y38pXF9xsjxLgJJntMK83nmSPX+JynN6k0UaEBDiLOqB/jCf6XEYy/ZT6Vo1sccJu
IVkPIGyhxsfQ0YKVqMCPJgn+feD60EvAeHWMsWFbZiR/tfYWanZ67SZBgC3wrUWeoRY5
iAm5D52U7fYqyXEze7eyQKkBSxCv+wDJt+/f2AAuR3bZB70HnPNF87dS38UIFj3TA0D9
T/1A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796019126; x=1796623926;
h=content-type:to:subject:message-id:date:from:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=I38uxHkR99ia/JwiaYZmPQSH05TsFYd7MmCYe2cN7XI=;
b=KLbhWBh7x9nV5cLM0qXqymZk3XaxApKkjatea7huT44pG1J43VnEZ6l2GEBi5j6wga
Is3Qrn91J+HYWIIqH4hLGo1PTZEyD3hcRKQ2KMZpQSZjPsQMN3Ecqo7mqpQoo2p8vr2o
Gam5Zq+2uz+5IvnzN5pgrxDokuPUYrJczZlm7NySKXXi15HXLNovvbpqcRev+V/eKNzV
bM1lDobLP+NZL3aT7b7AcK8zDFoOup5c/ZUQuyPzihZ1cHEYzzW3uYSTSbMxg2h+rfkd
qN0lP1zHkHVkCBEAs2u8NQQ4eRSZKPwaLjVOyeufDPGb/geNsTuhUC30BGEBWx6oB46j
68Ow==
X-Gm-Message-State: APuU4Z9aJo4QbyOFCW8OC4Z7aNNmv2ARKdxlnYksKbtIiZljCETmYuPQ
heC18gbQhYvVpzNEV+6pqDdwMimxx1BuuLRA7msausJw2gi7BCL7FnBCkWATckToxqH4ujWecAN
Boi/RIPXnErnR+hbdhOgpSSeoBuolKSWsw35JPUf4pKEyr0+NJWVN
X-Gm-Gg: AZFdTZezXZ0gZE0x1pIg8vEh70/vAv+iUEhAx72DOR3uyD3Q9gyLp+ZfmNiysY1A28i
zYM3OTiDP7iqyu39UcYwlBZFTVVUtTVt4BNrmrkZ4QzWxz9/Gdpy5Kz6q5icwFxE5SG/h7+KK8Z
WfZBpfIBRQceU07bnPUXrjVWxkabswWME2VRC1ZLqJn9HgpYBKVetTIbCI8Zmymsa3xmfBixSCw
GJU21ZaYX23kzLAQaz+yGbiBBR762V3o3ekP/Pnw2zIwnOZkLqxcFUbnh8z3Yx0JPEYy0mbTnuq
az0NNrO3RjcxGJ6dFxGUUCLyu8GBgkkfEr8DN/QB9uwvPo7i5o+QnTuwvaO48wma3J+TftOO7FC
6LpgZ3uDKXsh0gMw8SzHG9JmRqIkblPXuUW0=
X-Received: by 2002:a05:693c:415c:20b0:386:f868:8caf with SMTP id
5a478bee46e88-386f8688d11mr7402187eec.8.1796019125778; Sun, 29 Nov 2026
22:12:05 -0800 (PST)
X-Received: from 77377267392 named unknown by gmailapi.google.com with HTTPREST;
Mon, 30 Nov 2026 00:12:04 -0600
X-Received: from 77377267392 named unknown by gmailapi.google.com with HTTPREST;
Mon, 30 Nov 2026 01:06:35 -0500
X-Received: from 77377267392 named unknown by gmailapi.google.com with HTTPREST;
Mon, 30 Nov 2026 00:54:29 -0500
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-Gm-Features: Aa3M54o-TunfN_E2x2jBUqar8WHdGWh1ThNb_s4KXoCvrMX4dbNDcGAOfa08Xak