{"thread":{"id":"42853","subject":"[PATCH] git-clean: remove fifo, devices, socket files","startedAt":"2016-07-15T02:43:19Z","lastAt":"2016-07-16T08:10:00Z","messageCount":6,"participants":["Andrey Vagin","Johannes Sixt","Johannes Schindelin","Andrew Vagin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"291502","messageId":"1468550579-9298-1-git-send-email-avagin@openvz.org","threadId":"42853","inReplyTo":null,"subject":"[PATCH] git-clean: remove fifo, devices, socket files","fromName":"Andrey Vagin","fromEmail":"avagin@openvz.org","sentAt":"2016-07-15T02:42:59Z","receivedAt":"2016-07-15T02:43:19Z","isPatch":true,"sender":{"key":"avagin@openvz.org","avatar":null},"body":"Currently git-clean removes only links and files, but\nthere can be special files like fifo, sockets, devices.\n\nI think git-clean has to remove them too.\n\nSigned-off-by: Andrey Vagin <avagin@openvz.org>\n---\n cache.h | 8 ++++++++\n dir.c   | 4 ++++\n 2 files changed, 12 insertions(+)\n\ndiff --git a/cache.h b/cache.h\nindex f1dc289..a2f1258 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -77,10 +77,18 @@ struct object_id {\n #undef DT_DIR\n #undef DT_REG\n #undef DT_LNK\n+#undef DT_FIFO\n+#undef DT_BLK\n+#undef DT_CHR\n+#undef DT_SOCK\n #define DT_UNKNOWN\t0\n #define DT_DIR\t\t1\n #define DT_REG\t\t2\n #define DT_LNK\t\t3\n+#define DT_FIFO\t\t4\n+#define DT_BLK\t\t5\n+#define DT_CHR\t\t6\n+#define DT_SOCK\t\t7\n #define DTYPE(de)\tDT_UNKNOWN\n #endif\n \ndiff --git a/dir.c b/dir.c\nindex 6172b34..930dd99 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1470,8 +1470,12 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,\n \t\tstrbuf_addch(path, '/');\n \t\treturn treat_directory(dir, untracked, path->buf, path->len,\n \t\t\t\t       baselen, exclude, simplify);\n+\tcase DT_BLK:\n+\tcase DT_CHR:\n+\tcase DT_FIFO:\n \tcase DT_REG:\n \tcase DT_LNK:\n+\tcase DT_SOCK:\n \t\treturn exclude ? path_excluded : path_untracked;\n \t}\n }\n-- \n2.5.5\n\n"},{"id":"291504","messageId":"ab717fc4-fd07-53d1-1a88-ceba6155889c@kdbg.org","threadId":"42853","inReplyTo":"1468550579-9298-1-git-send-email-avagin@openvz.org","subject":"Re: [PATCH] git-clean: remove fifo, devices, socket files","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2016-07-15T05:56:20Z","receivedAt":"2016-07-15T05:56:32Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 15.07.2016 um 04:42 schrieb Andrey Vagin:\n> Currently git-clean removes only links and files, but\n> there can be special files like fifo, sockets, devices.\n>\n> I think git-clean has to remove them too.\n\nI think that is not necessary. If you do\n\n   mkfifo fifo && sudo mknod zero c 1 5\n\nthen 'git status' will not report them and 'git add' will not add them \nto a repository.\n\nSimilarly, if you happen to have a special file under a name in your \nworking tree where the repository has regular files, then 'git status' \nwill report the names as modified, and 'git reset --hard' will replace \nthe special files by the files recorded in the repository.\n\nIOW: These special files are invisible for Git unless it already knows \nthe names. The latter case is outside 'git clean's domain, and the \nformer case really means that special files in the working tree are left \nat the user's discretion.\n\n-- Hannes\n\n"},{"id":"291508","messageId":"CANaxB-y6XW7-ps1G2CB=N9CiD0VnSLhSer2nsf+2R4pm5TyswA@mail.gmail.com","threadId":"42853","inReplyTo":"ab717fc4-fd07-53d1-1a88-ceba6155889c@kdbg.org","subject":"Re: [PATCH] git-clean: remove fifo, devices, socket files","fromName":"Andrey Vagin","fromEmail":"avagin@openvz.org","sentAt":"2016-07-15T07:46:37Z","receivedAt":"2016-07-15T07:47:21Z","isPatch":true,"sender":{"key":"avagin@openvz.org","avatar":null},"body":"On Thu, Jul 14, 2016 at 10:56 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n> Am 15.07.2016 um 04:42 schrieb Andrey Vagin:\n>>\n>> Currently git-clean removes only links and files, but\n>> there can be special files like fifo, sockets, devices.\n>>\n>> I think git-clean has to remove them too.\n>\n>\n> I think that is not necessary. If you do\n>\n>   mkfifo fifo && sudo mknod zero c 1 5\n>\n> then 'git status' will not report them and 'git add' will not add them to a\n> repository.\n>\n> Similarly, if you happen to have a special file under a name in your working\n> tree where the repository has regular files, then 'git status' will report\n> the names as modified, and 'git reset --hard' will replace the special files\n> by the files recorded in the repository.\n>\n> IOW: These special files are invisible for Git unless it already knows the\n> names. The latter case is outside 'git clean's domain, and the former case\n> really means that special files in the working tree are left at the user's\n> discretion.\n\nI understand your points, but I don't see any reasons to ignore these files.\n\nWhat will be wrong if 'git status' will reports these files?\nWhat will be wrong if 'git add' will returns an error instead of\nskipping them silently?\n\nHow it works now:\n[avagin@laptop tmp]$ git add README\n[avagin@laptop tmp]$ git add fifo && echo ok\nok\n[avagin@laptop tmp]$ git commit -a -m \"Add fifo file\"\n[master b04da32] Add fifo file\n 1 file changed, 1 insertion(+)\n\nHow it works with this patch:\n\n[avagin@laptop tmp]$ ../git/bin-wrappers/git add fifo && echo ok\nerror: fifo: can only add regular files, symbolic links or git-directories\nfatal: adding files failed\n\nI like more when 'git add' reports an error when it can't add a file.\n\nThe git-clean man page says that it removes untracked files from the\nworking tree. It doesn't specifies that there are only links and\nregular files.\n\nI won't insist on my point, it may be wrong. But I like when a\nbehavior is predictable. I didn't expect that 'git status' doesn't\nshow special files and 'git clean' doesn't remove them. I asked my\ncolleagues and the current behavior was not obvious for them too.\n\nThanks,\nAndrew\n\n>\n> -- Hannes\n>\n"},{"id":"291527","messageId":"alpine.DEB.2.20.1607151246190.6426@virtualbox","threadId":"42853","inReplyTo":"CANaxB-y6XW7-ps1G2CB=N9CiD0VnSLhSer2nsf+2R4pm5TyswA@mail.gmail.com","subject":"Re: [PATCH] git-clean: remove fifo, devices, socket files","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-07-15T10:48:49Z","receivedAt":"2016-07-15T10:49:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Andrey,\n\nOn Fri, 15 Jul 2016, Andrey Vagin wrote:\n\n> What will be wrong if 'git status' will reports these [fifo/socket] files?\n\n`git status` is intended to give you an idea what to commit next. And...\n\n> What will be wrong if 'git add' will returns an error instead of\n> skipping them silently?\n\n... we *cannot* commit fifos or sockets. There is simply no representation\nin Git's data model for them.\n\nHaving said that, I would welcome a patch that makes `git add` complain\nabout arguments that could not be added (and are not directories).\n\nAs to the patch in question, for the above-mentioned reasons, I think we\nwant to keep the existing behavior instead.\n\nCiao,\nJohannes\n"},{"id":"291563","messageId":"3a6cb604-daa0-6d34-3342-0671a0b23032@kdbg.org","threadId":"42853","inReplyTo":"CANaxB-y6XW7-ps1G2CB=N9CiD0VnSLhSer2nsf+2R4pm5TyswA@mail.gmail.com","subject":"Re: [PATCH] git-clean: remove fifo, devices, socket files","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2016-07-15T20:33:42Z","receivedAt":"2016-07-15T20:33:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 15.07.2016 um 09:46 schrieb Andrey Vagin:\n> On Thu, Jul 14, 2016 at 10:56 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n>> IOW: These special files are invisible for Git unless it already knows the\n>> names. The latter case is outside 'git clean's domain, and the former case\n>> really means that special files in the working tree are left at the user's\n>> discretion.\n>\n> I understand your points, but I don't see any reasons to ignore these files.\n>\n> What will be wrong if 'git status' will reports these files?\n> What will be wrong if 'git add' will returns an error instead of\n> skipping them silently?\n\nI can buy that 'git add' reports an error for special files. (And I \nconcur with Dscho that the behavior should otherwise remain unchanged.) \nBut this is not what the commit message sells even if the patch changes \nthe behavior of 'git add', too (I haven't tested the patch).\n\n-- Hannes\n\n"},{"id":"291592","messageId":"20160715213628.GA19021@outlook.office365.com","threadId":"42853","inReplyTo":"3a6cb604-daa0-6d34-3342-0671a0b23032@kdbg.org","subject":"Re: [PATCH] git-clean: remove fifo, devices, socket files","fromName":"Andrew Vagin","fromEmail":"avagin@virtuozzo.com","sentAt":"2016-07-15T21:36:29Z","receivedAt":"2016-07-16T08:10:00Z","isPatch":true,"sender":{"key":"avagin@virtuozzo.com","avatar":null},"body":"On Fri, Jul 15, 2016 at 10:33:42PM +0200, Johannes Sixt wrote:\n> Am 15.07.2016 um 09:46 schrieb Andrey Vagin:\n> > On Thu, Jul 14, 2016 at 10:56 PM, Johannes Sixt <j6t@kdbg.org> wrote:\n> > > IOW: These special files are invisible for Git unless it already knows the\n> > > names. The latter case is outside 'git clean's domain, and the former case\n> > > really means that special files in the working tree are left at the user's\n> > > discretion.\n> > \n> > I understand your points, but I don't see any reasons to ignore these files.\n> > \n> > What will be wrong if 'git status' will reports these files?\n> > What will be wrong if 'git add' will returns an error instead of\n> > skipping them silently?\n> \n> I can buy that 'git add' reports an error for special files. (And I concur\n> with Dscho that the behavior should otherwise remain unchanged.) But this is\n> not what the commit message sells even if the patch changes the behavior of\n> 'git add', too (I haven't tested the patch).\n\nOk. Thank you for the feedback.\n\n> \n> -- Hannes\n> \n"}]}