From cd48dadb8d840637f0f55b1ad0d8f50d892c767d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 31 Aug 2016 16:27:19 -0700 Subject: diff.c: remove output_prefix_length field "diff/log --stat" has a logic that determines the display columns available for the diffstat part of the output and apportions it for pathnames and diffstat graph automatically. 5e71a84a (Add output_prefix_length to diff_options, 2012-04-16) added the output_prefix_length field to diff_options structure to allow this logic to subtract the display columns used for the history graph part from the total "terminal width"; this matters when the "git log --graph -p" option is in use. The field must be set to the number of display columns needed to show the output from the output_prefix() callback, which is error prone. As there is only one user of the field, and the user has the actual value of the prefix string, let's get rid of the field and have the user count the display width itself. Signed-off-by: Junio C Hamano --- diff.h | 1 - 1 file changed, 1 deletion(-) (limited to 'diff.h') diff --git a/diff.h b/diff.h index 125447be0..49e4aaafb 100644 --- a/diff.h +++ b/diff.h @@ -174,7 +174,6 @@ struct diff_options { diff_format_fn_t format_callback; void *format_callback_data; diff_prefix_fn_t output_prefix; - int output_prefix_length; void *output_prefix_data; int diff_path_counter; -- cgit v1.2.1 From 660e113ce11840f4bc4028bff89889e6122fe89a Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Wed, 31 Aug 2016 16:27:20 -0700 Subject: graph: add support for --line-prefix on all graph-aware output Add an extension to git-diff and git-log (and any other graph-aware displayable output) such that "--line-prefix=" will print the additional line-prefix on every line of output. To make this work, we have to fix a few bugs in the graph API that force graph_show_commit_msg to be used only when you have a valid graph. Additionally, we extend the default_diff_output_prefix handler to work even when no graph is enabled. This is somewhat of a hack on top of the graph API, but I think it should be acceptable here. This will be used by a future extension of submodule display which displays the submodule diff as the actual diff between the pre and post commit in the submodule project. Add some tests for both git-log and git-diff to ensure that the prefix is honored correctly. Signed-off-by: Jacob Keller Signed-off-by: Junio C Hamano --- diff.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'diff.h') diff --git a/diff.h b/diff.h index 49e4aaafb..219a28aa0 100644 --- a/diff.h +++ b/diff.h @@ -115,6 +115,8 @@ struct diff_options { const char *pickaxe; const char *single_follow; const char *a_prefix, *b_prefix; + const char *line_prefix; + size_t line_prefix_length; unsigned flags; unsigned touched_flags; -- cgit v1.2.1 From 61cfbc054d8341c3276efbf1380a2be0ee435dba Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Wed, 31 Aug 2016 16:27:21 -0700 Subject: diff: prepare for additional submodule formats A future patch will add a new format for displaying the difference of a submodule. Make it easier by changing how we store the current selected format. Replace the DIFF_OPT flag with an enumeration, as each format will be mutually exclusive. Signed-off-by: Jacob Keller Signed-off-by: Junio C Hamano --- diff.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'diff.h') diff --git a/diff.h b/diff.h index 219a28aa0..14be35d01 100644 --- a/diff.h +++ b/diff.h @@ -83,7 +83,6 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data) #define DIFF_OPT_DIRSTAT_BY_FILE (1 << 20) #define DIFF_OPT_ALLOW_TEXTCONV (1 << 21) #define DIFF_OPT_DIFF_FROM_CONTENTS (1 << 22) -#define DIFF_OPT_SUBMODULE_LOG (1 << 23) #define DIFF_OPT_DIRTY_SUBMODULES (1 << 24) #define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25) #define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26) @@ -110,6 +109,11 @@ enum diff_words_type { DIFF_WORDS_COLOR }; +enum diff_submodule_format { + DIFF_SUBMODULE_SHORT = 0, + DIFF_SUBMODULE_LOG +}; + struct diff_options { const char *orderfile; const char *pickaxe; @@ -157,6 +161,7 @@ struct diff_options { int stat_count; const char *word_regex; enum diff_words_type word_diff; + enum diff_submodule_format submodule_format; /* this is set by diffcore for DIFF_FORMAT_PATCH */ int found_changes; -- cgit v1.2.1 From fd47ae6a5b9cc0cfc56c1f7c43db612d26ca4b75 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Wed, 31 Aug 2016 16:27:25 -0700 Subject: diff: teach diff to display submodule difference with an inline diff Teach git-diff and friends a new format for displaying the difference of a submodule. The new format is an inline diff of the contents of the submodule between the commit range of the update. This allows the user to see the actual code change caused by a submodule update. Add tests for the new format and option. Signed-off-by: Jacob Keller Signed-off-by: Junio C Hamano --- diff.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'diff.h') diff --git a/diff.h b/diff.h index 14be35d01..2d884f1d0 100644 --- a/diff.h +++ b/diff.h @@ -111,7 +111,8 @@ enum diff_words_type { enum diff_submodule_format { DIFF_SUBMODULE_SHORT = 0, - DIFF_SUBMODULE_LOG + DIFF_SUBMODULE_LOG, + DIFF_SUBMODULE_INLINE_DIFF }; struct diff_options { -- cgit v1.2.1