{"thread":{"id":"8002","subject":"[PATCH 2/3] dir.c: Omit non-excluded directories with dir->show_ignored","startedAt":"2007-05-06T18:09:24Z","lastAt":"2007-05-07T02:35:04Z","messageCount":8,"participants":["Michael Spang","Junio C Hamano","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"41229","messageId":"463E19D4.4030400@uwaterloo.ca","threadId":"8002","inReplyTo":"463E1705.2090201@gmail.com","subject":"[PATCH 2/3] dir.c: Omit non-excluded directories with dir->show_ignored","fromName":"Michael Spang","fromEmail":"mspang@uwaterloo.ca","sentAt":"2007-05-06T18:09:24Z","receivedAt":"2007-05-06T18:09:24Z","isPatch":true,"sender":{"key":"mspang@uwaterloo.ca","avatar":null},"body":"This makes \"git-ls-files --others --directory --ignored\" behave\nas documented and consequently also fixes \"git-clean -d -X\".\nPreviously, git-clean would remove non-excluded directories\neven when using the -X option.\n\nSigned-off-by: Michael Spang <mspang@uwaterloo.ca>\n---\n dir.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex d306352..adb3e62 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -448,6 +448,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co\n \n \t\twhile ((de = readdir(fdir)) != NULL) {\n \t\t\tint len;\n+\t\t\tint exclude;\n \n \t\t\tif ((de->d_name[0] == '.') &&\n \t\t\t    (de->d_name[1] == 0 ||\n@@ -461,7 +462,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co\n \t\t\tmemcpy(fullname + baselen, de->d_name, len+1);\n \t\t\tif (simplify_away(fullname, baselen + len, simplify))\n \t\t\t\tcontinue;\n-\t\t\tif (excluded(dir, fullname) != dir->show_ignored) {\n+\t\t\tif ((exclude = excluded(dir, fullname)) != dir->show_ignored) {\n \t\t\t\tif (!dir->show_ignored || DTYPE(de) != DT_DIR) {\n \t\t\t\t\tcontinue;\n \t\t\t\t}\n@@ -484,6 +485,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co\n \t\t\t\tlen++;\n \t\t\t\tswitch (treat_directory(dir, fullname, baselen + len, simplify)) {\n \t\t\t\tcase show_directory:\n+\t\t\t\t\tif (exclude != dir->show_ignored)\n+\t\t\t\t\t\tcontinue;\n \t\t\t\t\tbreak;\n \t\t\t\tcase recurse_into_directory:\n \t\t\t\t\tcontents += read_directory_recursive(dir,\n-- \n1.5.2.rc1.4.g47e1\n"},{"id":"41230","messageId":"463E19DE.8070305@uwaterloo.ca","threadId":"8002","inReplyTo":"463E1705.2090201@gmail.com","subject":"[PATCH 3/3] Fix minor documentation errors","fromName":"Michael Spang","fromEmail":"mspang@uwaterloo.ca","sentAt":"2007-05-06T18:09:34Z","receivedAt":"2007-05-06T18:09:34Z","isPatch":true,"sender":{"key":"mspang@uwaterloo.ca","avatar":null},"body":"- git-ls-files.txt: typo in description of --ignored\n- git-clean.txt: s/forceRequire/requireForce/\n\nSigned-off-by: Michael Spang <mspang@uwaterloo.ca>\n---\n Documentation/git-clean.txt    |    2 +-\n Documentation/git-ls-files.txt |    4 ++--\n 2 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-clean.txt b/Documentation/git-clean.txt\nindex 5aff026..e3252d5 100644\n--- a/Documentation/git-clean.txt\n+++ b/Documentation/git-clean.txt\n@@ -26,7 +26,7 @@ OPTIONS\n \tRemove untracked directories in addition to untracked files.\n \n -f::\n-\tIf the git configuration specifies clean.forceRequire as true,\n+\tIf the git configuration specifies clean.requireForce as true,\n \tgit-clean will refuse to run unless given -f or -n.\n \n -n::\ndiff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt\nindex 79e0b7b..076cebc 100644\n--- a/Documentation/git-ls-files.txt\n+++ b/Documentation/git-ls-files.txt\n@@ -42,8 +42,8 @@ OPTIONS\n \tShow other files in the output\n \n -i|--ignored::\n-\tShow ignored files in the output\n-\tNote the this also reverses any exclude list present.\n+\tShow ignored files in the output.\n+\tNote that this also reverses any exclude list present.\n \n -s|--stage::\n \tShow stage files in the output\n"},{"id":"41231","messageId":"463E19F6.9000906@uwaterloo.ca","threadId":"8002","inReplyTo":"463E1705.2090201@gmail.com","subject":"[PATCH/RFD 4/3] t7300: Tests for git-clean using filenames with spaces/punctuation","fromName":"Michael Spang","fromEmail":"mspang@uwaterloo.ca","sentAt":"2007-05-06T18:09:58Z","receivedAt":"2007-05-06T18:09:58Z","isPatch":true,"sender":{"key":"mspang@uwaterloo.ca","avatar":null},"body":"Signed-off-by: Michael Spang <mspang@uwaterloo.ca>\n---\n\nThis isn't meant for applying, at least until this flaw is fixed.\n\nThese tests are failing because ls-files does escaping and clean does\nnot unescape. Does anyone know of a solution to this?\n\nsed could be used to remove the double quotes and replace escaped characters,\nbut doing many replacements happens in multiple passes and hence does not\nalways work as desired.\n\nIs this even properly solvable without making clean a builtin or\nwriting git-unescape?\n\n\n t/t7300-clean.sh |   23 +++++++++++++++++++++++\n 1 files changed, 23 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7300-clean.sh b/t/t7300-clean.sh\nindex 1fb3850..3792221 100755\n--- a/t/t7300-clean.sh\n+++ b/t/t7300-clean.sh\n@@ -7,6 +7,8 @@ test_description='git-clean basic tests'\n \n . ./test-lib.sh\n \n+TAB=\"\t\"\n+\n test_expect_success \\\n     'setup' \\\n     \"mkdir -p src &&\n@@ -123,6 +125,27 @@ test_expect_success \\\n     test ! -e obj.o &&\n     test ! -e build\"\n \n+test_expect_success \\\n+    'filenames with spaces' \\\n+    'touch abc\\ def &&\n+    touch 123 123\\  &&\n+    git-add 123 &&\n+    git-clean &&\n+    test ! -e abc\\ def &&\n+    test ! -e 123\\  &&\n+    test -e 123'\n+\n+test_expect_success \\\n+    'filenames with escaped characters' \\\n+    'touch \"'\"$TAB\"'\" \" \" \\\\ \\\" \\\\\\\\\\\" \\\\t &&\n+    git-clean &&\n+    test ! -e \"'\"$TAB\"'\" &&\n+    test ! -e \" \" &&\n+    test ! -e \\\\ &&\n+    test ! -e \\\" &&\n+    test ! -e \\\\\\\\\\\" &&\n+    test ! -e \\\\t'\n+\n test_expect_failure \\\n     'clean.requireForce' \\\n     \"mkdir -p build docs &&\n"},{"id":"41235","messageId":"7vr6ptbx5g.fsf@assigned-by-dhcp.cox.net","threadId":"8002","inReplyTo":"463E19F6.9000906@uwaterloo.ca","subject":"Re: [PATCH/RFD 4/3] t7300: Tests for git-clean using filenames with spaces/punctuation","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-06T18:54:35Z","receivedAt":"2007-05-06T18:54:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Spang <mspang@uwaterloo.ca> writes:\n\n> Is this even properly solvable without making clean a builtin or\n> writing git-unescape?\n\nIf you know how to use \"xargs -0\" and are willing to depend on\nthe -0 GNU extension, then the answer is yes.\n\nI do not use git-clean myself, as I do not see what (I think) it\ntries to solve as a problem to begin with, so obviously I do not\ncare too deeply about the command's implementation --- I just\nlet it be there because there seem to be others who want it ---\nbut if I were asked an advice on the right direction to proceed,\nI would probably suggest rewriting it in C.\n"},{"id":"41239","messageId":"463E28FC.9080209@uwaterloo.ca","threadId":"8002","inReplyTo":"7vr6ptbx5g.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH/RFD 4/3] t7300: Tests for git-clean using filenames with spaces/punctuation","fromName":"Michael Spang","fromEmail":"mspang@uwaterloo.ca","sentAt":"2007-05-06T19:14:04Z","receivedAt":"2007-05-06T19:14:04Z","isPatch":true,"sender":{"key":"mspang@uwaterloo.ca","avatar":null},"body":"Junio C Hamano wrote:\n> Michael Spang <mspang@uwaterloo.ca> writes:\n> \n>> Is this even properly solvable without making clean a builtin or\n>> writing git-unescape?\n> \n> If you know how to use \"xargs -0\" and are willing to depend on\n> the -0 GNU extension, then the answer is yes.\n\nRight. But I do not think xargs can call a shell function. git-clean\ndoes not just call git-rm directly. I guess git-clean could call\nitself through xargs, but that might become confusing.\n\n> I do not use git-clean myself, as I do not see what (I think) it\n> tries to solve as a problem to begin with, so obviously I do not\n> care too deeply about the command's implementation --- I just\n> let it be there because there seem to be others who want it ---\n> but if I were asked an advice on the right direction to proceed,\n> I would probably suggest rewriting it in C.\n\nThat seems like the cleanest solution to me as well.\n\nCheers,\nMichael Spang\n"},{"id":"41241","messageId":"alpine.LFD.0.98.0705061239460.25245@woody.linux-foundation.org","threadId":"8002","inReplyTo":"463E19D4.4030400@uwaterloo.ca","subject":"Re: [PATCH 2/3] dir.c: Omit non-excluded directories with dir->show_ignored","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-05-06T19:42:03Z","receivedAt":"2007-05-06T19:42:03Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 6 May 2007, Michael Spang wrote:\n> @@ -461,7 +462,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co\n>  \t\t\tmemcpy(fullname + baselen, de->d_name, len+1);\n>  \t\t\tif (simplify_away(fullname, baselen + len, simplify))\n>  \t\t\t\tcontinue;\n> -\t\t\tif (excluded(dir, fullname) != dir->show_ignored) {\n> +\t\t\tif ((exclude = excluded(dir, fullname)) != dir->show_ignored) {\n\nStyle issue: please write this as\n\n\t\t\texclude = excluded(dir, fullname);\n\t\t\tif (exclude != dir->show_ignored) {\n\ninstead. \n\nYes, both are valid C, and mean the same thing, but one is much more \nreadable than the other.\n\nCombining multiple things inside an if-statement is convenient if:\n\n - the things inside are _really_ trivial.\n\n - it's done as part of macro expansion etc (ie it's not visible as such, \n   and the code is readable in its pre-preprocessor format)\n\nbut it's not good form otherwise.\n\n\t\tLinus\n"},{"id":"41247","messageId":"463E382F.8080708@uwaterloo.ca","threadId":"8002","inReplyTo":"alpine.LFD.0.98.0705061239460.25245@woody.linux-foundation.org","subject":"Re: [PATCH 2/3] dir.c: Omit non-excluded directories with dir->show_ignored","fromName":"Michael Spang","fromEmail":"mspang@uwaterloo.ca","sentAt":"2007-05-06T20:18:55Z","receivedAt":"2007-05-06T20:18:55Z","isPatch":true,"sender":{"key":"mspang@uwaterloo.ca","avatar":null},"body":"Linus Torvalds wrote:\n> \n> On Sun, 6 May 2007, Michael Spang wrote:\n>> @@ -461,7 +462,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co\n>>  \t\t\tmemcpy(fullname + baselen, de->d_name, len+1);\n>>  \t\t\tif (simplify_away(fullname, baselen + len, simplify))\n>>  \t\t\t\tcontinue;\n>> -\t\t\tif (excluded(dir, fullname) != dir->show_ignored) {\n>> +\t\t\tif ((exclude = excluded(dir, fullname)) != dir->show_ignored) {\n> \n> Style issue: please write this as\n> \n> \t\t\texclude = excluded(dir, fullname);\n> \t\t\tif (exclude != dir->show_ignored) {\n> \n> instead. \n\nOkay. Will fixup after waiting a bit for more comments.\n\nThanks,\nMichael Spang\n"},{"id":"41280","messageId":"463E9058.5080907@uwaterloo.ca","threadId":"8002","inReplyTo":"alpine.LFD.0.98.0705061239460.25245@woody.linux-foundation.org","subject":"Re: [PATCH 2/3] dir.c: Omit non-excluded directories with dir->show_ignored","fromName":"Michael Spang","fromEmail":"mspang@uwaterloo.ca","sentAt":"2007-05-07T02:35:04Z","receivedAt":"2007-05-07T02:35:04Z","isPatch":true,"sender":{"key":"mspang@uwaterloo.ca","avatar":null},"body":"This makes \"git-ls-files --others --directory --ignored\" behave\nas documented and consequently also fixes \"git-clean -d -X\".\nPreviously, git-clean would remove non-excluded directories\neven when using the -X option.\n\nSigned-off-by: Michael Spang <mspang@uwaterloo.ca>\n---\n\nThis fixes the style issue noted by Linus.\n\n\n dir.c |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex d306352..11fab7f 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -448,6 +448,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co\n \n \t\twhile ((de = readdir(fdir)) != NULL) {\n \t\t\tint len;\n+\t\t\tint exclude;\n \n \t\t\tif ((de->d_name[0] == '.') &&\n \t\t\t    (de->d_name[1] == 0 ||\n@@ -461,7 +462,9 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co\n \t\t\tmemcpy(fullname + baselen, de->d_name, len+1);\n \t\t\tif (simplify_away(fullname, baselen + len, simplify))\n \t\t\t\tcontinue;\n-\t\t\tif (excluded(dir, fullname) != dir->show_ignored) {\n+\n+\t\t\texclude = excluded(dir, fullname);\n+\t\t\tif (exclude != dir->show_ignored) {\n \t\t\t\tif (!dir->show_ignored || DTYPE(de) != DT_DIR) {\n \t\t\t\t\tcontinue;\n \t\t\t\t}\n@@ -484,6 +487,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co\n \t\t\t\tlen++;\n \t\t\t\tswitch (treat_directory(dir, fullname, baselen + len, simplify)) {\n \t\t\t\tcase show_directory:\n+\t\t\t\t\tif (exclude != dir->show_ignored)\n+\t\t\t\t\t\tcontinue;\n \t\t\t\t\tbreak;\n \t\t\t\tcase recurse_into_directory:\n \t\t\t\t\tcontents += read_directory_recursive(dir,\n"}]}