Skip to contentSkip to conversation

Some strange behavior of git

DISCUSSION Olga Pshenichnikova 4 participants 6 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hello,
we use git in our project.
What can be cause for further confusing behavior?

    git@ip5server:~$ git status
    On branch master
    Untracked files:
      (use "git add <file>..." to include in what will be committed)

app/addons/arliteks/

nothing added to commit but untracked files present (use "git add"
to track)

    git@ip5server:~$ git clean -dn
    Would remove app/addons/arliteks/
    Would remove design/
    Would remove js/
    Would remove var/langs/en/

Why I don't see all 4 directories in first command?

#1 lore raw

On February 24, 2016 5:43 PM, Olga Pshenichnikova wrote

Quoted 11 lines

What can be cause for further confusing behavior?

     git@ip5server:~$ git status
     On branch master
     Untracked files:
       (use "git add <file>..." to include in what will be committed)

app/addons/arliteks/

nothing added to commit but untracked files present (use "git add"
to track)

Quoted 7 lines
     git@ip5server:~$ git clean -dn
     Would remove app/addons/arliteks/
     Would remove design/
     Would remove js/
     Would remove var/langs/en/

Why I don't see all 4 directories in first command?

What do your .gitignore files contain in this project?

Cheers,
Randall
-- Brief whoami: NonStop&UNIX developer since approximately UNIX(421664400)/NonStop(211288444200000000) -- In my real life, I talk too much.

#2 lore raw
In reply to Olga Pshenichnikova
Quoted 13 lines · Olga Pshenichnikova

Hello,
we use git in our project.
What can be cause for further confusing behavior?

    git@ip5server:~$ git status
    On branch master
    Untracked files:
      (use "git add <file>..." to include in what will be committed)

app/addons/arliteks/

nothing added to commit but untracked files present (use "git add" to
track)

Quoted 7 lines
    git@ip5server:~$ git clean -dn
    Would remove app/addons/arliteks/
    Would remove design/
    Would remove js/
    Would remove var/langs/en/

Why I don't see all 4 directories in first command?

Look at the effects of the .gitignore file

https://git-scm.com/docs/gitignore

Quoted 4 lines

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

#3 lore raw
In reply to Olga Pshenichnikova
Quoted 13 lines · Olga Pshenichnikova

Hello,
we use git in our project.
What can be cause for further confusing behavior?

    git@ip5server:~$ git status
    On branch master
    Untracked files:
      (use "git add <file>..." to include in what will be committed)

app/addons/arliteks/

nothing added to commit but untracked files present (use "git add" to
track)

Quoted 7 lines
    git@ip5server:~$ git clean -dn
    Would remove app/addons/arliteks/
    Would remove design/
    Would remove js/
    Would remove var/langs/en/

Why I don't see all 4 directories in first command?

Are the design/, js/ and var/langs/en/ directories empty? Git doesn't track empty directories, so they won't show up in git status, but with git clean -d you specify that Git should also remove untracked directories, which is why you see them here.

Quoted 4 lines

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

--
Thomas

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

[Please keep everyone cc'd in the conversation, especially the mailing list. I added it back for now.
Also please don't top post on the list]

Quoted 6 lines · Olga Pshenichnikova

No, it isn't empty, but I found the problem.
Problem was that I handled subdirectories structure in exclude file:

design/dir1
design/dir2

Quoted 6 lines

But

design/dir3 wasn't ignored and wasn't controlled.

So, my problem take place when some sub directory both isn't ignored AND isn't controlled even if it isn't empty.

I think that's a bug, I think this directory should only be removed if -x is given. I haven't come up with a patch yet, but here's a test demonstrating the failure.

t/t7300-clean.sh +9 -0
index 86ceb38..0961007 100755
@@ -653,4 +653,13 @@ test_expect_success 'git clean -d respects pathspecs (pathspec is prefix of dir)
 	test_path_is_dir foobar
 '
 
+test_expect_failure 'git clean -d does not clean ignored files in subdir' '
+	mkdir -p sub/dir &&
+	>sub/dir/file &&
+	test_when_finished rm .gitignore &&
+	echo sub/dir/ >.gitignore &&
+	git clean -df sub &&
+	test_path_is_file sub/dir/file
+'
+
 test_done
Quoted 1 line

Thank you for response!

#6 lore raw

Thanx )

Quoted 42 lines · Thomas Gummerer

[Please keep everyone cc'd in the conversation, especially the mailing list. I added it back for now.
Also please don't top post on the list]

Quoted 6 lines · Olga Pshenichnikova

No, it isn't empty, but I found the problem.
Problem was that I handled subdirectories structure in exclude file:

design/dir1
design/dir2

Quoted 6 lines

But

design/dir3 wasn't ignored and wasn't controlled.

So, my problem take place when some sub directory both isn't ignored AND isn't controlled even if it isn't empty.

I think that's a bug, I think this directory should only be removed if -x is given. I haven't come up with a patch yet, but here's a test demonstrating the failure.

t/t7300-clean.sh +9 -0
index 86ceb38..0961007 100755
@@ -653,4 +653,13 @@ test_expect_success 'git clean -d respects pathspecs (pathspec is prefix of dir)
  	test_path_is_dir foobar
  '
 
+test_expect_failure 'git clean -d does not clean ignored files in subdir' '
+	mkdir -p sub/dir &&
+	>sub/dir/file &&
+	test_when_finished rm .gitignore &&
+	echo sub/dir/ >.gitignore &&
+	git clean -df sub &&
+	test_path_is_file sub/dir/file
+'
+
  test_done
Quoted 3 lines

Thank you for response!