Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] why do we overwrite untracked files?

On Tue, Jan 11, 2011 at 06:18, Christian Halstrick
<christian.halstrick@xxxxxxxxx> wrote:
>
> Do you remember why we don't care in DirCacheCheckout that we don't
> overwrite content of untracked files? I am wondering why even in the
> git read-tree man page I don't find anything. Do you know why the
> table in http://www.kernel.org/pub/software/scm/git/docs/git-read-tree.html#_two_tree_merge
> for cases 0-3 doesn't take into account whether the working tree is
> clean? Isn't it a conflict when for a certain path HEAD and index are
> empty but merge contains content A and the working tree contains
> content B? At least we can't update the working tree without loosing
> unsaved content.

Its supposed to be untracked and ignored files.  If the ignored check
is missing, that is a bug.

C Git steps on untracked ignored files when switching branches.  For example:

$ mkdir test; cd test; git init
Initialized empty Git repository in /Users/sop/test/.git/
$ echo a>a ; git add a; git commit -m A
[master (root-commit) 3bab920] A
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 a

$ git checkout -b B
Switched to a new branch 'B'
$ echo step.on.me >step.on.me; git add step.on.me; git commit -m B
[B 3c567f8] B
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 step.on.me

$ git checkout -b A master
Switched to a new branch 'A'
$ echo keep >step.on.me; echo step.on.me >.gitignore
$ git add .gitignore
$ git commit -m A
[A 0736597] A
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore

$ git checkout B
Switched to branch 'B'
$ cat step.on.me
step.on.me
$

-- 
Shawn.


Back to the top