{"thread":{"id":"39761","subject":"[PATCH] log: add log.follow config option","startedAt":"2015-07-01T19:03:59Z","lastAt":"2015-07-03T17:47:15Z","messageCount":6,"participants":["David Turner","Matthieu Moy","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"265352","messageId":"1435777439-5002-1-git-send-email-dturner@twopensource.com","threadId":"39761","inReplyTo":null,"subject":"[PATCH] log: add log.follow config option","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2015-07-01T19:03:59Z","receivedAt":"2015-07-01T19:03:59Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"Many users prefer to always use --follow with logs.  Rather than\naliasing the command, an option might be more convenient for some.\n\nSigned-off-by: David Turner <dturner@twopensource.com>\n---\n\nWhy not just alias log=log --follow?\n\nAt Twitter, we manage git config centrally, but we also allow users to\nadd their own aliases.  We would like to turn log.follow on globally,\nwhile not messing up any aliases users already have for log.\n\nAlso, some users might have different log aliases for different\nrepositories, but want to manage --follow globally.\n\nAnd in the future, we might want to make log --follow the default (it\nis what I usually want), so it would be nice to provide a way for\nusers to turn that off globally from a config option.\n\n builtin/log.c                       |  7 +++++++\n t/t4206-log-follow-harder-copies.sh | 23 +++++++++++++++++++++++\n 2 files changed, 30 insertions(+)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 8781049..11b8d82 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -31,6 +31,7 @@ static const char *default_date_mode = NULL;\n \n static int default_abbrev_commit;\n static int default_show_root = 1;\n+static int default_follow = 0;\n static int decoration_style;\n static int decoration_given;\n static int use_mailmap_config;\n@@ -102,6 +103,8 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n {\n \tif (fmt_pretty)\n \t\tget_commit_format(fmt_pretty, rev);\n+\tif (default_follow)\n+\t\tDIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);\n \trev->verbose_header = 1;\n \tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n \trev->diffopt.stat_width = -1; /* use full terminal width */\n@@ -390,6 +393,10 @@ static int git_log_config(const char *var, const char *value, void *cb)\n \t\tdefault_show_root = git_config_bool(var, value);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"log.follow\")) {\n+\t\tdefault_follow = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \tif (skip_prefix(var, \"color.decorate.\", &slot_name))\n \t\treturn parse_decorate_color_config(var, slot_name, value);\n \tif (!strcmp(var, \"log.mailmap\")) {\ndiff --git a/t/t4206-log-follow-harder-copies.sh b/t/t4206-log-follow-harder-copies.sh\nindex ad29e65..6b2f3b9 100755\n--- a/t/t4206-log-follow-harder-copies.sh\n+++ b/t/t4206-log-follow-harder-copies.sh\n@@ -53,4 +53,27 @@ test_expect_success \\\n     'validate the output.' \\\n     'compare_diff_patch current expected'\n \n+test_expect_success \\\n+    'git config log.follow works like --follow' \\\n+    'test_config log.follow true &&\n+     git log --name-status --pretty=\"format:%s\"  path1 > current'\n+\n+test_expect_success \\\n+    'validate the output.' \\\n+    'compare_diff_patch current expected'\n+\n+test_expect_success \\\n+    'git config log.follow is overridden by --no-follow' \\\n+    'test_config log.follow true &&\n+     git log --no-follow --name-status --pretty=\"format:%s\"  path1 > current'\n+\n+cat >expected <<\\EOF\n+Copy path1 from path0\n+A\tpath1\n+EOF\n+\n+test_expect_success \\\n+    'validate the output.' \\\n+    'compare_diff_patch current expected'\n+\n test_done\n-- \n2.0.5.499.g01f6352.dirty-twtrsrc\n"},{"id":"265372","messageId":"vpq8uazo9y6.fsf@anie.imag.fr","threadId":"39761","inReplyTo":"1435777439-5002-1-git-send-email-dturner@twopensource.com","subject":"Re: [PATCH] log: add log.follow config option","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-07-01T21:16:17Z","receivedAt":"2015-07-01T21:16:17Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"David Turner <dturner@twopensource.com> writes:\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> index 8781049..11b8d82 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -31,6 +31,7 @@ static const char *default_date_mode = NULL;\n>  \n>  static int default_abbrev_commit;\n>  static int default_show_root = 1;\n> +static int default_follow = 0;\n>  static int decoration_style;\n>  static int decoration_given;\n>  static int use_mailmap_config;\n> @@ -102,6 +103,8 @@ static void cmd_log_init_defaults(struct rev_info *rev)\n>  {\n>  \tif (fmt_pretty)\n>  \t\tget_commit_format(fmt_pretty, rev);\n> +\tif (default_follow)\n> +\t\tDIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);\n\nDoesn't it activate --follow all the time, including when the user\nprovides several paths?\n\nIn this case, you get this:\n\n$ git log --follow *.c\nfatal: --follow requires exactly one pathspec\n\nSo activating --follow for all \"git log\" calls would prevent log from\nbeing used with several pathspecs.\n\nOr, do you have a preparation patch that allows --follow with multiple\npathspecs? ;-)\n\nIn any case, you have to test \"git log -- path1 path2\" with the option\nactivated.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"265373","messageId":"xmqqvbe37eyy.fsf@gitster.dls.corp.google.com","threadId":"39761","inReplyTo":"vpq8uazo9y6.fsf@anie.imag.fr","subject":"Re: [PATCH] log: add log.follow config option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-01T21:19:49Z","receivedAt":"2015-07-01T21:19:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> So activating --follow for all \"git log\" calls would prevent log from\n> being used with several pathspecs.\n>\n> Or, do you have a preparation patch that allows --follow with multiple\n> pathspecs? ;-)\n>\n> In any case, you have to test \"git log -- path1 path2\" with the option\n> activated.\n\nOr more commonly, just \"git log\" with no pathspec.\n\nI also think that it is a bad idea to force \"log --follow\" to people\nbefore it is made into a true feature; as it stands, it is merely a\n\"checkbox\" item.  It has too severe limitation to be used seriously\nin real projects, unless your history is completely linear.\n\ncf.\n\n  http://thread.gmane.org/gmane.comp.version-control.git/269357/focus=269433\n"},{"id":"265435","messageId":"1435862617.30946.2.camel@twopensource.com","threadId":"39761","inReplyTo":"xmqqvbe37eyy.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] log: add log.follow config option","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2015-07-02T18:43:37Z","receivedAt":"2015-07-02T18:43:37Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"On Wed, 2015-07-01 at 14:19 -0700, Junio C Hamano wrote:\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n> \n> > So activating --follow for all \"git log\" calls would prevent log from\n> > being used with several pathspecs.\n> >\n> > Or, do you have a preparation patch that allows --follow with multiple\n> > pathspecs? ;-)\n> >\n> > In any case, you have to test \"git log -- path1 path2\" with the option\n> > activated.\n> \n> Or more commonly, just \"git log\" with no pathspec.\n> \n> I also think that it is a bad idea to force \"log --follow\" to people\n> before it is made into a true feature; as it stands, it is merely a\n> \"checkbox\" item.  It has too severe limitation to be used seriously\n> in real projects, unless your history is completely linear.\n> \n> cf.\n> \n>   http://thread.gmane.org/gmane.comp.version-control.git/269357/focus=269433\n\nThanks.\n\nTwitter's history is almost completely linear, so it's useful for us.  \n\nSince it looks like the patch won't be useful outside of our context,\nI'll just rewrite it to check the pathspec count, and not upstream it\nuntil follow becomes more general.\n"},{"id":"265447","messageId":"vpqr3op676u.fsf@anie.imag.fr","threadId":"39761","inReplyTo":"1435862617.30946.2.camel@twopensource.com","subject":"Re: [PATCH] log: add log.follow config option","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-07-03T07:17:45Z","receivedAt":"2015-07-03T07:17:45Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"David Turner <dturner@twopensource.com> writes:\n\n> Twitter's history is almost completely linear, so it's useful for us.  \n>\n> Since it looks like the patch won't be useful outside of our context,\n> I'll just rewrite it to check the pathspec count, and not upstream it\n> until follow becomes more general.\n\nAs long as it's an opt-in and that the documentation states the\nlimitations clearly enough, I think it makes sense to me to have this\nupstream.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"265469","messageId":"xmqqy4ix3zh8.fsf@gitster.dls.corp.google.com","threadId":"39761","inReplyTo":"vpqr3op676u.fsf@anie.imag.fr","subject":"Re: [PATCH] log: add log.follow config option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-07-03T17:47:15Z","receivedAt":"2015-07-03T17:47:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> David Turner <dturner@twopensource.com> writes:\n>\n>> Twitter's history is almost completely linear, so it's useful for us.  \n>>\n>> Since it looks like the patch won't be useful outside of our context,\n>> I'll just rewrite it to check the pathspec count, and not upstream it\n>> until follow becomes more general.\n>\n> As long as it's an opt-in and that the documentation states the\n> limitations clearly enough, I think it makes sense to me to have this\n> upstream.\n\nPerhaps.  But at least \"log -- 1 2\" and \"log --\" should not be broken\nfor those that set the configuration.\n\nUnless you are counting these as also \"limitations\", that is.\n"}]}