mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
diff: index-line: respect --abbrev in object's name
A handful of Git's commands respect `--abbrev' for customizing length of abbreviation of object names. For diff-family, Git supports 2 different options for 2 different purposes, `--full-index' for showing diff-patch object's name in full, and `--abbrev' to customize the length of object names in diff-raw and diff-tree header lines, without any options to customise the length of object names in diff-patch format. When working with diff-patch format, we only have two options, either full index, or default abbrev length. Although, that behaviour is documented, it doesn't stop users from trying to use `--abbrev' with the hope of customising diff-patch's objects' name's abbreviation. Let's allow the blob object names shown on the "index" line to be abbreviated to arbitrary length given via the "--abbrev" option. To preserve backward compatibility with old script that specify both `--full-index' and `--abbrev', always show full object id if `--full-index' is specified. Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
fc7e73d7ef
commit
3046c7f69a
29
t/t4013/diff.diff-tree_--root_-p_--abbrev=10_initial
Normal file
29
t/t4013/diff.diff-tree_--root_-p_--abbrev=10_initial
Normal file
@@ -0,0 +1,29 @@
|
||||
$ git diff-tree --root -p --abbrev=10 initial
|
||||
444ac553ac7612cc88969031b02b3767fb8a353a
|
||||
diff --git a/dir/sub b/dir/sub
|
||||
new file mode 100644
|
||||
index 0000000000..35d242ba79
|
||||
--- /dev/null
|
||||
+++ b/dir/sub
|
||||
@@ -0,0 +1,2 @@
|
||||
+A
|
||||
+B
|
||||
diff --git a/file0 b/file0
|
||||
new file mode 100644
|
||||
index 0000000000..01e79c32a8
|
||||
--- /dev/null
|
||||
+++ b/file0
|
||||
@@ -0,0 +1,3 @@
|
||||
+1
|
||||
+2
|
||||
+3
|
||||
diff --git a/file2 b/file2
|
||||
new file mode 100644
|
||||
index 0000000000..01e79c32a8
|
||||
--- /dev/null
|
||||
+++ b/file2
|
||||
@@ -0,0 +1,3 @@
|
||||
+1
|
||||
+2
|
||||
+3
|
||||
$
|
||||
@@ -0,0 +1,29 @@
|
||||
$ git diff-tree --root -p --full-index --abbrev=10 initial
|
||||
444ac553ac7612cc88969031b02b3767fb8a353a
|
||||
diff --git a/dir/sub b/dir/sub
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..35d242ba79ae89ac695e26b3d4c27a8e6f028f9e
|
||||
--- /dev/null
|
||||
+++ b/dir/sub
|
||||
@@ -0,0 +1,2 @@
|
||||
+A
|
||||
+B
|
||||
diff --git a/file0 b/file0
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d
|
||||
--- /dev/null
|
||||
+++ b/file0
|
||||
@@ -0,0 +1,3 @@
|
||||
+1
|
||||
+2
|
||||
+3
|
||||
diff --git a/file2 b/file2
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d
|
||||
--- /dev/null
|
||||
+++ b/file2
|
||||
@@ -0,0 +1,3 @@
|
||||
+1
|
||||
+2
|
||||
+3
|
||||
$
|
||||
29
t/t4013/diff.diff-tree_--root_-p_--full-index_initial
Normal file
29
t/t4013/diff.diff-tree_--root_-p_--full-index_initial
Normal file
@@ -0,0 +1,29 @@
|
||||
$ git diff-tree --root -p --full-index initial
|
||||
444ac553ac7612cc88969031b02b3767fb8a353a
|
||||
diff --git a/dir/sub b/dir/sub
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..35d242ba79ae89ac695e26b3d4c27a8e6f028f9e
|
||||
--- /dev/null
|
||||
+++ b/dir/sub
|
||||
@@ -0,0 +1,2 @@
|
||||
+A
|
||||
+B
|
||||
diff --git a/file0 b/file0
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d
|
||||
--- /dev/null
|
||||
+++ b/file0
|
||||
@@ -0,0 +1,3 @@
|
||||
+1
|
||||
+2
|
||||
+3
|
||||
diff --git a/file2 b/file2
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d
|
||||
--- /dev/null
|
||||
+++ b/file2
|
||||
@@ -0,0 +1,3 @@
|
||||
+1
|
||||
+2
|
||||
+3
|
||||
$
|
||||
Reference in New Issue
Block a user