Re: Bug report: Folder and files are deleted by git stash -u

2015-02-05 Thread Junio C Hamano
Junio C Hamano  writes:

> Tobias Preuss  writes:
>
>> I noticed some bizarre behaviour when using: git stash -u.
>> It deletes folders which contain files configured to be ignored.
>
> The files you mark as ignored are expendable and this is not limited
> to "stash".
> ...
> Here is what should happen when you go to 'master':
>
> $ git checkout master
> Switched to branch 'master'
> $ /bin/ls -AF
> a  .git/  .gitignore
>
> That is, a/file.c that is safely stored in 'side' branch is removed,
> a/file.o that is expendable is deleted, and the empty directory 'a'
> now can be replaced with the regular file 'a' the 'master' branch
> wants to have.

Addendum 1.

If *.o files are not treated expendable, you would be forced to
"make clean" every time you switch between these two branches,
which is unacceptable.

Addendum 2.

There was an old wishlist item to introduce another class of
paths (in addition to the "tracked", "untracked" and "ignored")
that are "ignored-but-precious".  Then "*.o" would still be
expendable while a directory that must become a regular file
with "ignored-but-precious" files in it would prevent switching
from branch 'side' to 'master' in the illustration in the
previous message in order to keep that "ignored-but-precious"
file.

But nobody needed such a feature badly enough to step up and
implement it.

cf. http://article.gmane.org/gmane.comp.version-control.git/185746


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bug report: Folder and files are deleted by git stash -u

2015-02-05 Thread Junio C Hamano
Tobias Preuss  writes:

> I noticed some bizarre behaviour when using: git stash -u.
> It deletes folders which contain files configured to be ignored.

The files you mark as ignored are expendable and this is not limited
to "stash".

$ git init
Initialized empty Git repository in /var/tmp/x/ignore/.git/
$ echo \*.o >.gitignore
$ git add .gitignore
$ git commit -m void
[master (root-commit) 457b70e] void
 1 file changed, 1 insertion(+)
 create mode 100644 .gitignore
$ echo a regular file >a
$ git add a
$ git commit -m "a regular file"
[master df839f0] a regular file
 1 file changed, 1 insertion(+)
 create mode 100644 a

We have two regular files, .gitignore and a, on 'master' branch.

$ git checkout -b side HEAD^
Switched to a new branch 'side'
$ mkdir a
$ >a/file.c
$ >a/file.o
$ git add .
$ git commit -m 'a/file.c'
[side 3199d63] a/file.c
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a/file.c

We have two regular files, .gitignore and a/file.c, on 'side' branch,
which is checked out.  The object files that would be created by
compiling source files are set to be ignored by .gitignore rule.

Here is what should happen when you go to 'master':

$ git checkout master
Switched to branch 'master'
$ /bin/ls -AF
a  .git/  .gitignore

That is, a/file.c that is safely stored in 'side' branch is removed,
a/file.o that is expendable is deleted, and the empty directory 'a'
now can be replaced with the regular file 'a' the 'master' branch
wants to have.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Bug report: Folder and files are deleted by git stash -u

2015-02-05 Thread Tobias Preuss
Hello.

I noticed some bizarre behaviour when using: git stash -u.
It deletes folders which contain files configured to be ignored. I
actually lost files by this which I could not restore.

Here is how you can reproduce the case.

1. Create a project folder to act as the root of the repository. `cd`
into the directory
2. Create a folder `tracked-folder` with a file `tracked-file` in it.
Add some content to the file.
3. Create a folder `untracked-folder` with a file `untracked-file` in
it. Add some content to the file.
4. Create a file `to-be-stashed`, add some content to the file.
5. Create a `.gitignore` file with the following content: `untracked-file`.
6. Initialize the Git repository: `git init .`
7. Add all files to be tracked: `git add . & git commit`
8. List the current content of the repository: `tree`. It should show
the following:

├── to-be-stashed
├── tracked-folder
│   └── tracked-file
└── untracked-folder
└── untracked-file

9. Run `git stash -u` and inspect the folder again:

.
└── tracked-folder
└── tracked-file

10. Run `git stash pop` and inspect the folder once again:

.
├── to-be-stashed
└── tracked-folder
└── tracked-file

There you are - you just lost the whole folder.

Can you please confirm or deny if this is a bug? Thank you.
Best regards, Tobias
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html