summaryrefslogtreecommitdiff
path: root/t/t4013/diff.diff_--raw_--abbrev=4_initial
diff options
context:
space:
mode:
authorJack Bates <bk874k@nottheoilrig.com>2016-12-06 16:56:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-12-08 22:40:30 (GMT)
commit43d1948b7b84abc744227259dd1a3e8dfbb60358 (patch)
tree2d81914e42820709d25156e6d8e817252bdecc92 /t/t4013/diff.diff_--raw_--abbrev=4_initial
parentaeddbfdfa48443c034a9b28b10dfddf2f71b907f (diff)
downloadgit-43d1948b7b84abc744227259dd1a3e8dfbb60358.zip
git-43d1948b7b84abc744227259dd1a3e8dfbb60358.tar.gz
git-43d1948b7b84abc744227259dd1a3e8dfbb60358.tar.bz2
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>
Diffstat (limited to 't/t4013/diff.diff_--raw_--abbrev=4_initial')
-rw-r--r--t/t4013/diff.diff_--raw_--abbrev=4_initial6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t4013/diff.diff_--raw_--abbrev=4_initial b/t/t4013/diff.diff_--raw_--abbrev=4_initial
new file mode 100644
index 0000000..c3641db
--- /dev/null
+++ b/t/t4013/diff.diff_--raw_--abbrev=4_initial
@@ -0,0 +1,6 @@
+$ git diff --raw --abbrev=4 initial
+:100644 100644 35d2... 9929... M dir/sub
+:100644 100644 01e7... 10a8... M file0
+:000000 100644 0000... b1e6... A file1
+:100644 000000 01e7... 0000... D file2
+$