summaryrefslogtreecommitdiff
path: root/t/t3800-mktag.sh
AgeCommit message (Collapse)Author
2021-06-28mktag tests: test fast-exportÆvar Arnfjörð Bjarmason
Pass the bad tags we've created in the mktag tests through fast-export, it will die on the bad object or ref, let's make sure that happens. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-06-28mktag tests: test for-each-refÆvar Arnfjörð Bjarmason
Add a "for-each-ref" for all the mktag tests. This test would have caught the segfault which was fixed in c6854508808 (ref-filter: fix NULL check for parse object failure, 2021-04-01). Let's make sure we test that code more exhaustively. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-06-28mktag tests: test update-ref and reachable fsckÆvar Arnfjörð Bjarmason
Extend the mktag tests to pass the created bad tag through update-ref and fsck. The reason for passing it through update-ref is to guard against it having a segfault as for-each-ref did before c6854508808 (ref-filter: fix NULL check for parse object failure, 2021-04-01). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-06-28mktag tests: test hash-object --literally and unreachable fsckÆvar Arnfjörð Bjarmason
Extend the mktag tests to pass the tag we've created through both hash-object --literally and fsck. This checks that fsck itself will not complain about certain invalid content if a reachable tip isn't involved. Due to how fsck works and walks the graph the failure will be different if the object is reachable, so we might succeed before we've created the ref. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-06-15mktag tests: invert --no-strict testÆvar Arnfjörð Bjarmason
Change the mktag --no-strict test to actually test success under --no-strict, that test was added in 06ce79152be (mktag: add a --[no-]strict option, 2021-01-06). It doesn't make sense to check that we have the same failure except when we want --no-strict, by doing that we're assuming that the behavior will be different under --no-strict, bun nothing was testing for that. We should instead assert that --strict is the same as --no-strict, except in the cases where we've declared that it's not. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-06-15mktag tests: parse out options in helperÆvar Arnfjörð Bjarmason
Change check_verify_failure() helper to parse out options from $@. This makes it easier to add new options in the future. See 06ce79152be (mktag: add a --[no-]strict option, 2021-01-06) for the initial implementation. Let's also replace "" quotes with '' for the test body, the varables we need are eval'd into the body, so there's no need for the quoting confusion. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-03-24mktag tests: fix broken "&&" chainÆvar Arnfjörð Bjarmason
Remove a stray "xb" I inadvertently introduced in 780aa0a21e0 (tests: remove last uses of GIT_TEST_GETTEXT_POISON=false, 2021-02-11). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-02-11tests: remove last uses of GIT_TEST_GETTEXT_POISON=falseÆvar Arnfjörð Bjarmason
Follow-up my 73c01d25fe2 (tests: remove uses of GIT_TEST_GETTEXT_POISON=false, 2021-01-20) by removing the last uses of GIT_TEST_GETTEXT_POISON=*. These assignments were part of branch that was in-flight at the time of the gettext poison removal. See 466f94ec45e (Merge branch 'ab/detox-gettext-tests', 2021-02-10) and c7d6d419b0d (Merge branch 'ab/mktag', 2021-01-25) for the merging of the two branches. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-06mktag: add a --[no-]strict optionÆvar Arnfjörð Bjarmason
Now that mktag has been migrated to use the fsck machinery to check its input, it makes sense to teach it to run in the equivalent of "git fsck"'s default mode. For cases where mktag is used to (re)create a tag object using data from an existing and malformed tag object, the validation may optionally have to be loosened. Teach the command to take the "--[no-]strict" option to do so. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag: convert to parse-optionsÆvar Arnfjörð Bjarmason
Convert the "mktag" command to use parse-options.h instead of its own ad-hoc argc handling. This doesn't matter much in practice since it doesn't support any options, but removes another special-case in our codebase, and makes it easier to add options to it in the future. It does marginally improve the situation for programs that want to execute git commands in a consistent manner and e.g. always use --end-of-options. E.g. "gitaly" does that, and has a blacklist of built-ins that don't support --end-of-options. This is one less special case for it and other similar programs to support. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag: allow omitting the header/body \n separatorÆvar Arnfjörð Bjarmason
Change mktag's acceptance rules to accept an empty body without an empty line after the header again. This fixes an ancient unintended dregression in "mktag". When "mktag" was introduced in ec4465adb3 (Add "tag" objects that can be used to sign other objects., 2005-04-25) the input checks were much looser. When it was documented it 6cfec03680 (mktag: minimally update the description., 2007-06-10) it was clearly intended for this \n to be optional: The message, when [it] exists, is separated by a blank line from the header. But then in e0aaf781f6 (mktag.c: improve verification of tagger field and tests, 2008-03-27) this was made an error, seemingly by accident. It was just a result of the general header checks, and all the tests after that patch have a trailing empty line (but did not before). Let's allow this again, and tweak the test semantics changed in e0aaf781f6 to remove the redundant empty line. New tests added in previous commits of mine already added an explicit test for allowing the empty line between header and body. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag: allow turning off fsck.extraHeaderEntryÆvar Arnfjörð Bjarmason
In earlier commits mktag learned to use the fsck machinery, at which point we needed to add fsck.extraHeaderEntry so it could be as strict about extra headers as it's been ever since it was implemented. But it's not nice to need to switch away from "mktag" to "hash-object" + manual "fsck" just because you'd like to have an extra header. So let's support turning it off by getting "fsck.*" variables from the config. Pedantically speaking it's still not possible to make "mktag" behave just like "hash-object -t tag" does, since we're unconditionally going to check the referenced object in verify_object_in_tag(), which is our own check, and not one that exists in fsck.c. But the spirit of "this works like fsck" is preserved, in that if you created such a tag with "hash-object" and did a full "fsck" on the repository it would also error out about that invalid object, it just wouldn't emit the same message as fsck does. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag: use fsck instead of custom verify_tag()Ævar Arnfjörð Bjarmason
Change the validation logic in "mktag" to use fsck's fsck_tag() instead of its own custom parser. Curiously the logic for both dates back to the same commit[1]. Let's unify them so we're not maintaining two sets functions to verify that a tag is OK. The behavior of fsck_tag() and the old "mktag" code being removed here is different in few aspects. I think it makes sense to remove some of those checks, namely: A. fsck only cares that the timezone matches [-+][0-9]{4}. The mktag code disallowed values larger than 1400. Yes there's currently no timezone with a greater offset[2], but since we allow any number of non-offical timezones (e.g. +1234) passing this through seems fine. Git also won't break in the future if e.g. French Polynesia decides it needs to outdo the Line Islands when it comes to timezone extravagance. B. fsck allows missing author names such as "tagger <email>", mktag wouldn't, but would allow e.g. "tagger [2 spaces] <email>" (but not "tagger [1 space] <email>"). Now we allow all of these. C. Like B, but "mktag" disallowed spaces in the <email> part, fsck allows it. In some ways fsck_tag() is stricter than "mktag" was, namely: D. fsck disallows zero-padded dates, but mktag didn't care. So e.g. the timestamp "0000000000 +0000" produces an error now. A test in "t1006-cat-file.sh" relied on this, it's been changed to use "hash-object" (without fsck) instead. There was one check I deemed worth keeping by porting it over to fsck_tag(): E. "mktag" did not allow any custom headers, and by extension (as an empty commit is allowed) also forbade an extra stray trailing newline after the headers it knew about. Add a new check in the "ignore" category to fsck and use it. This somewhat abuses the facility added in efaba7cc77f (fsck: optionally ignore specific fsck issues completely, 2015-06-22). This is somewhat of hack, but probably the least invasive change we can make here. The fsck command will shuffle these categories around, e.g. under --strict the "info" becomes a "warn" and "warn" becomes "error". Existing users of fsck's (and others, e.g. index-pack) --strict option rely on this. So we need to put something into a category that'll be ignored by all existing users of the API. Pretending that fsck.extraHeaderEntry=error ("ignore" by default) was set serves to do this for us. 1. ec4465adb38 (Add "tag" objects that can be used to sign other objects., 2005-04-25) 2. https://en.wikipedia.org/wiki/List_of_UTC_time_offsets Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: test verify_object() with replaced objectsÆvar Arnfjörð Bjarmason
Add tests to demonstrate what "mktag" does in the face of replaced objects. There was an existing test for replaced objects fed to "mktag" added in cc400f50112 (mktag: call "check_sha1_signature" with the replacement sha1, 2009-01-23), but that one only tests a commit->commit mapping. Not a mapping to a different type as like we're also testing for here. We could remove the "mktag" test in t6050-replace.sh now if the created tag wasn't being used by a subsequent "fsck" test. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: improve verify_object() test coverageÆvar Arnfjörð Bjarmason
The verify_object() function in "mktag.c" is tasked with ensuring that our tag refers to a valid object. The existing test for this might fail because it was also testing that "type taggg" didn't refer to a valid object type (it should be "type tag"), or because we referred to a valid object but got the type wrong. Let's split these tests up, so we're testing all combinations of a non-existing object and in invalid/wrong "type" lines. We need to provide GIT_TEST_GETTEXT_POISON=false here because the "invalid object type" error is emitted by parse_loose_header_extended(), which has that message already marked for translation. Another option would be to use test_i18ngrep, but I prefer always running the test, not skipping it under gettext poison testing. I'm not testing this in combination with "git replace". That'll be done in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: test "hash-object" compatibilityÆvar Arnfjörð Bjarmason
Change all the successful "mktag" tests to test that "hash-object" produces the same hash for the input, and that fsck passes for both. This tests e.g. that "mktag" doesn't trim its input or otherwise munge it in a way that "hash-object" doesn't. Since we're doing an "fsck --strict" here at the end let's incorporate the creation of the "mytag" name into this test, removing the special-case at the end of the file. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: stress test whitespace handlingÆvar Arnfjörð Bjarmason
Add tests for a couple of whitespace edge cases around the header/body boundary. I consider the requirement for a blank line before the empty body a bug, it's a long-standing regression which goes against the command's documented behavior. This bug will be addressed in a follow-up change. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: run "fsck" after creating "mytag"Ævar Arnfjörð Bjarmason
Change the last test in the file to run an "fsck --strict" after creating the tag at the end. We're just doing this for good measure to check that fsck behaves as expected now that there's finally a reference for our valid tag. Other tests going to be checking this elsewhere, but it's nice to cover all the edge cases in this test to make it as self-contained as possible. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: don't create "mytag" twiceÆvar Arnfjörð Bjarmason
Change a test added in e0aaf781f6 (mktag.c: improve verification of tagger field and tests, 2008-03-27) to not create "mytag", which should only be created and verified at the end in an earlier test added in 446c6faec6 (New tests and en-passant modifications to mktag., 2006-07-29). While we're at it let's prevent a similar logic error from creeping into the test by asserting that "mytag" doesn't exist before we create it. Let's do this by moving the test to use "update-ref", instead of our own homebrew ad-hoc refstore update. We're not really testing for anything yet by creating the tag at the end here. A subsequent commit will change that. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: don't redirect stderr to a file needlesslyÆvar Arnfjörð Bjarmason
Remove the redirection of stderr to "message" in the valid tag test. This pattern seems to have been copy/pasted from the failure case in 446c6faec6 (New tests and en-passant modifications to mktag., 2006-07-29). While I'm at it do the same for the "replace" tests. The tag creation I'm changing here seems to have been copy/pasted from the "mktag" tests to those tests in cc400f50112 (mktag: call "check_sha1_signature" with the replacement sha1, 2009-01-23). Nobody examines the contents of the resulting "message" file, so the net result is that error messages cannot be seen in "sh t3800-mktag.sh -v" output. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: remove needless SHA-1 hardcodingÆvar Arnfjörð Bjarmason
Change the tests amended in acb49d1cc8b (t3800: make hash-size independent, 2019-08-18) even more to make them independent of either SHA-1 or SHA-256. Some of these tests were failing for the wrong reasons. The first one being modified here would fail because the line starts with "xxxxxx" instead of "object", the rest of the line doesn't matter. Let's just put a valid hash on the rest of the line anyway to narrow the test down for just the s/object/xxxxxx/ case. The second one being modified here would fail under GIT_TEST_DEFAULT_HASH=sha256 because <some sha-1 length garbage> is an invalid SHA-256, but we should really be testing <some sha-256 length garbage> when under SHA-256. This doesn't really matter since we should be able to trust other parts of the code to validate things in the 0-9a-f range, but let's keep it for good measure. There's a later test which tests an invalid SHA which looks like a valid one, to stress the "We refuse to tag something we can't verify[...]" logic in mktag.c. But here we're testing for a SHA-length string which contains characters outside of the /[0-9a-f]/i set. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: use "test_commit" helperÆvar Arnfjörð Bjarmason
Replace ad-hoc setup of a single commit in the "mktag" tests with our standard helper pattern. The old setup dated back to 446c6faec69 (New tests and en-passant modifications to mktag., 2006-07-29) before the helper existed. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-05mktag tests: don't needlessly use a subshellÆvar Arnfjörð Bjarmason
The use of a subshell dates back to e9b20943b77 (t/t3800: do not use a temporary file to hold expected result., 2008-01-04). It's not needed anymore, if it ever was. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-07-30t: remove test_oid_init in testsbrian m. carlson
Now that we call test_oid_init in the setup for all test scripts, there's no point in calling it individually. Remove all of the places where we've done so to help keep tests tidy. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-08-20t3800: make hash-size independentbrian m. carlson
Replace references to several hard-coded object IDs with a variable referring to the generated commit. Avoid matching on exact character positions, which will be different depending on the hash in use. In the test for a valid object ID, use an obviously invalid one from the lookup table. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-20Use test_expect_success for test setupsBrian Gernhardt
Several tests did not use test_expect_success for their setup commands. Putting these start commands into the testing framework means both that errors during setup will be caught quickly and that non-error text will be suppressed without -v. Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-09-03tests: use "git xyzzy" form (t0000 - t3599)Nanako Shiraishi
Converts tests between t0050-t3903. Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-14mask necessary whitespace policy violations in test scriptsJeff King
All of these violations are necessary parts of the tests (which are generally checking the behavior of trailing whitespace, or contain diff fragments with empty lines). Our solution is two-fold: 1. Process input with whitespace problems using tr. This has the added bonus that it becomes very obvious where the bogus whitespace is intended to go. 2. Move large diff fragments into their own supplemental files. This gets rid of the whitespace problem, since supplemental files are not checked, and it also makes the test script a bit easier to read. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-01mktag.c: tweak validation of tagger field and adjust test scriptBrandon Casey
Update the verify_tag() function to remove an unnecessary test, and add additional check for angle brackets in the name and email field, and spaces in the email field. The timestamp and timezone sections are made more straight forward by using strspn(). Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-31mktag.c: improve verification of tagger field and testsBrandon Casey
Since nearly its birth, git's tags have included a "tagger" field which describes the name of tagger, email of tagger, and date and time of tagging. But, this field was only loosely tested by git-mktag. Provide some thorough testing for this field and also ensure that the tag header is separated from the tag body by an empty line to reduce the convenience of creating a flawed tag. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-26t/t3800-mktag.sh: use test_must_fail rather than '!'Brandon Casey
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-05t/t3800: do not use a temporary file to hold expected result.Junio C Hamano
It is a good practice to write program output to a temporary file during the test, as it would allow easier postmortem when the tested program does break. But there is no benefit in writing the expected output out to the temporary. This actually fixes a bug in check_verify_failure() routine. The intention of the test seems to make sure the "git mktag" command fails, and it spits out the expected error message. But if the command did not fail as expected, the shell function as originally written would not have detected the failure. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-05t/t{3600,3800,5401}: do not use egrep when grep would doJunio C Hamano
There is nothing _wrong_ with egrep per se, but this way we would have less dependency on external tools. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-03Rewrite "git-frotz" to "git frotz"Junio C Hamano
This uses the remove-dashes target to replace "git-frotz" to "git frotz". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-02-04Assorted typo fixesPavel Roskin
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-16Replace "echo -n" with printf in shell scripts.Jason Riedy
Not all echos know -n. This was causing a test failure in t5401-update-hooks.sh, but not t3800-mktag.sh for some reason. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-08-02New tests and en-passant modifications to mktag.Ramsay Allan Jones
These changes were originally part of the next patch, but have been split out since they were peripheral to the main purpose of that patch. - update comment describing the signature format to reflect the current code. - remove trailing \n in calls to error(), since a \n is already provided by error(). - remove redundant call to get_sha1_hex(). - call sha1_to_hex(sha1) to convert to ascii, rather than attempting to print the raw sha1. The new tests provide a regression suite to support the modifications to git-mktag in this and the next patch. Signed-off-by: Ramsay Allan Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <junkio@cox.net>