All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mateo Patino <mateopatinodev@gmail.com>
To: git@vger.kernel.org
Cc: Mateo Patino <mateopatinodev@gmail.com>,
	karthik.188@gmail.com, jltobler@gmail.com,
	ayu.chandekar@gmail.com, siddharthasthana31@gmail.com, ps@pks.im,
	gitster@pobox.com
Subject: Re: [RFC] [GSoC]: STRBUF_INIT_CONST: initialize `strbuf` to constant string
Date: Mon, 23 Mar 2026 12:10:51 -0400	[thread overview]
Message-ID: <20260323161101.9142-1-mateopatinodev@gmail.com> (raw)
In-Reply-To: <CAPig+cRAsEgeT+OgCSpTuY_Q6dMpXrfadrB=ujkAUyF-ocu2-g@mail.gmail.com>

(Note: resending this because it had HTML the first time and the list rejected 
it. Apologies if it becomes a  duplicate for someone).

>
> You probably didn't intend for it to sound this way, but this summary
> makes it seem as if the Git project rejected these patch submissions
> without proper justification. However, having studied the threads
> which you referenced, it becomes clear that the reason these patches
> were never accepted is because the submitters never followed through
> by addressing reviewer comments. For instance, in my review[*1*] of
> the patch [4] which you referenced, I pointed out several significant
> problems with the patch, but the patch author never responded, so it
> makes sense that the submission was never accepted into the project.

Yes, I saw that they did not reply to reviewer feedback. Here I meant to say 
that previous patches had already been attempted in this area and could be
used as guidance for future attempts.

>
> Although feedback to Robear Selwans's submission from some reviewers
> was subjective, Peff's review[*2*] pointed at a major roadblock;
> specifically, that strbuf has always promoted strbuf.buf is a
> writeable C-style string, so it is not safe simply to assign a pointer
> to a literal string to the "buf" member, and it's not practical to
> expect that all consumers of strbufs can be audited and modified to
> work correctly with the "new world order" that STRBUF_INIT_CONST would
> introduce.

Since the Git codebase widely assumes strbuf.buf is writable, I wonder whether 
we could create a new struct that is specifically documented as a read-only, 
non-owning view into memory, something lightweight like `string_view` in C++, 
which is an object that simply holds a pointer to a string in memory and the length. 
For example, in C,

struct strview {
    const char *buf;
    size_t len;
};

This struct would not care where the memory that `buf` points to exists. The
memory would be owned elsewhere and the caller would be responsible for 
ensuring that the memory is valid throughout the lifetime of the struct. I think
this could help pass around string data without requiring ownership or 
allocation, particularly in cases where the data is already available.

A small downside I see to this approach is that we'd need to write a few helper
functions that accompany this struct, and they would likely share similar names
to the helper functions of `strbuf`, though I think this has been accepted in the 
past in other places throughout the codebase.

Another consideration is that this proposed `strview` would not address the
lifetime and ownership issue in [4], but having a safer way to pass read-only 
strings seems like a step in the right direction.

  reply	other threads:[~2026-03-23 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-22  6:55 [RFC] [GSoC]: STRBUF_INIT_CONST: initialize `strbuf` to constant string Mateo Patino
2026-03-22  8:59 ` Eric Sunshine
2026-03-23 16:10   ` Mateo Patino [this message]
     [not found]   ` <CAFRsFoV+k-8GMf=62GJwxP=o0Fy5RRBGW+h4NqOLjFbU6z96tw@mail.gmail.com>
2026-03-24  3:33     ` Eric Sunshine
2026-03-28 21:40       ` Mateo Patino
2026-03-29  5:23         ` Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260323161101.9142-1-mateopatinodev@gmail.com \
    --to=mateopatinodev@gmail.com \
    --cc=ayu.chandekar@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@gmail.com \
    --cc=karthik.188@gmail.com \
    --cc=ps@pks.im \
    --cc=siddharthasthana31@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.