Merge branch 'jb/diff-no-index-no-abbrev'
"git diff --no-index" did not take "--no-abbrev" option. * jb/diff-no-index-no-abbrev: diff: handle --no-abbrev in no-index case
This commit is contained in:
commit
c89606fa90
6
diff.c
6
diff.c
@ -3106,7 +3106,8 @@ static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
|
|||||||
abbrev = FALLBACK_DEFAULT_ABBREV;
|
abbrev = FALLBACK_DEFAULT_ABBREV;
|
||||||
if (abbrev > GIT_SHA1_HEXSZ)
|
if (abbrev > GIT_SHA1_HEXSZ)
|
||||||
die("BUG: oid abbreviation out of range: %d", abbrev);
|
die("BUG: oid abbreviation out of range: %d", abbrev);
|
||||||
hex[abbrev] = '\0';
|
if (abbrev)
|
||||||
|
hex[abbrev] = '\0';
|
||||||
return hex;
|
return hex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3364,6 +3365,7 @@ void diff_setup(struct diff_options *options)
|
|||||||
|
|
||||||
options->file = stdout;
|
options->file = stdout;
|
||||||
|
|
||||||
|
options->abbrev = DEFAULT_ABBREV;
|
||||||
options->line_termination = '\n';
|
options->line_termination = '\n';
|
||||||
options->break_opt = -1;
|
options->break_opt = -1;
|
||||||
options->rename_limit = -1;
|
options->rename_limit = -1;
|
||||||
@ -4024,6 +4026,8 @@ int diff_opt_parse(struct diff_options *options,
|
|||||||
offending, optarg);
|
offending, optarg);
|
||||||
return argcount;
|
return argcount;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(arg, "--no-abbrev"))
|
||||||
|
options->abbrev = 0;
|
||||||
else if (!strcmp(arg, "--abbrev"))
|
else if (!strcmp(arg, "--abbrev"))
|
||||||
options->abbrev = DEFAULT_ABBREV;
|
options->abbrev = DEFAULT_ABBREV;
|
||||||
else if (skip_prefix(arg, "--abbrev=", &arg)) {
|
else if (skip_prefix(arg, "--abbrev=", &arg)) {
|
||||||
|
@ -311,6 +311,13 @@ diff --line-prefix=abc master master^ side
|
|||||||
diff --dirstat master~1 master~2
|
diff --dirstat master~1 master~2
|
||||||
diff --dirstat initial rearrange
|
diff --dirstat initial rearrange
|
||||||
diff --dirstat-by-file initial rearrange
|
diff --dirstat-by-file initial rearrange
|
||||||
|
# No-index --abbrev and --no-abbrev
|
||||||
|
diff --raw initial
|
||||||
|
diff --raw --abbrev=4 initial
|
||||||
|
diff --raw --no-abbrev initial
|
||||||
|
diff --no-index --raw dir2 dir
|
||||||
|
diff --no-index --raw --abbrev=4 dir2 dir
|
||||||
|
diff --no-index --raw --no-abbrev dir2 dir
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'log -S requires an argument' '
|
test_expect_success 'log -S requires an argument' '
|
||||||
|
3
t/t4013/diff.diff_--no-index_--raw_--abbrev=4_dir2_dir
Normal file
3
t/t4013/diff.diff_--no-index_--raw_--abbrev=4_dir2_dir
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
$ git diff --no-index --raw --abbrev=4 dir2 dir
|
||||||
|
:000000 100644 0000... 0000... A dir/sub
|
||||||
|
$
|
3
t/t4013/diff.diff_--no-index_--raw_--no-abbrev_dir2_dir
Normal file
3
t/t4013/diff.diff_--no-index_--raw_--no-abbrev_dir2_dir
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
$ git diff --no-index --raw --no-abbrev dir2 dir
|
||||||
|
:000000 100644 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 A dir/sub
|
||||||
|
$
|
3
t/t4013/diff.diff_--no-index_--raw_dir2_dir
Normal file
3
t/t4013/diff.diff_--no-index_--raw_dir2_dir
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
$ git diff --no-index --raw dir2 dir
|
||||||
|
:000000 100644 0000000... 0000000... A dir/sub
|
||||||
|
$
|
6
t/t4013/diff.diff_--raw_--abbrev=4_initial
Normal file
6
t/t4013/diff.diff_--raw_--abbrev=4_initial
Normal file
@ -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
|
||||||
|
$
|
6
t/t4013/diff.diff_--raw_--no-abbrev_initial
Normal file
6
t/t4013/diff.diff_--raw_--no-abbrev_initial
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
$ git diff --raw --no-abbrev initial
|
||||||
|
:100644 100644 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e 992913c5aa0a5476d10c49ed0f21fc0c6d1aedf3 M dir/sub
|
||||||
|
:100644 100644 01e79c32a8c99c557f0757da7cb6d65b3414466d 10a8a9f3657f91a156b9f0184ed79a20adef9f7f M file0
|
||||||
|
:000000 100644 0000000000000000000000000000000000000000 b1e67221afe8461efd244b487afca22d46b95eb8 A file1
|
||||||
|
:100644 000000 01e79c32a8c99c557f0757da7cb6d65b3414466d 0000000000000000000000000000000000000000 D file2
|
||||||
|
$
|
6
t/t4013/diff.diff_--raw_initial
Normal file
6
t/t4013/diff.diff_--raw_initial
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
$ git diff --raw initial
|
||||||
|
:100644 100644 35d242b... 992913c... M dir/sub
|
||||||
|
:100644 100644 01e79c3... 10a8a9f... M file0
|
||||||
|
:000000 100644 0000000... b1e6722... A file1
|
||||||
|
:100644 000000 01e79c3... 0000000... D file2
|
||||||
|
$
|
Loading…
x
Reference in New Issue
Block a user