diff options
| author | Junio C Hamano <gitster@pobox.com> | 2020-04-28 15:50:07 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2020-04-28 15:50:08 -0700 |
| commit | 93d1f196a9b84f449ed405fe9c9c96320b6dffb0 (patch) | |
| tree | 7908322dd12923c4261174bcfd3f2dd7c319e7ed | |
| parent | 5a96715eb7451e81b3d981f2b4797a1aa4f1afdd (diff) | |
| parent | 8d1675eb7f7f76af834c72e72c8824410e874fec (diff) | |
| download | git-93d1f196a9b84f449ed405fe9c9c96320b6dffb0.tar.xz | |
Merge branch 'vd/range-diff-with-custom-pretty-format-fix'
"git range-diff" fixes.
* vd/range-diff-with-custom-pretty-format-fix:
range-diff: avoid negative string precision
range-diff: fix a crash in parsing git-log output
| -rw-r--r-- | range-diff.c | 18 | ||||
| -rwxr-xr-x | t/t3206-range-diff.sh | 10 |
2 files changed, 27 insertions, 1 deletions
diff --git a/range-diff.c b/range-diff.c index f745567cf6..40af086281 100644 --- a/range-diff.c +++ b/range-diff.c @@ -63,6 +63,8 @@ static int read_patches(const char *range, struct string_list *list, "--output-indicator-old=<", "--output-indicator-context=#", "--no-abbrev-commit", + "--pretty=medium", + "--notes", NULL); if (other_arg) argv_array_pushv(&cp.args, other_arg->argv); @@ -106,20 +108,34 @@ static int read_patches(const char *range, struct string_list *list, continue; } + if (!util) { + error(_("could not parse first line of `log` output: " + "did not start with 'commit ': '%s'"), + line); + string_list_clear(list, 1); + strbuf_release(&buf); + strbuf_release(&contents); + finish_command(&cp); + return -1; + } + if (starts_with(line, "diff --git")) { struct patch patch = { 0 }; struct strbuf root = STRBUF_INIT; int linenr = 0; + int orig_len; in_header = 0; strbuf_addch(&buf, '\n'); if (!util->diff_offset) util->diff_offset = buf.len; line[len - 1] = '\n'; + orig_len = len; len = parse_git_diff_header(&root, &linenr, 0, line, len, size, &patch); if (len < 0) - die(_("could not parse git header '%.*s'"), (int)len, line); + die(_("could not parse git header '%.*s'"), + orig_len, line); strbuf_addstr(&buf, " ## "); if (patch.is_new > 0) strbuf_addf(&buf, "%s (new)", patch.new_name); diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh index bd808f87ed..e024cff65c 100755 --- a/t/t3206-range-diff.sh +++ b/t/t3206-range-diff.sh @@ -513,6 +513,16 @@ test_expect_success 'range-diff overrides diff.noprefix internally' ' git -c diff.noprefix=true range-diff HEAD^... ' +test_expect_success 'basic with modified format.pretty with suffix' ' + git -c format.pretty="format:commit %H%d%n" range-diff \ + master..topic master..unmodified +' + +test_expect_success 'basic with modified format.pretty without "commit "' ' + git -c format.pretty="format:%H%n" range-diff \ + master..topic master..unmodified +' + test_expect_success 'range-diff compares notes by default' ' git notes add -m "topic note" topic && git notes add -m "unmodified note" unmodified && |
