Provide a notification handler in the CLI so that (for example) warnings
and non-fatal error information can be sent to stdout. The CLI ignores
"fatal" level errors since they're superfluous; it will get the same
error after the function returns.
Users can now configure a "notification callback"; notifications are
raised when a condition occurs in a git repository that an end-user
should know about, or that the calling application may wish to act on.
Notifications provide structured data, that is provided based on the
type of notification (for example, file paths).
In addition, an an informative message is provided when a notification
is raised; the structured data should be sufficient for callers to build
their own message, but the provided message should make that
unnecessary.
Some examples of likely future use of notifications:
* `core.safecrlf=warn` messages are warning-level notifications. This
allows the calling application to receive these notifications and
display them to the user (for example, sending them to the console).
* When a file cannot be written during checkout, we should inform the
calling application. By default, git continues to check out when one
(or more) paths fail to be written, but conclude that the checkout
failed overall. Given this somewhat odd behavior, callers may wish to
short-circuit this when any path fails to be written.
* Callers may want structured failure information for a `safe.directory`
failure so that they can get the file path without having to try to
"screen scrape" the git_error message.
I tried to build my libgit2-1.9.0 package for CYGWIN but I got an error. This message appears when compiling:
[199/671] Building C object src/cli/CMakeFiles/git2_cli.dir/opt.c.o
libgit2-1.9.0/src/cli/opt.c: In function ‘cli_opt_parse’:
libgit2-1.9.0/src/cli/opt.c:564:23: warning: implicit declaration of function ‘alloca’; did you mean ‘malloc’? [-Wimplicit-function-declaration]
564 | given_specs = alloca(sizeof(const cli_opt_spec *) * (args_len + 1));
| ^~~~~~
| malloc
and later the linker emits this error message:
[668/671] Linking C executable git2.exe
FAILED: git2.exe
/usr/x86_64-pc-cygwin/bin/ld: src/cli/CMakeFiles/git2_cli.dir/opt.c.o: in function `cli_opt_parse':
/usr/src/debug/libgit2-1.9.0-1/src/cli/opt.c:564:(.text+0xce3): undefined reference to `alloca'
collect2: error: ld returned 1 exit status
The error is fixed by adding alloca.h to included headers.
Hopefully, opt.c already allows to add alloca.h for some platforms, so I just added an additional test for the preprocessor for checking if the target is CYGWIN.
Introduce `--profile` support to the benchmark helper script, which will
invoke `perf` on Linux. Additionally, add a `--flamegraph` output
option based on that.
It can be useful to report the commit ID during benchmarks to track down
regressions; leverage the addition of that in `git version` during
benchmark runs.
There's no such thing as a "loose object type" or a "packed object
type". There are only object types. Introduce `type_is_valid` and
deprecate `typeisloose`.