git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add --path-prefix option to git-fast-import

From
Shawn O. Pearce <spearce@spearce.org>
Date
Dec 29, 2009, 15:08 UTC
Message-ID
<20091229150844.GC6152@spearce.org>
In-Reply-To
<1262091083-25401-1-git-send-email-gisle.aas@it.uib.no>
Gisle Aas <gisle.aas@it.uib.no> wrote:
Show 9 quoted lines
> I found this useful when import multiple external repositories to be merged
> into a single git repo.  Not having the files be renamed during the merge
> made it easier to follow the history of the individual files.
> 
> Signed-off-by: Gisle Aas <gisle@aas.no>
> ---
>  Documentation/git-fast-import.txt |    6 ++++++
>  fast-import.c                     |   24 ++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 0 deletions(-)
Interesting.  Test cases?
 
Show 6 quoted lines
> +static const char *path_prefix_prepend(struct strbuf *sb, const char *p)
> +{
> +	if (p != sb->buf) {
> +	    strbuf_reset(sb);
> +	    strbuf_addstr(sb, p);
> +	}

I'd be a bit happier about the change if you could check not only that p != sb->buf, but that p is not within sb->buf + sb->alloc.

I can't remember if all of the cases below are safe such that any time you call the function with a p that p isn't pointing to something within the strbuf you are handing in.

-- 
Shawn.
Previous: Gisle Aas
Message 4 of 4 in “Add --path-prefix option to git-fast-import”
  1. Add --path-prefix option to git-fast-importGisle Aas, Dec 29, 2009
  2. Sverre RabbelierDec 29, 2009
  3. Gisle AasDec 30, 2009
  4. Shawn O. PearceDec 29, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.