git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phil Hord <hordp@cisco.com>
To: Phil Hord <phil.hord@gmail.com>, Jay Soffian <jaysoffian@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>, git <git@vger.kernel.org>
Subject: Re: clean bug on ignored subdirectories with no tracked files?
Date: Thu, 01 Dec 2011 18:35:52 -0500	[thread overview]
Message-ID: <4ED80F58.20003@cisco.com> (raw)
In-Reply-To: <CABURp0qv7MB-ZQvvSZQi43nAy1ZaR75-19T2Sd1JBT14Y_dG7w@mail.gmail.com>


On Mon, Nov 21, 2011 at 3:03 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
> On Mon, Nov 21, 2011 at 2:28 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> "clean" without "-x" is meant to preserve untracked but expendable paths
>> (e.g. build products), so if something is removed that is untracked but
>> matches the ignore pattern, then that is a bug to be fixed.  Care to roll
>> a patch to fix it?
> Okay, just confirming it is a bug. I'll add this e-mail to my todo
> list, but I don't have time for a patch anytime soon. 

I think the fix is in dir.c (treat_directory), but I'm not sure how yet.

How's this for starters?

-- >8 --
Subject: [PATCH] clean: Test known breakage of .gitignore and -d

git-clean -d is used to remove untracked directories.  If the
directory still contains .gitignored files it should not be removed.
But git is broken here if neither the ignored files nor the directory
are explicitly ignored.

Document this known breakage with a test for both cases.

Noticed-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Phil Hord <hordp@cisco.com>
---
 t/t7300-clean.sh |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 800b536..e29e383 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -14,6 +14,7 @@ test_expect_success 'setup' '
 	mkdir -p src &&
 	touch src/part1.c Makefile &&
 	echo build >.gitignore &&
+	echo /foo/bar >>.gitignore &&
 	echo \*.o >>.gitignore &&
 	git add . &&
 	git commit -m setup &&
@@ -264,6 +265,20 @@ test_expect_success 'git clean -d src/ examples/' '
 
 '
 
+test_expect_failure 'git clean -d leaves .gitignored files alone' '
+
+	mkdir -p objs foo/bar &&
+	touch objs/foo.o &&
+	touch foo/gone &&
+	touch foo/bar/baz &&
+	git clean -nd &&
+	git clean -d &&
+	test ! -f foo/gone &&
+	test -f foo/bar/baz &&
+	test -f objs/foo.o
+
+'
+
 test_expect_success 'git clean -x' '
 
 	mkdir -p build docs &&
-- 
1.7.8.rc4

      parent reply	other threads:[~2011-12-01 23:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-19  5:38 clean bug on ignored subdirectories with no tracked files? Jay Soffian
2011-11-19 19:23 ` Junio C Hamano
2011-11-21 18:51   ` Jay Soffian
2011-11-21 19:02     ` Junio C Hamano
2011-11-21 19:28       ` Junio C Hamano
2011-11-21 20:03         ` Jay Soffian
     [not found]           ` <CABURp0qv7MB-ZQvvSZQi43nAy1ZaR75-19T2Sd1JBT14Y_dG7w@mail.gmail.com>
2011-12-01 23:35             ` Phil Hord [this message]

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=4ED80F58.20003@cisco.com \
    --to=hordp@cisco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jaysoffian@gmail.com \
    --cc=phil.hord@gmail.com \
    /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).