An informal list of FIXMEs which don't warrant full tickets...

This is not *intended* to be a list of long-lived fixme's, but more of a scratchpad for things which come up spontaneously and shouldn't be forgotten.

In no particular order...

# Global Config DB Handle (2021-11-09)

Currently the global config db handle is managed the same as the repo and checkout handles: they are `ATTACH`ed to an in-memory `main` db.
Experience with `fnc` suggests that we probably want to split it into its own db handle so that it can be opened and closed at will without
locking-related issues. As of this writing, it's not possible to close (detach) the config db while any statement handle is currently being
processed (that is, has been stepped but not yet finalized or reset) because any statement in such a state will lock the `ATTACH`ed dbs.

The internals are set up to handle such a thing but this will require many small changes, some of which will certainly have to be
discovered via trial and error.

There are currently no known use cases which require doing SQL joins on data from the global config db and the repo/checkout dbs,
so no significant SQL needs to be changed for this.

Sidebar: this will have one significant change: the db name for that db will no longer be `cfg`, but `main` for its handle. We'll need to ensure that
the schema does not use the name `cfg` anywhere.


# Diff Engine v2

Related to the "v2" diff engine (2021 edition)...

## Diff formats with chunk headers sometimes split unnecessarily

When outputing to a format which uses "chunk headers" (like unified) can sometimes split two chunks which are directly adjacent:

```
$ ./f-vdiff 072d63965188 a725befe5863 -l '*vdiff*' | head -30
Index: f-apps/f-vdiff.c
==================================================================
--- f-apps/f-vdiff.c
+++ f-apps/f-vdiff.c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    36     36    fsl_buffer fname;
    37     37    fsl_buffer fcontent1;
    38     38    fsl_buffer fcontent2;
    39     39    fsl_buffer fhash;
    40     40    fsl_list globs;
           41 +  fsl_diff_opt diffOpt;
           42 +  fsl_diff_builder * diffBuilder;
    41     43  } VDiffApp = {
    42     44
    43     45
    44     46
    45     47
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    46     48
    47     49
    48     50
    49     51
    50     52
    51
           53
           54
           55
    52     56  };
    53     57
    54     58  static int f_vdiff_hash(fsl_card_F const * const fc,
```

Note how line numbers above and below the `~~~~~` (diff chunk separator) are consecutive. fossil(1) doesn't do that because it handles the chunk separator at a higher level of the API, whereas libf moves that into the diff builder interface. That change requires that libf forego a step fossil performs which tries to merge chunks of a diff together if the distance between them is smaller than the number of context lines. That change in libf is apparently the root cause of this. It's purely cosmetic, but it's annoying. The core of the discrepancy comes from fossil mixing the output of of the diffs: most of it is done from the diff builders but some pieces, like Unified-format diff line number markers, are output from the core diff driver algorithm. That gives it more control over the output, but it also only supports a single output channel (a memory buffer), whereas libf needs to be able to support arbitrary output channels (some of which, like ncurses widgets, cannot simply be streamed-to).

TODO: figure out how to adapt libf to (A) not require that the higher-level API know such details about the diff builder but (B) still be able to apply that "cosmetic optimization."

Checkin [](08fdbacefacd2b) partially resolves this, but only for the case when we're using line numbers (as in the above example).

## Backports from Fossil

This list is for potential backports from fossil which should be investigated more closely to determine whether they need to be adapted for use in this library:

- Improved diff output with `--from BRANCH` when it names a branch which was just merged into the local checkout: <s>[](fossil:edb3a3a06369c1e7bd29)</s>
[](fossil:960c9e8bd69531eb)


# f-apps-specific

## f-vdiff

#### Recognize Renames

f-vdiff, when comparing to the local checkout, needs to be able to recognize renames. Case in point:

```
f-vdiff . .
f-vdiff: ERROR #107 (FSL_RC_NOT_FOUND): Cannot stat file;
```

That file, along with many others, was moved to `../tools` in this checkout. We have the state necessary to do this check (namely, the vfile table), it just needs to get done).

#### Optionally show full content of added/removed files

For newly-added/removed files, f-vdiff politely only shows "added" or "removed," not the whole content. Thought it's ostensibly easy to add an option to do this, f-vdiff's internal structure didn't really foresee that possibility and retrofitting it now requires some reworking.