{"thread":{"id":"38879","subject":"[PATCH] clone: Warn if LICENSE or COPYING file lacking and !clone.skiplicensecheck","startedAt":"2015-03-22T00:16:40Z","lastAt":"2015-03-22T09:45:19Z","messageCount":3,"participants":["David A. Wheeler","Johannes Sixt","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"258261","messageId":"E1YZTZI-0002QE-3r@rmm6prod02.runbox.com","threadId":"38879","inReplyTo":null,"subject":"[PATCH] clone: Warn if LICENSE or COPYING file lacking and !clone.skiplicensecheck","fromName":"David A. Wheeler","fromEmail":"dwheeler@dwheeler.com","sentAt":"2015-03-22T00:16:40Z","receivedAt":"2015-03-22T00:16:40Z","isPatch":true,"sender":{"key":"dwheeler@dwheeler.com","avatar":"https://avatars.githubusercontent.com/u/813150?v=4"},"body":"Warn cloners if there is no LICENSE* or COPYING* file that makes\nthe license clear.  This is a useful warning, because if there is\nno license somewhere, then local copyright laws (which forbid many uses)\nand terms of service apply - and the cloner may not be expecting that.\nMany projects accidentally omit a license, so this is common enough to note.\n\nYou can disable this warning by setting \"clone.skiplicensecheck\" to \"true\".\n\nFor more info on the issue, feel free to see:\nhttp://choosealicense.com/no-license/\nhttp://www.wired.com/2013/07/github-licenses/\nhttps://twitter.com/stephenrwalli/status/247597785069789184\n\nSigned-off-by: David A. Wheeler <dwheeler@dwheeler.com>\n---\n builtin/clone.c | 44 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 44 insertions(+)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 9572467..a3e8584 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -50,6 +50,7 @@ static int option_progress = -1;\n static struct string_list option_config;\n static struct string_list option_reference;\n static int option_dissociate;\n+static int skip_license_check;\n \n static int opt_parse_reference(const struct option *opt, const char *arg, int unset)\n {\n@@ -748,6 +749,44 @@ static void dissociate_from_references(void)\n \t\tdie_errno(_(\"cannot unlink temporary alternates file\"));\n }\n \n+static int starts_with_ignore_case(const char *str, const char *prefix)\n+{\n+\tfor (; ; str++, prefix++)\n+\t\tif (!*prefix)\n+\t\t\treturn 1;\n+\t\telse if (tolower(*str) != tolower(*prefix))\n+\t\t\treturn 0;\n+}\n+\n+static int missing_license(void)\n+{\n+\tDIR *dir = opendir(\".\"); /* Examine current directory for license. */\n+\tstruct dirent *e;\n+\tstruct stat st;\n+\tint ret = 0;\n+\n+\tif (!dir)\n+\t\treturn 0; /* Empty directory, no need for license. */\n+\n+\twhile ((e = readdir(dir)) != NULL) {\n+\t\tif (starts_with_ignore_case(e->d_name, \"license\") ||\n+\t\t    starts_with_ignore_case(e->d_name, \"copyright\")) {\n+\t\t\tif (stat(e->d_name, &st) || st.st_size < 2)\n+\t\t\t\tcontinue;\n+\t\t\tret = 0;\n+\t\t\tbreak;\n+\t\t}\n+\t\tif (!strcmp(e->d_name, \".\") || !strcmp(e->d_name, \"..\") ||\n+\t\t    !strcmp(e->d_name, \".git\"))\n+\t\t\tcontinue;\n+\t\tret = 1; /* Non-empty directory */\n+\t}\n+\n+\tclosedir(dir);\n+\treturn ret;\n+}\n+\n+\n int cmd_clone(int argc, const char **argv, const char *prefix)\n {\n \tint is_bundle = 0, is_local;\n@@ -1016,6 +1055,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \tjunk_mode = JUNK_LEAVE_REPO;\n \terr = checkout();\n \n+\tgit_config_get_bool(\"clone.skiplicensecheck\", &skip_license_check);\n+\tif (!option_no_checkout && !skip_license_check &&\n+\t    missing_license())\n+\t\twarning(_(\"Repository has no LICENSE or COPYING file with content.\"));\n+\n \tstrbuf_release(&reflog_msg);\n \tstrbuf_release(&branch_top);\n \tstrbuf_release(&key);\n-- \n2.3.3.221.g33aa87e.dirty\n"},{"id":"258278","messageId":"550E7C05.4060603@kdbg.org","threadId":"38879","inReplyTo":"E1YZTZI-0002QE-3r@rmm6prod02.runbox.com","subject":"Re: [PATCH] clone: Warn if LICENSE or COPYING file lacking and !clone.skiplicensecheck","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2015-03-22T08:23:33Z","receivedAt":"2015-03-22T08:23:33Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 22.03.2015 um 01:16 schrieb David A. Wheeler:\n> Warn cloners if there is no LICENSE* or COPYING* file that makes\n> the license clear.  This is a useful warning, because if there is\n> no license somewhere, then local copyright laws (which forbid many uses)\n> and terms of service apply - and the cloner may not be expecting that.\n> Many projects accidentally omit a license, so this is common enough to note.\n>\n> You can disable this warning by setting \"clone.skiplicensecheck\" to \"true\".\n>\n> For more info on the issue, feel free to see:\n> http://choosealicense.com/no-license/\n> http://www.wired.com/2013/07/github-licenses/\n> https://twitter.com/stephenrwalli/status/247597785069789184\n>\n> Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>\n\nThe opt-out works only when placed in the system-wide or user \nconfiguration. That places a maintenance burden on *ALL* existing \ninstallations that do not want the warning.\n\nIf you really want to hard-code such a policy decision into Git, then \nmake it an opt-in so that members of the license squad can enable it.\n\nI don't need it.\n\n-- Hannes\n"},{"id":"258279","messageId":"CACsJy8DxUjfJ8DZ4g5bspeHARCVs9nwt9fC4wySUy0rtsCL++A@mail.gmail.com","threadId":"38879","inReplyTo":"E1YZTZI-0002QE-3r@rmm6prod02.runbox.com","subject":"Re: [PATCH] clone: Warn if LICENSE or COPYING file lacking and !clone.skiplicensecheck","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-03-22T09:45:19Z","receivedAt":"2015-03-22T09:45:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, Mar 22, 2015 at 7:16 AM, David A. Wheeler <dwheeler@dwheeler.com> wrote:\n> Warn cloners if there is no LICENSE* or COPYING* file that makes\n> the license clear.  This is a useful warning, because if there is\n> no license somewhere, then local copyright laws (which forbid many uses)\n> and terms of service apply - and the cloner may not be expecting that.\n> Many projects accidentally omit a license, so this is common enough to note.\n>\n> You can disable this warning by setting \"clone.skiplicensecheck\" to \"true\".\n\nPerhaps make this a hook and maybe install by default on new clones,\ne.g. templates/hooks--post-checkout.sample?\n-- \nDuy\n"}]}