mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
Merge branch 'jt/format-patch-base-info-above-sig'
"git format-patch --base=..." feature that was recently added showed the base commit information after "-- " e-mail signature line, which turned out to be inconvenient. The base information has been moved above the signature line. * jt/format-patch-base-info-above-sig: format-patch: show base info before email signature
This commit is contained in:
commit
e8f871a9ce
|
@ -1042,7 +1042,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
|
||||||
diff_flush(&opts);
|
diff_flush(&opts);
|
||||||
|
|
||||||
fprintf(rev->diffopt.file, "\n");
|
fprintf(rev->diffopt.file, "\n");
|
||||||
print_signature(rev->diffopt.file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *clean_message_id(const char *msg_id)
|
static const char *clean_message_id(const char *msg_id)
|
||||||
|
@ -1361,7 +1360,7 @@ static void print_bases(struct base_tree_info *bases, FILE *file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Show the base commit */
|
/* Show the base commit */
|
||||||
fprintf(file, "base-commit: %s\n", oid_to_hex(&bases->base_commit));
|
fprintf(file, "\nbase-commit: %s\n", oid_to_hex(&bases->base_commit));
|
||||||
|
|
||||||
/* Show the prerequisite patches */
|
/* Show the prerequisite patches */
|
||||||
for (i = bases->nr_patch_id - 1; i >= 0; i--)
|
for (i = bases->nr_patch_id - 1; i >= 0; i--)
|
||||||
|
@ -1720,6 +1719,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||||
make_cover_letter(&rev, use_stdout,
|
make_cover_letter(&rev, use_stdout,
|
||||||
origin, nr, list, branch_name, quiet);
|
origin, nr, list, branch_name, quiet);
|
||||||
print_bases(&bases, rev.diffopt.file);
|
print_bases(&bases, rev.diffopt.file);
|
||||||
|
print_signature(rev.diffopt.file);
|
||||||
total++;
|
total++;
|
||||||
start_number--;
|
start_number--;
|
||||||
}
|
}
|
||||||
|
@ -1779,13 +1779,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||||
if (!use_stdout)
|
if (!use_stdout)
|
||||||
rev.shown_one = 0;
|
rev.shown_one = 0;
|
||||||
if (shown) {
|
if (shown) {
|
||||||
|
print_bases(&bases, rev.diffopt.file);
|
||||||
if (rev.mime_boundary)
|
if (rev.mime_boundary)
|
||||||
fprintf(rev.diffopt.file, "\n--%s%s--\n\n\n",
|
fprintf(rev.diffopt.file, "\n--%s%s--\n\n\n",
|
||||||
mime_boundary_leader,
|
mime_boundary_leader,
|
||||||
rev.mime_boundary);
|
rev.mime_boundary);
|
||||||
else
|
else
|
||||||
print_signature(rev.diffopt.file);
|
print_signature(rev.diffopt.file);
|
||||||
print_bases(&bases, rev.diffopt.file);
|
|
||||||
}
|
}
|
||||||
if (!use_stdout)
|
if (!use_stdout)
|
||||||
fclose(rev.diffopt.file);
|
fclose(rev.diffopt.file);
|
||||||
|
|
|
@ -754,9 +754,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
|
||||||
git format-patch --ignore-if-in-upstream HEAD
|
git format-patch --ignore-if-in-upstream HEAD
|
||||||
'
|
'
|
||||||
|
|
||||||
|
git_version="$(git --version | sed "s/.* //")"
|
||||||
|
|
||||||
|
signature() {
|
||||||
|
printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_expect_success 'format-patch default signature' '
|
||||||
|
git format-patch --stdout -1 | tail -n 3 >output &&
|
||||||
|
signature >expect &&
|
||||||
|
test_cmp expect output
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'format-patch --signature' '
|
test_expect_success 'format-patch --signature' '
|
||||||
git format-patch --stdout --signature="my sig" -1 >output &&
|
git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
|
||||||
grep "my sig" output
|
signature "my sig" >expect &&
|
||||||
|
test_cmp expect output
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'format-patch with format.signature config' '
|
test_expect_success 'format-patch with format.signature config' '
|
||||||
|
@ -1502,12 +1515,12 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
|
||||||
|
|
||||||
test_expect_success 'format-patch --base' '
|
test_expect_success 'format-patch --base' '
|
||||||
git checkout side &&
|
git checkout side &&
|
||||||
git format-patch --stdout --base=HEAD~3 -1 >patch &&
|
git format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual &&
|
||||||
grep "^base-commit:" patch >actual &&
|
echo >expected &&
|
||||||
grep "^prerequisite-patch-id:" patch >>actual &&
|
echo "base-commit: $(git rev-parse HEAD~3)" >>expected &&
|
||||||
echo "base-commit: $(git rev-parse HEAD~3)" >expected &&
|
|
||||||
echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
|
echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
|
||||||
echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
|
echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
|
||||||
|
signature >> expected &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -1605,6 +1618,14 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'format-patch --base with --attach' '
|
||||||
|
git format-patch --attach=mimemime --stdout --base=HEAD~ -1 >patch &&
|
||||||
|
sed -n -e "/^base-commit:/s/.*/1/p" -e "/^---*mimemime--$/s/.*/2/p" \
|
||||||
|
patch >actual &&
|
||||||
|
test_write_lines 1 2 >expect &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'format-patch --pretty=mboxrd' '
|
test_expect_success 'format-patch --pretty=mboxrd' '
|
||||||
sp=" " &&
|
sp=" " &&
|
||||||
cat >msg <<-INPUT_END &&
|
cat >msg <<-INPUT_END &&
|
||||||
|
|
Loading…
Reference in a new issue