diff options
Diffstat (limited to '')
| -rw-r--r-- | source/cgit.c | 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/cgit.h | 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | source/ui-patch.c | 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rwxr-xr-x | tests/t0109-patch.sh | 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4 files changed, 20 insertions, 6 deletions
diff --git a/source/cgit.c b/source/cgit.c index 5f8ecfa..a877e92 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -54,6 +54,8 @@ struct refmatch { int found; }; +const char *cgit_version = CGIT_VERSION; + /* * Isolate git from the calling user's configuration, which could otherwise * break once HOME is unset below. It runs as a constructor because git reads diff --git a/source/cgit.h b/source/cgit.h index 5b92632..c04193f 100644 --- a/source/cgit.h +++ b/source/cgit.h @@ -324,6 +324,8 @@ struct cgit_context { int empty_repo; }; +extern const char *cgit_version; + extern struct cgit_repolist cgit_repolist; extern struct cgit_context ctx; diff --git a/source/ui-patch.c b/source/ui-patch.c index 525e660..78c850c 100644 --- a/source/ui-patch.c +++ b/source/ui-patch.c @@ -62,6 +62,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, const char *pref struct commit *commit; struct object_id new_oid, old_oid; char rev_range[REV_RANGE_LEN]; + const char *version; // setup_revisions reads these the way git reads a command line, so the // first entry stands in for the program name and is skipped, and the // array has to stay null terminated because the path after the double @@ -130,11 +131,16 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, const char *pref ctx.page.filename = cgit_fmt("%s.patch", rev_range); cgit_print_http_headers(); + // git format-patch signs with its bare version number, so the v that + // cgit's tags carry is left off to read the same way. + if (!skip_prefix(cgit_version, "v", &version)) + version = cgit_version; + while ((commit = get_revision(&rev))) { log_tree_commit(&rev, commit); // Two dashes and a space is the mail signature separator, so - // git am and mail readers drop the line below rather than - // carrying it into the commit message. - printf("-- \ncgit\n\n"); + // git am and mail readers drop the version note below rather + // than carrying it into the commit message. + printf("-- \ncgit %s\n\n", version); } } diff --git a/tests/t0109-patch.sh b/tests/t0109-patch.sh index 3cb9d08..0c4bf8c 100755 --- a/tests/t0109-patch.sh +++ b/tests/t0109-patch.sh @@ -8,9 +8,13 @@ test_description='Check content on patch page' . ./setup.sh +# The version the built binary signs its patches with, without the v of the +# tag, as git writes its own. +CGIT_VERSION=$(sed -n "s/CGIT_VERSION = v\{0,1\}//p" "$TEST_OUTPUT_DIRECTORY/../build/VERSION") + # The signature sits on the second-to-last line, above the trailing blank. check_cgit_signature() { - tail -2 tmp | head -1 | grep "^cgit$" + tail -2 tmp | head -1 | grep -x -F "cgit $CGIT_VERSION" } test_expect_success 'generate foo/patch' ' @@ -35,7 +39,7 @@ test_expect_success 'find `cgit` signature' ' test_expect_success 'compare with output of git-format-patch(1)' ' git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" \ - --signature="cgit" --stdout HEAD^ >tmp2 && + --signature="cgit $CGIT_VERSION" --stdout HEAD^ >tmp2 && strip_headers <tmp >tmp_ && test_cmp tmp_ tmp2 ' @@ -64,7 +68,7 @@ test_expect_success 'find `cgit` signature on the range' ' test_expect_success 'compare the range with git-format-patch(1)' ' git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" \ - -N --signature="cgit" --stdout HEAD~3..HEAD >tmp2 && + -N --signature="cgit $CGIT_VERSION" --stdout HEAD~3..HEAD >tmp2 && strip_headers <tmp >tmp_ && test_cmp tmp_ tmp2 ' |
