Merge branch 'dd/diff-customize-index-line-abbrev'
The output from the "diff" family of the commands had abbreviated object names of blobs involved in the patch, but its length was not affected by the --abbrev option. Now it is. * dd/diff-customize-index-line-abbrev: diff: index-line: respect --abbrev in object's name t4013: improve diff-post-processor logic
This commit is contained in:
commit
096c948dab
@ -446,10 +446,11 @@ endif::git-format-patch[]
|
|||||||
--abbrev[=<n>]::
|
--abbrev[=<n>]::
|
||||||
Instead of showing the full 40-byte hexadecimal object
|
Instead of showing the full 40-byte hexadecimal object
|
||||||
name in diff-raw format output and diff-tree header
|
name in diff-raw format output and diff-tree header
|
||||||
lines, show only a partial prefix. This is
|
lines, show only a partial prefix.
|
||||||
independent of the `--full-index` option above, which controls
|
In diff-patch output format, `--full-index` takes higher
|
||||||
the diff-patch output format. Non default number of
|
precedence, i.e. if `--full-index` is specified, full blob
|
||||||
digits can be specified with `--abbrev=<n>`.
|
names will be shown regardless of `--abbrev`.
|
||||||
|
Non default number of digits can be specified with `--abbrev=<n>`.
|
||||||
|
|
||||||
-B[<n>][/<m>]::
|
-B[<n>][/<m>]::
|
||||||
--break-rewrites[=[<n>][/<m>]]::
|
--break-rewrites[=[<n>][/<m>]]::
|
||||||
|
5
diff.c
5
diff.c
@ -4319,7 +4319,10 @@ static void fill_metainfo(struct strbuf *msg,
|
|||||||
}
|
}
|
||||||
if (one && two && !oideq(&one->oid, &two->oid)) {
|
if (one && two && !oideq(&one->oid, &two->oid)) {
|
||||||
const unsigned hexsz = the_hash_algo->hexsz;
|
const unsigned hexsz = the_hash_algo->hexsz;
|
||||||
int abbrev = o->flags.full_index ? hexsz : DEFAULT_ABBREV;
|
int abbrev = o->abbrev ? o->abbrev : DEFAULT_ABBREV;
|
||||||
|
|
||||||
|
if (o->flags.full_index)
|
||||||
|
abbrev = hexsz;
|
||||||
|
|
||||||
if (o->flags.binary) {
|
if (o->flags.binary) {
|
||||||
mmfile_t mf;
|
mmfile_t mf;
|
||||||
|
@ -130,27 +130,45 @@ test_expect_success setup '
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
process_diffs () {
|
process_diffs () {
|
||||||
_x04="[0-9a-f][0-9a-f][0-9a-f][0-9a-f]" &&
|
perl -e '
|
||||||
_x07="$_x05[0-9a-f][0-9a-f]" &&
|
my $oid_length = length($ARGV[0]);
|
||||||
sed -e "s/$OID_REGEX/$ZERO_OID/g" \
|
my $x40 = "[0-9a-f]{40}";
|
||||||
-e "s/From $_x40 /From $ZERO_OID /" \
|
my $xab = "[0-9a-f]{4,16}";
|
||||||
-e "s/from $_x40)/from $ZERO_OID)/" \
|
my $orx = "[0-9a-f]" x $oid_length;
|
||||||
-e "s/commit $_x40\$/commit $ZERO_OID/" \
|
|
||||||
-e "s/commit $_x40 (/commit $ZERO_OID (/" \
|
sub munge_oid {
|
||||||
-e "s/$_x40 $_x40 $_x40/$ZERO_OID $ZERO_OID $ZERO_OID/" \
|
my ($oid) = @_;
|
||||||
-e "s/$_x40 $_x40 /$ZERO_OID $ZERO_OID /" \
|
my $x;
|
||||||
-e "s/^$_x40 $_x40$/$ZERO_OID $ZERO_OID/" \
|
|
||||||
-e "s/^$_x40 /$ZERO_OID /" \
|
return "" unless length $oid;
|
||||||
-e "s/^$_x40$/$ZERO_OID/" \
|
|
||||||
-e "s/$_x07\.\.$_x07/fffffff..fffffff/g" \
|
if ($oid =~ /^(100644|100755|120000)$/) {
|
||||||
-e "s/$_x07,$_x07\.\.$_x07/fffffff,fffffff..fffffff/g" \
|
return $oid;
|
||||||
-e "s/$_x07 $_x07 $_x07/fffffff fffffff fffffff/g" \
|
}
|
||||||
-e "s/$_x07 $_x07 /fffffff fffffff /g" \
|
|
||||||
-e "s/Merge: $_x07 $_x07/Merge: fffffff fffffff/g" \
|
if ($oid =~ /^0*$/) {
|
||||||
-e "s/$_x07\.\.\./fffffff.../g" \
|
$x = "0";
|
||||||
-e "s/ $_x04\.\.\./ ffff.../g" \
|
} else {
|
||||||
-e "s/ $_x04/ ffff/g" \
|
$x = "f";
|
||||||
"$1"
|
}
|
||||||
|
|
||||||
|
if (length($oid) == 40) {
|
||||||
|
return $x x $oid_length;
|
||||||
|
} else {
|
||||||
|
return $x x length($oid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (<STDIN>) {
|
||||||
|
s/($orx)/munge_oid($1)/ge;
|
||||||
|
s/From ($x40)( |\))/"From " . munge_oid($1) . $2/ge;
|
||||||
|
s/commit ($x40)($| \(from )($x40?)/"commit " . munge_oid($1) . $2 . munge_oid($3)/ge;
|
||||||
|
s/\b($x40)( |\.\.|$)/munge_oid($1) . $2/ge;
|
||||||
|
s/^($x40)($| )/munge_oid($1) . $2/e;
|
||||||
|
s/($xab)(\.\.|,| |\.\.\.|$)/munge_oid($1) . $2/ge;
|
||||||
|
print;
|
||||||
|
}
|
||||||
|
' "$ZERO_OID" <"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
|
V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
|
||||||
@ -221,6 +239,9 @@ diff-tree --root -r --abbrev=4 initial
|
|||||||
:noellipses diff-tree --root -r --abbrev=4 initial
|
:noellipses diff-tree --root -r --abbrev=4 initial
|
||||||
diff-tree -p initial
|
diff-tree -p initial
|
||||||
diff-tree --root -p initial
|
diff-tree --root -p initial
|
||||||
|
diff-tree --root -p --abbrev=10 initial
|
||||||
|
diff-tree --root -p --full-index initial
|
||||||
|
diff-tree --root -p --full-index --abbrev=10 initial
|
||||||
diff-tree --patch-with-stat initial
|
diff-tree --patch-with-stat initial
|
||||||
diff-tree --root --patch-with-stat initial
|
diff-tree --root --patch-with-stat initial
|
||||||
diff-tree --patch-with-raw initial
|
diff-tree --patch-with-raw initial
|
||||||
|
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
|
||||||
|
$
|
Loading…
Reference in New Issue
Block a user