[PATCH 1/1] fast-import: checkpoint: dump branches/tags/marks even if object_count==0
The checkpoint command cycles packfiles if object_count != 0, a sensible test or there would be no pack files to write. Since 820b931012, the command also dumps branches, tags and marks, but still conditionally. However, it is possible for a command stream to modify refs or create marks without creating any new objects.
For example, reset a branch (and keep fast-import running):
$ git fast-import
reset refs/heads/master
from refs/heads/master^
checkpoint
but refs/heads/master remains unchanged.
Other example: a commit command that re-creates an object that already exists in the object database.
The man page also states that checkpoint "updates the refs" and that "placing a progress command immediately after a checkpoint will inform the reader when the checkpoint has been completed and it can safely access the refs that fast-import updated". This wasn't always true without this patch.
This fix unconditionally calls dump_{branches,tags,marks}() for all checkpoint commands. dump_branches() and dump_tags() are cheap to call in the case of a no-op.
Add tests to t9300 that observe the (non-packfiles) effects of checkpoint.
Signed-off-by: Eric Rannaud <e@nanocritical.com>
---
fast-import.c | 6 +--
t/t9300-fast-import.sh | 117 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 120 insertions(+), 3 deletions(-)
Any comments on the testing strategy with a background fast-import?
To summarize:
- fast-import is started in the background with a command stream that
ends with "checkpoint\nprogress checkpoint\n". fast-import keeps
running after reaching the last command (we don't want fast-import to
terminate).
- In the meantime, the test is waiting to read "progress checkpoint" in
the output of fast-import, then it checks the testing conditions.
- Finally, the test ensures that fast-import is still running in the
background (and thus that it has just observed the effect of
checkpoint, and not the side effects of fast-import terminating).
- After 10 sec, no matter what, the background fast-import is sent
"done" and terminates.
I tried to make sure that the test runs quickly and does not (typically) sleep. Upon failure, the test may take up to 10 sec to fully terminate.
However, the test could break under (very heavy) load if fast-import is unable to make progress in a reasonable amount of time (either "progress checkpoint" is not read within 5 sec, or fast-import receives "done" before the testing conditions are checked). Let me know if this is not acceptable.
Should these test cases be at least separated to a new t9304 to circumscribe any such nuisance? Alternatively, a FIFO-based approach could be considered.
(Note: added cases 2 and 4 pass without this patch, but 1 and 3 do not.)