git/t/t4013
Jack Bates 43d1948b7b diff: handle --no-abbrev in no-index case
There are two different places where the --no-abbrev option is parsed,
and two different places where SHA-1s are abbreviated. We normally parse
--no-abbrev with setup_revisions(), but in the no-index case, "git diff"
calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
--no-abbrev until now. (It did handle --abbrev, however.) We normally
abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666 ("diff:
handle sha1 abbreviations outside of repository, 2016-10-20) recently
introduced a special case when you run "git diff" outside of a
repository.

setup_revisions() does also call diff_opt_parse(), but not for --abbrev
or --no-abbrev, which it handles itself. setup_revisions() sets
rev_info->abbrev, and later copies that to diff_options->abbrev. It
handles --no-abbrev by setting abbrev to zero. (This change doesn't
touch that.)

Setting abbrev to zero was broken in the outside-of-a-repository special
case, which until now resulted in a truly zero-length SHA-1, rather than
taking zero to mean do not abbreviate. The only way to trigger this bug,
however, was by running "git diff --raw" without either the --abbrev or
--no-abbrev options, because 1) without --raw it doesn't respect abbrev
(which is bizarre, but has been that way forever), 2) we silently clamp
--abbrev=0 to MINIMUM_ABBREV, and 3) --no-abbrev wasn't handled until
now.

The outside-of-a-repository case is one of three no-index cases. The
other two are when one of the files you're comparing is outside of the
repository you're in, and the --no-index option.

Signed-off-by: Jack Bates <jack@nottheoilrig.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-12-08 14:40:30 -08:00
..
diff.config_format.subjectprefix_DIFFERENT_PREFIX format-patch: Add format.subjectprefix config option 2007-07-02 21:05:45 -07:00
diff.diff-tree_--cc_--patch-with-stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--cc_--patch-with-stat_--summary_side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--cc_--patch-with-stat_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--cc_--stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--cc_--stat_--summary_side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--cc_--stat_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--cc_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.diff-tree_--patch-with-raw_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--patch-with-stat_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty=oneline_--patch-with-raw_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty=oneline_--patch-with-stat_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty=oneline_--root_--patch-with-raw_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty=oneline_--root_--patch-with-stat_initial diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--pretty=oneline_--root_-p_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty=oneline_--root_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty=oneline_-p_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty=oneline_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_--patch-with-raw_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_--patch-with-stat_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_--patch-with-stat_side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--pretty_--root_--patch-with-raw_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_--root_--patch-with-stat_initial diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--pretty_--root_--stat_--summary_initial diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--pretty_--root_--stat_initial diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--pretty_--root_--summary_-r_initial t4013: note improvements brought by the new output code. 2006-06-29 12:07:27 -07:00
diff.diff-tree_--pretty_--root_--summary_initial Turn on recursive with --summary 2006-10-05 15:10:40 -07:00
diff.diff-tree_--pretty_--root_-p_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_--root_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_--stat_--summary_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_--stat_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_--summary_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_-p_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_-p_side t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--pretty_side t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--root_--abbrev_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--root_--patch-with-raw_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--root_--patch-with-stat_initial diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_--root_-p_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--root_-r_--abbrev=4_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--root_-r_--abbrev_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--root_-r_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_--root_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_-c_--abbrev_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.diff-tree_-c_--stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_-c_--stat_--summary_side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_-c_--stat_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff-tree_-c_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.diff-tree_-p_-m_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.diff-tree_-p_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_-p_master t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_-r_--abbrev=4_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_-r_--abbrev_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_-r_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff-tree_master t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.diff_--abbrev_initial..side t4013: add "diff" UI program tests. 2006-07-01 22:02:17 -07:00
diff.diff_--cached diff: support --cached on unborn branches 2011-02-07 15:04:30 -08:00
diff.diff_--cached_--_file0 diff: support --cached on unborn branches 2011-02-07 15:04:30 -08:00
diff.diff_--dirstat-by-file_initial_rearrange --dirstat-by-file: Make it faster and more correct 2011-04-11 10:12:24 -07:00
diff.diff_--dirstat_initial_rearrange Teach --dirstat not to completely ignore rearranged lines within a file 2011-04-11 11:16:15 -07:00
diff.diff_--dirstat_master~1_master~2 Test diff --dirstat functionality 2009-02-20 00:02:48 -08:00
diff.diff_--line-prefix=abc_master_master^_side graph: add support for --line-prefix on all graph-aware output 2016-08-31 18:07:09 -07:00
diff.diff_--line-prefix_--cached_--_file0 graph: add support for --line-prefix on all graph-aware output 2016-08-31 18:07:09 -07:00
diff.diff_--name-status_dir2_dir "git diff": do not ignore index without --no-index 2008-05-24 00:16:39 -07:00
diff.diff_--no-index_--name-status_--_dir2_dir diff: accept -- when using --no-index 2009-01-06 23:18:20 -08:00
diff.diff_--no-index_--name-status_dir2_dir "git diff": do not ignore index without --no-index 2008-05-24 00:16:39 -07:00
diff.diff_--no-index_--raw_--abbrev=4_dir2_dir diff: handle --no-abbrev in no-index case 2016-12-08 14:40:30 -08:00
diff.diff_--no-index_--raw_--no-abbrev_dir2_dir diff: handle --no-abbrev in no-index case 2016-12-08 14:40:30 -08:00
diff.diff_--no-index_--raw_dir2_dir diff: handle --no-abbrev in no-index case 2016-12-08 14:40:30 -08:00
diff.diff_--no-index_dir_dir3 Skip timestamp differences for diff --no-index 2009-02-18 10:55:33 -08:00
diff.diff_--patch-with-raw_-r_initial..side t4013: add "diff" UI program tests. 2006-07-01 22:02:17 -07:00
diff.diff_--patch-with-raw_initial..side t4013: add "diff" UI program tests. 2006-07-01 22:02:17 -07:00
diff.diff_--patch-with-stat_-r_initial..side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff_--patch-with-stat_initial..side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff_--raw_--abbrev=4_initial diff: handle --no-abbrev in no-index case 2016-12-08 14:40:30 -08:00
diff.diff_--raw_--no-abbrev_initial diff: handle --no-abbrev in no-index case 2016-12-08 14:40:30 -08:00
diff.diff_--raw_initial diff: handle --no-abbrev in no-index case 2016-12-08 14:40:30 -08:00
diff.diff_--stat_initial..side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff_-r_--stat_initial..side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.diff_-r_initial..side t4013: add "diff" UI program tests. 2006-07-01 22:02:17 -07:00
diff.diff_initial..side t4013: add "diff" UI program tests. 2006-07-01 22:02:17 -07:00
diff.diff_master_master^_side "git diff <tree>{3,}": do not reverse order of arguments 2008-10-12 12:36:19 -07:00
diff.format-patch_--attach_--stdout_--suffix=.diff_initial..side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--attach_--stdout_initial..master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--attach_--stdout_initial..master^ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--attach_--stdout_initial..side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--inline_--stdout_--numbered-files_initial..master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--inline_--stdout_--subject-prefix=TESTCASE_initial..master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--inline_--stdout_initial..master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--inline_--stdout_initial..master^ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--inline_--stdout_initial..master^^ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--inline_--stdout_initial..side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--stdout_--cover-letter_-n_initial..master^ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--stdout_--no-numbered_initial..master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--stdout_--numbered_initial..master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--stdout_initial..master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--stdout_initial..master^ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.format-patch_--stdout_initial..side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.log_--decorate=full_--all log: decorate HEAD with branch name under --decorate=full, too 2015-05-13 10:25:18 -07:00
diff.log_--decorate_--all log: decorate HEAD with branch name 2015-03-10 15:17:48 -07:00
diff.log_--patch-with-stat_--summary_master_--_dir_ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.log_--patch-with-stat_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.log_--patch-with-stat_master_--_dir_ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.log_--root_--cc_--patch-with-stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.log_--root_--patch-with-stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.log_--root_--patch-with-stat_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.log_--root_-c_--patch-with-stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.log_--root_-p_master log: do not print ellipses with --abbrev-commit 2009-02-13 17:18:22 -08:00
diff.log_--root_master log: do not print ellipses with --abbrev-commit 2009-02-13 17:18:22 -08:00
diff.log_-GF_-p_--pickaxe-all_master diff/log -G<pattern>: tests 2010-08-31 14:30:29 -07:00
diff.log_-GF_-p_master diff/log -G<pattern>: tests 2010-08-31 14:30:29 -07:00
diff.log_-GF_master diff/log -G<pattern>: tests 2010-08-31 14:30:29 -07:00
diff.log_-m_-p_--first-parent_master t4013: add tests for log -p -m --first-parent 2010-03-09 01:11:18 -08:00
diff.log_-m_-p_master t4013: add tests for log -p -m --first-parent 2010-03-09 01:11:18 -08:00
diff.log_-p_--first-parent_master t4013: add tests for log -p -m --first-parent 2010-03-09 01:11:18 -08:00
diff.log_-p_master log: do not print ellipses with --abbrev-commit 2009-02-13 17:18:22 -08:00
diff.log_-S_F_master diff: parse separate options like -S foo 2010-08-06 09:14:22 -07:00
diff.log_-SF_-p_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.log_-SF_master Clean up "git log" format with DIFF_FORMAT_NO_OUTPUT 2007-10-15 20:24:27 -04:00
diff.log_-SF_master_--max-count=0 log: fix --max-count when used together with -S or -G 2011-03-09 14:28:24 -08:00
diff.log_-SF_master_--max-count=1 log: fix --max-count when used together with -S or -G 2011-03-09 14:28:24 -08:00
diff.log_-SF_master_--max-count=2 log: fix --max-count when used together with -S or -G 2011-03-09 14:28:24 -08:00
diff.log_master log: do not print ellipses with --abbrev-commit 2009-02-13 17:18:22 -08:00
diff.rev-list_--children_HEAD Test rev-list --parents/--children 2009-02-20 00:02:48 -08:00
diff.rev-list_--parents_HEAD Test rev-list --parents/--children 2009-02-20 00:02:48 -08:00
diff.show_--first-parent_master show --first-parent/-m: do not default to --cc 2010-03-09 01:11:19 -08:00
diff.show_--patch-with-raw_side t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.show_--patch-with-stat_--summary_side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.show_--patch-with-stat_side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.show_--root_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.show_--stat_--summary_side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.show_--stat_side diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.show_-c_master show -c: show patch text 2010-03-09 01:11:18 -08:00
diff.show_-m_master show --first-parent/-m: do not default to --cc 2010-03-09 01:11:19 -08:00
diff.show_initial t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.show_master log: do not print ellipses with --abbrev-commit 2009-02-13 17:18:22 -08:00
diff.show_side t4013: add tests for diff/log family output options. 2006-06-26 14:36:40 -07:00
diff.whatchanged_--patch-with-stat_--summary_master_--_dir_ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.whatchanged_--patch-with-stat_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.whatchanged_--patch-with-stat_master_--_dir_ diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.whatchanged_--root_--cc_--patch-with-stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.whatchanged_--root_--patch-with-stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.whatchanged_--root_--patch-with-stat_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.whatchanged_--root_-c_--patch-with-stat_--summary_master diff --stat: use less columns for change counts 2012-04-30 14:17:26 -07:00
diff.whatchanged_--root_-p_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.whatchanged_--root_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.whatchanged_-p_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.whatchanged_-SF_-p_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.whatchanged_-SF_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00
diff.whatchanged_master t4013 diff format tests update 2006-07-13 21:40:43 -07:00