git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Apparent bug in 'git stash push <subdir>' loses untracked files
@ 2017-12-13 17:32 Reid Price
  2017-12-13 21:20 ` Igor Djordjevic
  2017-12-13 23:05 ` Thomas Gummerer
  0 siblings, 2 replies; 10+ messages in thread
From: Reid Price @ 2017-12-13 17:32 UTC (permalink / raw)
  To: git

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")
---------------------

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-01-06  0:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-13 17:32 Apparent bug in 'git stash push <subdir>' loses untracked files Reid Price
2017-12-13 21:20 ` 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

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).