git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Sam Partington <sam@whiteoctober.co.uk>
To: git@vger.kernel.org
Subject: Bug when stashing previously-ignored file plus associated .gitignore change
Date: Fri, 11 Aug 2017 16:55:38 +0100	[thread overview]
Message-ID: <CAPuLQgNq_7Kdeio-59cbDjZ5mWC1VRd_1_KK33Gbka9KJ13vfQ@mail.gmail.com> (raw)

Hi there,

I'm running git 2.7.4 on Ubuntu 16.04.  I've found a couple of
problems when "un-ignoring" files in tandem with git stash.

Here's how to reproduce:

Say you have a project using git, with a .gitignore file which
contains the following line:

bin/*

You can then see the problems by doing this:

$ touch bin/mynewfile # this file will be ignored at this point

and then updating .gitignore to look like this (adding that second line):

bin/*
!bin/mynewfile

So far, so good; the new file is no longer ignored.

But now, try stashing the changes and including untracked files in the stash:

$ git stash save -u

Here's the first problem, bin/mynewfile is still there:

$ ls bin/mynewfile
bin/mynewfile

But you'd expect it to not be there and be in the stash, I think.
This is what would normally happen with the untracked-files option for
git stash.

This leads to the second problem - you can't now pop the stash:

$ git stash pop
bin/mynewfile already exists, no checkout
Could not restore untracked files from stash

If you want to apply the stash, you have to remove the file:

$ rm bin/mynewfile
$ git stash pop # this works, and re-creates bin/mynewfile

This is quite an unusual edge case, but I have hit it two or three
times now and so thought it worth reporting, but I'll understand if
it's deemed not worth fixing!

Do let me know if you need any more information from me here.

Thanks
Sam

PS Sorry for the lack of formatting - I'm sending this as plain text
as my original HTML emails was rejected as possible spam by your
mailserver.

Sam Partington
Senior Developer

www.whiteoctober.co.uk
Office: +44 (0)1865 920 707

This email message and any attachments are confidential and solely for
the use of the intended recipient. If you are not the intended
recipient, you have received this message in error. Please notify us
immediately and delete the message from your computer. You should not
distribute, copy or disclose its contents to any other person. Any
views or opinions expressed in this email are solely those of the
author and do not necessarily represent those of White October
Limited. White October is a private limited company registered in
England & Wales under registration number 3982889. The company’s
registered office is at 264 Banbury Road, Oxford, OX2 7DY.

             reply	other threads:[~2017-08-11 15:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-11 15:55 Sam Partington [this message]
2017-08-11 17:14 ` [PATCH] stash: clean untracked files before reset Nicolas Morey-Chaisemartin
2017-08-11 22:11   ` Junio C Hamano
2017-08-14  4:47 ` Bug when stashing previously-ignored file plus associated .gitignore change Kevin Daudt
2017-08-14  7:38   ` Sam Partington

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPuLQgNq_7Kdeio-59cbDjZ5mWC1VRd_1_KK33Gbka9KJ13vfQ@mail.gmail.com \
    --to=sam@whiteoctober.co.uk \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).