All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] git-clean: remove fifo, devices, socket files
@ 2016-07-15  2:42 Andrey Vagin
  2016-07-15  5:56 ` Johannes Sixt
  0 siblings, 1 reply; 6+ messages in thread
From: Andrey Vagin @ 2016-07-15  2:42 UTC (permalink / raw)
  To: gitster; +Cc: git, Andrey Vagin

Currently git-clean removes only links and files, but
there can be special files like fifo, sockets, devices.

I think git-clean has to remove them too.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
---
 cache.h | 8 ++++++++
 dir.c   | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/cache.h b/cache.h
index f1dc289..a2f1258 100644
--- a/cache.h
+++ b/cache.h
@@ -77,10 +77,18 @@ struct object_id {
 #undef DT_DIR
 #undef DT_REG
 #undef DT_LNK
+#undef DT_FIFO
+#undef DT_BLK
+#undef DT_CHR
+#undef DT_SOCK
 #define DT_UNKNOWN	0
 #define DT_DIR		1
 #define DT_REG		2
 #define DT_LNK		3
+#define DT_FIFO		4
+#define DT_BLK		5
+#define DT_CHR		6
+#define DT_SOCK		7
 #define DTYPE(de)	DT_UNKNOWN
 #endif
 
diff --git a/dir.c b/dir.c
index 6172b34..930dd99 100644
--- a/dir.c
+++ b/dir.c
@@ -1470,8 +1470,12 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
 		strbuf_addch(path, '/');
 		return treat_directory(dir, untracked, path->buf, path->len,
 				       baselen, exclude, simplify);
+	case DT_BLK:
+	case DT_CHR:
+	case DT_FIFO:
 	case DT_REG:
 	case DT_LNK:
+	case DT_SOCK:
 		return exclude ? path_excluded : path_untracked;
 	}
 }
-- 
2.5.5


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

* Re: [PATCH] git-clean: remove fifo, devices, socket files
  2016-07-15  2:42 [PATCH] git-clean: remove fifo, devices, socket files Andrey Vagin
@ 2016-07-15  5:56 ` Johannes Sixt
  2016-07-15  7:46   ` Andrey Vagin
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2016-07-15  5:56 UTC (permalink / raw)
  To: Andrey Vagin; +Cc: gitster, git

Am 15.07.2016 um 04:42 schrieb Andrey Vagin:
> Currently git-clean removes only links and files, but
> there can be special files like fifo, sockets, devices.
>
> I think git-clean has to remove them too.

I think that is not necessary. If you do

   mkfifo fifo && sudo mknod zero c 1 5

then 'git status' will not report them and 'git add' will not add them 
to a repository.

Similarly, if you happen to have a special file under a name in your 
working tree where the repository has regular files, then 'git status' 
will report the names as modified, and 'git reset --hard' will replace 
the special files by the files recorded in the repository.

IOW: These special files are invisible for Git unless it already knows 
the names. The latter case is outside 'git clean's domain, and the 
former case really means that special files in the working tree are left 
at the user's discretion.

-- Hannes


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

* Re: [PATCH] git-clean: remove fifo, devices, socket files
  2016-07-15  5:56 ` Johannes Sixt
@ 2016-07-15  7:46   ` Andrey Vagin
  2016-07-15 10:48     ` Johannes Schindelin
  2016-07-15 20:33     ` Johannes Sixt
  0 siblings, 2 replies; 6+ messages in thread
From: Andrey Vagin @ 2016-07-15  7:46 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Junio C Hamano, git

On Thu, Jul 14, 2016 at 10:56 PM, Johannes Sixt <j6t@kdbg.org> wrote:
> Am 15.07.2016 um 04:42 schrieb Andrey Vagin:
>>
>> Currently git-clean removes only links and files, but
>> there can be special files like fifo, sockets, devices.
>>
>> I think git-clean has to remove them too.
>
>
> I think that is not necessary. If you do
>
>   mkfifo fifo && sudo mknod zero c 1 5
>
> then 'git status' will not report them and 'git add' will not add them to a
> repository.
>
> Similarly, if you happen to have a special file under a name in your working
> tree where the repository has regular files, then 'git status' will report
> the names as modified, and 'git reset --hard' will replace the special files
> by the files recorded in the repository.
>
> IOW: These special files are invisible for Git unless it already knows the
> names. The latter case is outside 'git clean's domain, and the former case
> really means that special files in the working tree are left at the user's
> discretion.

I understand your points, but I don't see any reasons to ignore these files.

What will be wrong if 'git status' will reports these files?
What will be wrong if 'git add' will returns an error instead of
skipping them silently?

How it works now:
[avagin@laptop tmp]$ git add README
[avagin@laptop tmp]$ git add fifo && echo ok
ok
[avagin@laptop tmp]$ git commit -a -m "Add fifo file"
[master b04da32] Add fifo file
 1 file changed, 1 insertion(+)

How it works with this patch:

[avagin@laptop tmp]$ ../git/bin-wrappers/git add fifo && echo ok
error: fifo: can only add regular files, symbolic links or git-directories
fatal: adding files failed

I like more when 'git add' reports an error when it can't add a file.

The git-clean man page says that it removes untracked files from the
working tree. It doesn't specifies that there are only links and
regular files.

I won't insist on my point, it may be wrong. But I like when a
behavior is predictable. I didn't expect that 'git status' doesn't
show special files and 'git clean' doesn't remove them. I asked my
colleagues and the current behavior was not obvious for them too.

Thanks,
Andrew

>
> -- Hannes
>

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

* Re: [PATCH] git-clean: remove fifo, devices, socket files
  2016-07-15  7:46   ` Andrey Vagin
@ 2016-07-15 10:48     ` Johannes Schindelin
  2016-07-15 20:33     ` Johannes Sixt
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2016-07-15 10:48 UTC (permalink / raw)
  To: Andrey Vagin; +Cc: Johannes Sixt, Junio C Hamano, git

Hi Andrey,

On Fri, 15 Jul 2016, Andrey Vagin wrote:

> What will be wrong if 'git status' will reports these [fifo/socket] files?

`git status` is intended to give you an idea what to commit next. And...

> What will be wrong if 'git add' will returns an error instead of
> skipping them silently?

... we *cannot* commit fifos or sockets. There is simply no representation
in Git's data model for them.

Having said that, I would welcome a patch that makes `git add` complain
about arguments that could not be added (and are not directories).

As to the patch in question, for the above-mentioned reasons, I think we
want to keep the existing behavior instead.

Ciao,
Johannes

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

* Re: [PATCH] git-clean: remove fifo, devices, socket files
  2016-07-15  7:46   ` Andrey Vagin
  2016-07-15 10:48     ` Johannes Schindelin
@ 2016-07-15 20:33     ` Johannes Sixt
  2016-07-15 21:36       ` Andrew Vagin
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Sixt @ 2016-07-15 20:33 UTC (permalink / raw)
  To: Andrey Vagin; +Cc: Junio C Hamano, git

Am 15.07.2016 um 09:46 schrieb Andrey Vagin:
> On Thu, Jul 14, 2016 at 10:56 PM, Johannes Sixt <j6t@kdbg.org> wrote:
>> IOW: These special files are invisible for Git unless it already knows the
>> names. The latter case is outside 'git clean's domain, and the former case
>> really means that special files in the working tree are left at the user's
>> discretion.
>
> I understand your points, but I don't see any reasons to ignore these files.
>
> What will be wrong if 'git status' will reports these files?
> What will be wrong if 'git add' will returns an error instead of
> skipping them silently?

I can buy that 'git add' reports an error for special files. (And I 
concur with Dscho that the behavior should otherwise remain unchanged.) 
But this is not what the commit message sells even if the patch changes 
the behavior of 'git add', too (I haven't tested the patch).

-- Hannes


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

* Re: [PATCH] git-clean: remove fifo, devices, socket files
  2016-07-15 20:33     ` Johannes Sixt
@ 2016-07-15 21:36       ` Andrew Vagin
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Vagin @ 2016-07-15 21:36 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Andrey Vagin, Junio C Hamano, git

On Fri, Jul 15, 2016 at 10:33:42PM +0200, Johannes Sixt wrote:
> Am 15.07.2016 um 09:46 schrieb Andrey Vagin:
> > On Thu, Jul 14, 2016 at 10:56 PM, Johannes Sixt <j6t@kdbg.org> wrote:
> > > IOW: These special files are invisible for Git unless it already knows the
> > > names. The latter case is outside 'git clean's domain, and the former case
> > > really means that special files in the working tree are left at the user's
> > > discretion.
> > 
> > I understand your points, but I don't see any reasons to ignore these files.
> > 
> > What will be wrong if 'git status' will reports these files?
> > What will be wrong if 'git add' will returns an error instead of
> > skipping them silently?
> 
> I can buy that 'git add' reports an error for special files. (And I concur
> with Dscho that the behavior should otherwise remain unchanged.) But this is
> not what the commit message sells even if the patch changes the behavior of
> 'git add', too (I haven't tested the patch).

Ok. Thank you for the feedback.

> 
> -- Hannes
> 

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

end of thread, other threads:[~2016-07-16  8:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15  2:42 [PATCH] git-clean: remove fifo, devices, socket files Andrey Vagin
2016-07-15  5:56 ` Johannes Sixt
2016-07-15  7:46   ` Andrey Vagin
2016-07-15 10:48     ` Johannes Schindelin
2016-07-15 20:33     ` Johannes Sixt
2016-07-15 21:36       ` Andrew Vagin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.