Merge branch 'qn/blame-show-email'
authorJunio C Hamano <gitster@pobox.com>
Wed, 24 Jun 2015 19:21:41 +0000 (12:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Jun 2015 19:21:41 +0000 (12:21 -0700)
"git blame" learned blame.showEmail configuration variable.

* qn/blame-show-email:
blame: add blame.showEmail configuration

1  2 
builtin/blame.c
diff --combined builtin/blame.c
index b3e948e757e97947211f598488339cd4f03c43eb,b361b57396f4742e39bfc56e87b9b8d523fb2da7..a22ac174078742cc8991c0ee563980d239731e9b
@@@ -26,9 -26,8 +26,9 @@@
  #include "userdiff.h"
  #include "line-range.h"
  #include "line-log.h"
 +#include "dir.h"
  
 -static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] file");
 +static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>");
  
  static const char *blame_opt_usage[] = {
        blame_usage,
@@@ -2152,6 -2151,16 +2152,6 @@@ static void sanity_check_refcnt(struct 
        }
  }
  
 -/*
 - * Used for the command line parsing; check if the path exists
 - * in the working tree.
 - */
 -static int has_string_in_work_tree(const char *path)
 -{
 -      struct stat st;
 -      return !lstat(path, &st);
 -}
 -
  static unsigned parse_score(const char *arg)
  {
        char *end;
@@@ -2176,6 -2185,14 +2176,14 @@@ static int git_blame_config(const char 
                blank_boundary = git_config_bool(var, value);
                return 0;
        }
+       if (!strcmp(var, "blame.showemail")) {
+               int *output_option = cb;
+               if (git_config_bool(var, value))
+                       *output_option |= OUTPUT_SHOW_EMAIL;
+               else
+                       *output_option &= ~OUTPUT_SHOW_EMAIL;
+               return 0;
+       }
        if (!strcmp(var, "blame.date")) {
                if (!value)
                        return config_error_nonbool(var);
@@@ -2339,7 -2356,6 +2347,7 @@@ static struct commit *fake_working_tree
                if (strbuf_read(&buf, 0, 0) < 0)
                        die_errno("failed to read from stdin");
        }
 +      convert_to_git(path, buf.buf, buf.len, &buf, 0);
        origin->file.ptr = buf.buf;
        origin->file.size = buf.len;
        pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_sha1);
@@@ -2520,7 -2536,7 +2528,7 @@@ int cmd_blame(int argc, const char **ar
        unsigned int range_i;
        long anchor;
  
-       git_config(git_blame_config, NULL);
+       git_config(git_blame_config, &output_option);
        init_revisions(&revs, NULL);
        revs.date_mode = blame_date_mode;
        DIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);
@@@ -2647,14 -2663,14 +2655,14 @@@ parse_done
                if (argc < 2)
                        usage_with_options(blame_opt_usage, options);
                path = add_prefix(prefix, argv[argc - 1]);
 -              if (argc == 3 && !has_string_in_work_tree(path)) { /* (2b) */
 +              if (argc == 3 && !file_exists(path)) { /* (2b) */
                        path = add_prefix(prefix, argv[1]);
                        argv[1] = argv[2];
                }
                argv[argc - 1] = "--";
  
                setup_work_tree();
 -              if (!has_string_in_work_tree(path))
 +              if (!file_exists(path))
                        die_errno("cannot stat path '%s'", path);
        }