{"thread":{"id":"38090","subject":"[PATCH] fetch: add a config option to always use the depth argument","startedAt":"2014-12-01T19:07:03Z","lastAt":"2014-12-01T20:58:16Z","messageCount":3,"participants":["Stefan Beller","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"252801","messageId":"1417460823-17295-1-git-send-email-sbeller@google.com","threadId":"38090","inReplyTo":null,"subject":"[PATCH] fetch: add a config option to always use the depth argument","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2014-12-01T19:07:03Z","receivedAt":"2014-12-01T19:07:03Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"When having a repository, which deals with large amounts of data, i.e.\ngraphics, music, films, you may want to keep the git directory at\nthe smallest size possible.\n\nThe depth option helped us in achieving this goal by removing the sizable\nhistory and just keep recent history around. In the case of having large\namounts of data around, you probably want to use the depth option at any\nfetch you do, so it would be convenient to have an option for this.\n\nChange-Id: I45a569239639f20e24fbae32fb2046bc478c5f07\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n Documentation/config.txt        | 6 ++++++\n Documentation/fetch-options.txt | 2 ++\n builtin/fetch.c                 | 5 +++++\n 3 files changed, 13 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 9220725..418e21f 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1106,6 +1106,12 @@ fetch.prune::\n \tIf true, fetch will automatically behave as if the `--prune`\n \toption was given on the command line.  See also `remote.<name>.prune`.\n \n+fetch.depth::\n+\tIf set, fetch will automatically behave as if the `--depth`\n+\toption was given on the command line.  This allows users to keep\n+\tthe git directory at low space requirements, and thus comes in handy\n+\tfor users with large binary files in the repository.\n+\n format.attach::\n \tEnable multipart/mixed attachments as the default for\n \t'format-patch'.  The value can also be a double quoted string\ndiff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt\nindex b09a783..81131d0 100644\n--- a/Documentation/fetch-options.txt\n+++ b/Documentation/fetch-options.txt\n@@ -12,6 +12,8 @@\n \t`git clone` with `--depth=<depth>` option (see linkgit:git-clone[1])\n \tto the specified number of commits from the tip of each remote\n \tbranch history. Tags for the deepened commits are not fetched.\n+\tYou can configure git to always use the depth option, see\n+\t`fetch.depth` in linkgit:git-config[1]\n \n --unshallow::\n \tIf the source repository is complete, convert a shallow\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 7b84d35..30fa15b 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -68,6 +68,11 @@ static int git_fetch_config(const char *k, const char *v, void *cb)\n \t\tfetch_prune_config = git_config_bool(k, v);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"fetch.depth\")) {\n+\t\tif (git_config_string(&depth, k, v))\n+\t\t\treturn -1;\n+\t\treturn 0;\n+\t}\n \treturn git_default_config(k, v, cb);\n }\n \n-- \n2.1.2\n"},{"id":"252807","messageId":"xmqqzjb7nlyx.fsf@gitster.dls.corp.google.com","threadId":"38090","inReplyTo":"1417460823-17295-1-git-send-email-sbeller@google.com","subject":"Re: [PATCH] fetch: add a config option to always use the depth argument","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-12-01T20:39:34Z","receivedAt":"2014-12-01T20:39:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> When having a repository, which deals with large amounts of data, i.e.\n> graphics, music, films, you may want to keep the git directory at\n> the smallest size possible.\n>\n> The depth option helped us in achieving this goal by removing the sizable\n> history and just keep recent history around. In the case of having large\n> amounts of data around, you probably want to use the depth option at any\n> fetch you do, so it would be convenient to have an option for this.\n>\n> Change-Id: I45a569239639f20e24fbae32fb2046bc478c5f07\n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n>  Documentation/config.txt        | 6 ++++++\n>  Documentation/fetch-options.txt | 2 ++\n>  builtin/fetch.c                 | 5 +++++\n>  3 files changed, 13 insertions(+)\n>\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 9220725..418e21f 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -1106,6 +1106,12 @@ fetch.prune::\n>  \tIf true, fetch will automatically behave as if the `--prune`\n>  \toption was given on the command line.  See also `remote.<name>.prune`.\n>  \n> +fetch.depth::\n> +\tIf set, fetch will automatically behave as if the `--depth`\n> +\toption was given on the command line.  This allows users to keep\n> +\tthe git directory at low space requirements, and thus comes in handy\n> +\tfor users with large binary files in the repository.\n> +\n\nHmm, is this something a user would typically want repository-wide?\nI am wondering if \"remote.$nick.fetchDepth\" or something scoped to\nremote is more appropriate.\n\n>  format.attach::\n>  \tEnable multipart/mixed attachments as the default for\n>  \t'format-patch'.  The value can also be a double quoted string\n> diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt\n> index b09a783..81131d0 100644\n> --- a/Documentation/fetch-options.txt\n> +++ b/Documentation/fetch-options.txt\n> @@ -12,6 +12,8 @@\n>  \t`git clone` with `--depth=<depth>` option (see linkgit:git-clone[1])\n>  \tto the specified number of commits from the tip of each remote\n>  \tbranch history. Tags for the deepened commits are not fetched.\n> +\tYou can configure git to always use the depth option, see\n> +\t`fetch.depth` in linkgit:git-config[1]\n>  \n>  --unshallow::\n>  \tIf the source repository is complete, convert a shallow\n> diff --git a/builtin/fetch.c b/builtin/fetch.c\n> index 7b84d35..30fa15b 100644\n> --- a/builtin/fetch.c\n> +++ b/builtin/fetch.c\n> @@ -68,6 +68,11 @@ static int git_fetch_config(const char *k, const char *v, void *cb)\n>  \t\tfetch_prune_config = git_config_bool(k, v);\n>  \t\treturn 0;\n>  \t}\n> +\tif (!strcmp(k, \"fetch.depth\")) {\n> +\t\tif (git_config_string(&depth, k, v))\n> +\t\t\treturn -1;\n> +\t\treturn 0;\n> +\t}\n>  \treturn git_default_config(k, v, cb);\n>  }\n"},{"id":"252809","messageId":"xmqqvblvnl3r.fsf@gitster.dls.corp.google.com","threadId":"38090","inReplyTo":"xmqqzjb7nlyx.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] fetch: add a config option to always use the depth argument","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-12-01T20:58:16Z","receivedAt":"2014-12-01T20:58:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> +fetch.depth::\n>> +\tIf set, fetch will automatically behave as if the `--depth`\n>> +\toption was given on the command line.  This allows users to keep\n>> +\tthe git directory at low space requirements, and thus comes in handy\n>> +\tfor users with large binary files in the repository.\n>> +\n>\n> Hmm, is this something a user would typically want repository-wide?\n> I am wondering if \"remote.$nick.fetchDepth\" or something scoped to\n> remote is more appropriate.\n\nRegardless of what configuration variable is used, I think setting\ndepth directly from the config will mean the user cannot defeat a\nconfigured value by passing --unshallow because of this code\nsequence in builtin/fetch.c; am I mistaken?\n\n\t...\n\tgit_config(git_fetch_config, NULL);\n\targc = parse_options(argc, argv, prefix,\n\t\t\t     builtin_fetch_options, builtin_fetch_usage, 0);\n\tif (unshallow) {\n\t\tif (depth)\n\t\t\tdie(_(\"--depth and --unshallow cannot be used together\"));\n\t...\n\nI think depth variable should be left alone.\n\nThe right solution may be to leave the above \"unshallow and depth\nare incompatible\" check done only for the command line options as\nthe original code, and much later in the code path after you figure\nout which remote we are talking to, only when neither --depth nor\n--unshallow is given, consult the configuration system to see if\nthere is a default, perhaps in prepare_transport().  That approach\nwill let you later support \"remote.$nick.fetchDepth\", even if you\nstart with a repository-wide \"fetch.depth\" option, I would think.\n"}]}