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

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

From
GAGisle Aas <gisle.aas@it.uib.no>
Date
Dec 30, 2009, 08:17 UTC
Message-ID
<6B75CF25-4EE4-4475-975D-BB1F9A5B8CC2@it.uib.no>
In-Reply-To
<fabb9a1e0912290606ib1f2e46y1ddbae9aa68e5194@mail.gmail.com>
On Dec 29, 2009, at 15:06, Sverre Rabbelier wrote:
Show 25 quoted lines
> Heya,
> 
> On Tue, Dec 29, 2009 at 06:51, Gisle Aas <gisle.aas@it.uib.no> wrote:
>> +static const char *path_prefix_prepend(struct strbuf *sb, const char *p)
>> +{
>> +       if (p != sb->buf) {
>> +           strbuf_reset(sb);
>> +           strbuf_addstr(sb, p);
>> +       }
>> +       strbuf_insert(sb, 0, path_prefix, path_prefix_len);
>> +       return sb->buf;
>> +}
>> +
>>  static void file_change_m(struct branch *b)
>>  {
>>        const char *p = command_buf.buf + 2;
>> @@ -1909,6 +1921,8 @@ static void file_change_m(struct branch *b)
>>                        die("Garbage after path in: %s", command_buf.buf);
>>                p = uq.buf;
>>        }
>> +       if (path_prefix)
>> +           p = path_prefix_prepend(&uq, p);
> 
> You could reduce the size of this change by having path_prefix_prepend
> check for path_prefix and just do nothing if it is not set.

I felt the explict test was better style -- more obvious that nothing happens to p when there is no path_prefix.

--Gisle
Previous: Sverre RabbelierNext: Shawn O. Pearce
Message 3 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.