From: Marc Strapetz Date: Thu, 15 Mar 2018 08:51:48 GMT Subject: Re: [PATCH v2 1/2] stash push: avoid printing errors Message-ID: In-Reply-To: <20180314214642.22185-1-t.gummerer@gmail.com> On 14.03.2018 22:46, Thomas Gummerer wrote: > Currently 'git stash push -u -- ' prints the following errors > if only matches untracked files: > > fatal: pathspec 'untracked' did not match any files > error: unrecognized input > > This is because we first clean up the untracked files using 'git clean > ', and then use a command chain involving 'git add -u > ' and 'git apply' to clear the changes to files that are in > the index and were stashed. > > As the only includes untracked files that were already > removed by 'git clean', the 'git add' call will barf, and so will 'git > apply', as there are no changes that need to be applied. > > Fix this by making sure to only call this command chain if there are > still files that match after the call to 'git clean'. > > Reported-by: Marc Strapetz > Signed-off-by: Thomas Gummerer > --- > >> Either way I'll try to address this as soon as I can get some >> time to look at it. > > I finally got around to do this. The fix (in the second patch) turns > out to be fairly simple, I just forgot to pass the pathspec along to > one function whene originally introducing the pathspec feature in git > stash push (more explanation in the commit message for the patch > itself). Thanks Marc for reporting the two breakages! Thanks, I confirm that both issues are resolved. There is another issue now which seems to be a regression. When *successfully* stashing an untracked file, local modifications of other files are cleared, too. $ git init $ touch file1 $ git add file1 $ git commit -m "initial import" $ echo "a" > file1 $ touch file2 $ git status --porcelain M file1 ?? file2 $ git stash push -u -- file2 Saved working directory and index state WIP on master: 25352d7 initial import $ git status On branch master nothing to commit, working tree clean Hence, by stashing just "file2" the local modification of "file1" became reset. -Marc