git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Reid Price <reid.price@gmail.com>
To: git@vger.kernel.org
Subject: Apparent bug in 'git stash push <subdir>' loses untracked files
Date: Wed, 13 Dec 2017 09:32:09 -0800	[thread overview]
Message-ID: <CA+HNv10i7AvWXjrQjxxy1LNJTmhr7LE4TwxhHUYBiWtmJCOf_A@mail.gmail.com> (raw)

When running 'git stash push <subdir>' if there are both tracked and
untracked files in this subdirectory, the tracked files are stashed
but the untracked files are discarded.

I can reproduce this on my system (OSX, git 2.14.1) by running the
below script as

    bash -x ./stashbug.sh &> output.txt

I could not find this indicated anywhere as an existing issue by
performing generic searches, apologies if this is known.

  -Reid

Contents of stashbug.sh
------------------------
    #!/bin/sh

    uname -a
    git --version
    mkdir -p stashbug
    cd stashbug
    git init
    mkdir dir
    touch dir/tracked
    git add dir/tracked
    git commit -m 'initial'
    tree; git status
    mkdir dir/untracked_dir
    touch dir/untracked_dir/casualty1
    touch dir/casualty2
    echo 'contents' > dir/tracked
    tree; git status
    git stash push dir/
    git stash show -v
    tree; git status
    git stash pop
    tree; git status
------------------------

Resulting output.txt
---------------------
    + uname -a
    Darwin Reids-MacBook-Pro.local 15.6.0 Darwin Kernel Version
15.6.0: Tue Apr 11 16:00:51 PDT 2017;
root:xnu-3248.60.11.5.3~1/RELEASE_X86_64 x86_64
    + git --version
    git version 2.14.1
    + mkdir -p stashbug
    + cd stashbug
    + git init
    Initialized empty Git repository in /Users/reid/git/stashbug/.git/
    + mkdir dir
    + touch dir/tracked
    + git add dir/tracked
    + git commit -m initial
    [master (root-commit) 895197e] initial
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 dir/tracked
    + tree
    .
    └── dir
        └── tracked

    1 directory, 1 file
    + git status
    On branch master
    nothing to commit, working tree clean
    + mkdir dir/untracked_dir
    + touch dir/untracked_dir/casualty1
    + touch dir/casualty2
    + echo contents
    + tree
    .
    └── dir
        ├── casualty2
        ├── tracked
        └── untracked_dir
            └── casualty1

    2 directories, 3 files
    + git status
    On branch master
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   dir/tracked

    Untracked files:
      (use "git add <file>..." to include in what will be committed)

        dir/casualty2
        dir/untracked_dir/

    no changes added to commit (use "git add" and/or "git commit -a")
    + git stash push dir/
    Saved working directory and index state WIP on master: 895197e initial
    + git stash show -v
    diff --git a/dir/tracked b/dir/tracked
    index e69de29..12f00e9 100644
    --- a/dir/tracked
    +++ b/dir/tracked
    @@ -0,0 +1 @@
    +contents
    + tree
    .
    └── dir
        └── tracked

    1 directory, 1 file
    + git status
    On branch master
    nothing to commit, working tree clean
    + git stash pop
    On branch master
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   dir/tracked

    no changes added to commit (use "git add" and/or "git commit -a")
    Dropped refs/stash@{0} (93ceee344b947ecd8a27a672e3aedd2b2e1acc99)
    + tree
    .
    └── dir
        └── tracked

    1 directory, 1 file
    + git status
    On branch master
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   dir/tracked

    no changes added to commit (use "git add" and/or "git commit -a")
---------------------

             reply	other threads:[~2017-12-13 17:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 17:32 Reid Price [this message]
2017-12-13 21:20 ` Apparent bug in 'git stash push <subdir>' loses untracked files Igor Djordjevic
2017-12-13 23:14   ` Thomas Gummerer
2017-12-13 23:46     ` Igor Djordjevic
2017-12-13 23:05 ` Thomas Gummerer
2017-12-16 18:33   ` Junio C Hamano
2017-12-17 18:05     ` Thomas Gummerer
2017-12-18 18:24       ` Junio C Hamano
2018-01-05 20:03         ` Thomas Gummerer
2018-01-06  0:24           ` [PATCH v2] stash: don't delete untracked files that match pathspec Thomas Gummerer

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=CA+HNv10i7AvWXjrQjxxy1LNJTmhr7LE4TwxhHUYBiWtmJCOf_A@mail.gmail.com \
    --to=reid.price@gmail.com \
    --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).