-
Notifications
You must be signed in to change notification settings - Fork 143
Preliminary fixes for reftable support #669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
/submit |
Submitted as pull.669.git.1593518738.gitgitgadget@gmail.com |
On the Git mailing list, Junio C Hamano wrote (reply to this):
|
This branch is now known as |
This patch series was integrated into seen via git@fd5c471. |
This patch series was integrated into seen via git@66f3a24. |
This patch series was integrated into seen via git@da40f20. |
This patch series was integrated into seen via git@3dfc36e. |
This patch series was integrated into seen via git@f1c2194. |
This patch series was integrated into seen via git@aefc3ef. |
This patch series was integrated into seen via git@6f7cfa5. |
This patch series was integrated into seen via git@2cb0ca1. |
This patch series was integrated into seen via git@dfe6f6e. |
This patch series was integrated into seen via git@98dd40e. |
This patch series was integrated into seen via git@17af751. |
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Both the git-bisect.sh as bisect--helper inspected the file system directly. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Regarding reflog messages: - We expect that a reflog message consists of a single line. The file format used by the files backend may add a LF after the message as a delimiter, and output by commands like "git log -g" may complete such an incomplete line by adding a LF at the end, but philosophically, the terminating LF is not a part of the message. - We however allow callers of refs API to supply a random sequence of NUL terminated bytes. We cleanse caller-supplied message by squashing a run of whitespaces into a SP, and by trimming trailing whitespace, before storing the message. This is how we tolerate, instead of erring out, a message with LF in it (be it at the end, in the middle, or both). Currently, the cleansing of the reflog message is done by the files backend, before the log is written out. This is sufficient with the current code, as that is the only backend that writes reflogs. But new backends can be added that write reflogs, and we'd want the resulting log message we would read out of "log -g" the same no matter what backend is used. An added benefit is that the "cleansing" function could be updated later, independent from individual backends, to e.g. allow multi-line log messages if we wanted to, and when that happens, it would help a lot to ensure we covered all bases if the cleansing function (which would be updated) is called from the generic layer. Side note: I am not interested in supporting multi-line reflog messages right at the moment (nobody is asking for it), but I envision that instead of the "squash a run of whitespaces into a SP and rtrim" cleansing, we can %urlencode problematic bytes in the message *AND* append a SP at the end, when a new version of Git that supports multi-line and/or verbatim reflog messages writes a reflog record. The reading side can detect the presense of SP at the end (which should have been rtrimmed out if it were written by existing versions of Git) as a signal that decoding %urlencode recovers the original reflog message. Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
/submit |
Submitted as pull.669.v2.git.1594401593.gitgitgadget@gmail.com |
On the Git mailing list, Junio C Hamano wrote (reply to this):
|
@@ -902,7 +902,7 @@ int delete_ref(const char *msg, const char *refname, | |||
old_oid, flags); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Junio C Hamano wrote (reply to this):
"Junio C Hamano via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Currently, the cleansing of the reflog message is done by the files
> backend, before the log is written out. This is sufficient with the
> current code, as that is the only backend that writes reflogs. But
> new backends can be added that write reflogs, and we'd want the
> resulting log message we would read out of "log -g" the same no
> matter what backend is used.
I _think_ there is no correctness impact, but this slightly changes
the semantics. We used to take whatever random string from the
caller and at the lowest layer of the files backend, i.e.
> strbuf_addf(&sb, "%s %s %s", oid_to_hex(old_oid), oid_to_hex(new_oid), committer);
> if (msg && *msg)
> - copy_reflog_msg(&sb, msg);
> + strbuf_addstr(&sb, msg);
cleansed and added the message to strbuf.
With the updated code, normalize_reflog_message() is defined like so
> +static char *normalize_reflog_message(const char *msg)
> +{
> + struct strbuf sb = STRBUF_INIT;
> +
> + if (msg && *msg)
> + copy_reflog_msg(&sb, msg);
> + return strbuf_detach(&sb, NULL);
> +}
to always return a non-NULL but an empty string, even if the caller
gave us a NULL pointer. We always pass a non-NULL string around,
and the updated low-level code avoids calling strbuf_addstr()
because msg is not NULL, but *msg is '\0'.
We _might_ be able to optimize by tweaking the normalizer a bit
further, perhaps like so:
static char *normalize_reflog_message(const char *msg)
{
struct strbuf sb = STRBUF_INIT;
if (msg && *msg)
copy_reflog_msg(&sb, msg);
if (sb.len) {
return strbuf_detach(&sb, NULL);
} else {
strbuf_release(&sb);
return NULL;
}
}
to avoid allocating 1 byte '\0' on the heap by strbuf_detach() when
sb here ends up being truly empty.
But it would be a premature optimization to worry about such a thing
at this point, I think.
Thanks.
This patch series was integrated into seen via git@5a80cc8. |
This patch series was integrated into seen via git@30eb2cc. |
This patch series was integrated into seen via git@9a5a3af. |
This patch series was integrated into next via git@e524883. |
This patch series was integrated into seen via git@0c929c6. |
This patch series was integrated into seen via git@430470b. |
This patch series was integrated into seen via git@39c3065. |
This patch series was integrated into seen via git@5cefbac. |
This patch series was integrated into seen via git@29b9f5e. |
This patch series was integrated into seen via git@61d58e8. |
This patch series was integrated into seen via git@d0f73d8. |
This patch series was integrated into seen via git@3428f9c. |
This patch series was integrated into seen via git@5e2a57a. |
This patch series was integrated into seen via git@a60fefe. |
This patch series was integrated into seen via git@1c6a945. |
This patch series was integrated into seen via git@2102555. |
This patch series was integrated into seen via git@9f1be6f. |
This patch series was integrated into seen via git@b590dc8. |
This patch series was integrated into seen via git@71fd332. |
This patch series was integrated into seen via git@902db90. |
This patch series was integrated into seen via git@5aa6db6. |
This patch series was integrated into seen via git@f413529. |
This patch series was integrated into seen via git@3161cc6. |
This patch series was integrated into next via git@3161cc6. |
This patch series was integrated into master via git@3161cc6. |
Closed via 3161cc6. |
These are assorted small fixes split out from the reftable topic.