]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'pb/blame-funcname-range-userdiff'
authorJunio C Hamano <gitster@pobox.com>
Wed, 18 Nov 2020 21:32:53 +0000 (13:32 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Nov 2020 21:32:53 +0000 (13:32 -0800)
"git blame -L :funcname -- path" did not work well for a path for
which a userdiff driver is defined.

* pb/blame-funcname-range-userdiff:
  blame: simplify 'setup_blame_bloom_data' interface
  blame: simplify 'setup_scoreboard' interface
  blame: enable funcname blaming with userdiff driver
  line-log: mention both modes in 'blame' and 'log' short help
  doc: add more pointers to gitattributes(5) for userdiff
  blame-options.txt: also mention 'funcname' in '-L' description
  doc: line-range: improve formatting
  doc: log, gitk: move '-L' description to 'line-range-options.txt'

1  2 
Documentation/diff-options.txt
builtin/log.c

index 2e7a93894c8893f0ded8978391b3098fb1c9b0cf,72b558ce21f42d3fe18bf349df846f56b7abbf95..746b144c76ba15f48b58d77ad88b88379f83529e
@@@ -36,9 -36,9 +36,9 @@@ endif::git-format-patch[
  -U<n>::
  --unified=<n>::
        Generate diffs with <n> lines of context instead of
 -      the usual three. Implies `--patch`.
 +      the usual three.
  ifndef::git-format-patch[]
 -      Implies `-p`.
 +      Implies `--patch`.
  endif::git-format-patch[]
  
  --output=<file>::
@@@ -441,16 -441,12 +441,16 @@@ endif::git-format-patch[
  
  --binary::
        In addition to `--full-index`, output a binary diff that
 -      can be applied with `git-apply`. Implies `--patch`.
 +      can be applied with `git-apply`.
 +ifndef::git-format-patch[]
 +      Implies `--patch`.
 +endif::git-format-patch[]
  
  --abbrev[=<n>]::
        Instead of showing the full 40-byte hexadecimal object
        name in diff-raw format output and diff-tree header
 -      lines, show only a partial prefix.
 +      lines, show the shortest prefix that is at least '<n>'
 +      hexdigits long that uniquely refers the object.
        In diff-patch output format, `--full-index` takes higher
        precedence, i.e. if `--full-index` is specified, full blob
        names will be shown regardless of `--abbrev`.
@@@ -691,11 -687,6 +691,11 @@@ endif::git-format-patch[
  --ignore-blank-lines::
        Ignore changes whose lines are all blank.
  
 +-I<regex>::
 +--ignore-matching-lines=<regex>::
 +      Ignore changes whose all lines match <regex>.  This option may
 +      be specified more than once.
 +
  --inter-hunk-context=<lines>::
        Show the context between diff hunks, up to the specified number
        of lines, thereby fusing hunks that are close to each other.
  
  -W::
  --function-context::
-       Show whole surrounding functions of changes.
+       Show whole function as context lines for each change.
+       The function names are determined in the same way as
+       `git diff` works out patch hunk headers (see 'Defining a
+       custom hunk-header' in linkgit:gitattributes[5]).
  
  ifndef::git-format-patch[]
  ifndef::git-log[]
diff --combined builtin/log.c
index 6619e10abc27e17f41386a3aae1ee611daa09700,c87ce09325f47712d1ef54d021f9f432e09ae0c3..49eb8f6431b198d8942d48c77c1cc96e95fd3a0e
@@@ -183,8 -183,8 +183,8 @@@ static void cmd_log_init_finish(int arg
                                N_("pattern"), N_("do not decorate refs that match <pattern>")),
                OPT_CALLBACK_F(0, "decorate", NULL, NULL, N_("decorate options"),
                               PARSE_OPT_OPTARG, decorate_callback),
-               OPT_CALLBACK('L', NULL, &line_cb, "n,m:file",
-                            N_("Process line range n,m in file, counting from 1"),
+               OPT_CALLBACK('L', NULL, &line_cb, "range:file",
+                            N_("Trace the evolution of line range <start>,<end> or function :<funcname> in <file>"),
                             log_line_range_callback),
                OPT_END()
        };
        if (argc > 1)
                die(_("unrecognized argument: %s"), argv[1]);
  
 +      if (rev->line_level_traverse && rev->prune_data.nr)
 +              die(_("-L<range>:<file> cannot be used with pathspec"));
 +
        memset(&w, 0, sizeof(w));
        userformat_find_requirements(NULL, &w);
  
@@@ -1156,7 -1153,7 +1156,7 @@@ static void get_notes_args(struct strve
        }
  }
  
 -static void make_cover_letter(struct rev_info *rev, int use_stdout,
 +static void make_cover_letter(struct rev_info *rev, int use_separate_file,
                              struct commit *origin,
                              int nr, struct commit **list,
                              const char *branch_name,
  
        committer = git_committer_info(0);
  
 -      if (!use_stdout &&
 +      if (use_separate_file &&
            open_next_file(NULL, rev->numbered_files ? NULL : "cover-letter", rev, quiet))
                die(_("failed to create cover-letter file"));
  
@@@ -1741,7 -1738,7 +1741,7 @@@ int cmd_format_patch(int argc, const ch
                OPT_CALLBACK_F('N', "no-numbered", &numbered, NULL,
                            N_("use [PATCH] even with multiple patches"),
                            PARSE_OPT_NOARG | PARSE_OPT_NONEG, no_numbered_callback),
 -              OPT_BOOL('s', "signoff", &do_signoff, N_("add Signed-off-by:")),
 +              OPT_BOOL('s', "signoff", &do_signoff, N_("add a Signed-off-by trailer")),
                OPT_BOOL(0, "stdout", &use_stdout,
                            N_("print patches to standard out")),
                OPT_BOOL(0, "cover-letter", &cover_letter,
        if (rev.show_notes)
                load_display_notes(&rev.notes_opt);
  
 -      if (!output_directory && !use_stdout)
 -              output_directory = config_output_directory;
 +      if (use_stdout + rev.diffopt.close_file + !!output_directory > 1)
 +              die(_("--stdout, --output, and --output-directory are mutually exclusive"));
  
 -      if (!use_stdout)
 -              output_directory = set_outdir(prefix, output_directory);
 -      else
 +      if (use_stdout) {
                setup_pager();
 -
 -      if (output_directory) {
 +      } else if (rev.diffopt.close_file) {
 +              /*
 +               * The diff code parsed --output; it has already opened the
 +               * file, but but we must instruct it not to close after each
 +               * diff.
 +               */
 +              rev.diffopt.close_file = 0;
 +      } else {
                int saved;
 +
 +              if (!output_directory)
 +                      output_directory = config_output_directory;
 +              output_directory = set_outdir(prefix, output_directory);
 +
                if (rev.diffopt.use_color != GIT_COLOR_ALWAYS)
                        rev.diffopt.use_color = GIT_COLOR_NEVER;
 -              if (use_stdout)
 -                      die(_("standard output, or directory, which one?"));
                /*
                 * We consider <outdir> as 'outside of gitdir', therefore avoid
                 * applying adjust_shared_perm in s-c-l-d.
        if (cover_letter) {
                if (thread)
                        gen_message_id(&rev, "cover");
 -              make_cover_letter(&rev, use_stdout,
 +              make_cover_letter(&rev, !!output_directory,
                                  origin, nr, list, branch_name, quiet);
                print_bases(&bases, rev.diffopt.file);
                print_signature(rev.diffopt.file);
                        gen_message_id(&rev, oid_to_hex(&commit->object.oid));
                }
  
 -              if (!use_stdout &&
 +              if (output_directory &&
                    open_next_file(rev.numbered_files ? NULL : commit, NULL, &rev, quiet))
                        die(_("failed to create output files"));
                shown = log_tree_commit(&rev, commit);
                 * the log; when using one file per patch, we do
                 * not want the extra blank line.
                 */
 -              if (!use_stdout)
 +              if (output_directory)
                        rev.shown_one = 0;
                if (shown) {
                        print_bases(&bases, rev.diffopt.file);
                        else
                                print_signature(rev.diffopt.file);
                }
 -              if (!use_stdout)
 +              if (output_directory)
                        fclose(rev.diffopt.file);
        }
        stop_progress(&progress);