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

Re: [PATCH/RFC][GSoC] diff-no-index: transform "$directory $file" args to "$directory/$file $file"

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 22, 2015, 02:39 UTC
Message-ID
<CAPig+cShOv0TQ2x_22j8rXyp+kNbBVwAs8E1U==9qkijvffxoA@mail.gmail.com>
In-Reply-To
<CAHLaBN+x3SVL9+jDzeSEMapVd2BVrwQuVx_7ENspjbUPrium_A@mail.gmail.com>
On Sat, Mar 21, 2015 at 8:50 AM, Yurii Shevtsov <ungetch@gmail.com> wrote:
Show 9 quoted lines
> Signed-off-by: Yurii Shevtsov <ungetch@gmail.com>
> ---
> diff --git a/diff-no-index.c b/diff-no-index.c
> index 265709b..9a3439a 100644
> --- a/diff-no-index.c
> +++ b/diff-no-index.c
> @@ -97,8 +97,39 @@ static int queue_diff(struct diff_options *o,
>      if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
>          return -1;

Somehow, you lost all the tabs in the patch, and everything is instead indented with spaces (including context lines).

Show 25 quoted lines
> -    if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
> -        return error("file/directory conflict: %s, %s", name1, name2);
> +    if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2)) {
> +        struct strbuf path;
> +        const char *dir, *file;
> +        char *filename, *dirname = 0;
> +        int i, ret = 0;
> +
> +        dir = S_ISDIR(mode1) ? name1 : name2;
> +        file = (dir == name1) ? name2 : name1;
> +        strbuf_init(&path, strlen(name1) + strlen(name2) + 1);
> +        strbuf_addstr(&path, dir);
> +        filename = strrchr(file, '/');
> +        if (path.len && path.buf[path.len - 1] != '/')
> +            strbuf_addch(&path, '/');
> +        for (i = path.len - 2; i >= 0; i--)
> +            if (path.buf[i] == '/') {
> +                dirname = &path.buf[i];
> +                break;
> +            }
> +        if (dirname == 0)
> +            dirname = path.buf;
> +
> +        if (!strncmp(dirname, filename, strlen(filename)))
> +            return error("file/directory conflict: %s, %s", name1, name2);
Leaking 'path' strbuf.
Show 14 quoted lines
> +
> +        strbuf_addstr(&path, filename ? (filename + 1) : file);
> +        if (file == name1)
> +            ret = queue_diff(o, file, path.buf);
> +        else
> +            ret = queue_diff(o, path.buf, file);
> +        strbuf_release(&path);
> +
> +        return ret;
> +    }
>
>      if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
>          struct strbuf buffer1 = STRBUF_INIT;
> --
Previous: Yurii Shevtsov
Message 4 of 4 in “[GSoC] diff-no-index: transform "$directory $file" args to "$directory/$file $file"”
  1. [GSoC] diff-no-index: transform "$directory $file" args to "$directory/$file $file"Yurii Shevtsov, Mar 21, 2015
  2. Junio C HamanoMar 21, 2015
  3. Yurii ShevtsovMar 21, 2015
  4. Eric SunshineMar 22, 2015

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.