# APIs for automatic patch generation

6 messages from 2010-02-20 to 2010-12-13. Participants: Markus Elfring, Sverre Rabbelier.
Thread: https://gitlist.dev/t/22742

## Markus Elfring, 2010-02-20 19:40

Subject: APIs for automatic patch generation
Message-ID: <4B803AB8.30304@web.de>
URL: https://gitlist.dev/e/4B803AB8.30304%40web.de

```
Hello,

I would like to generate patches in the Git format for some other
software automatically. Which application programming interfaces do you
recommend for this purpose if I am going to integrate this into a small
C++ class library?
http://www.kernel.org/pub/software/scm/git/docs/v1.7.0/technical/api-index.html
http://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools

Specific use cases:
- Which functions or commands should I call to retrieve the required
informations for a line like "index 8d16832..358c98b 100644"?
- Can any functions help to construct proper range specifications for
difference hunks?

Regards,
Markus

```

## Markus Elfring, 2010-02-23 17:04

Subject: Re: APIs for automatic patch generation
Message-ID: <4B840AA2.3010604@web.de>
URL: https://gitlist.dev/e/4B840AA2.3010604%40web.de
In-Reply-To: <4B803AB8.30304@web.de>

```
Hello,

The commands "git diff" and "git format-patch" contain functionality that I
would like to reuse for my little application in a C++ class library.

Which functions exist in a C API that can provide the following data?
- a line like "index 8d16832..358c98b 100644"
- range specifications for difference hunks
- mail construction

Regards,
Markus

```

## Sverre Rabbelier, 2010-02-23 17:07

Subject: Re: APIs for automatic patch generation
Message-ID: <fabb9a1e1002230907u6471efa5w234a5dabfa4ba5e1@mail.gmail.com>
URL: https://gitlist.dev/e/fabb9a1e1002230907u6471efa5w234a5dabfa4ba5e1%40mail.gmail.com
In-Reply-To: <4B840AA2.3010604@web.de>

```
Heya,

On Tue, Feb 23, 2010 at 18:04, Markus Elfring <Markus.Elfring@web.de> wrote:
> The commands "git diff" and "git format-patch" contain functionality that I
> would like to reuse for my little application in a C++ class library.

Until libgit2 is done, just shell out and call 'git format-patch'.

[0] http://git.wiki.kernel.org/index.php/SoC2010Ideas#libgit2

-- 
Cheers,

Sverre Rabbelier

```

## Markus Elfring, 2010-02-23 17:23

Subject: Re: APIs for automatic patch generation
Message-ID: <4B840EF5.2090306@web.de>
URL: https://gitlist.dev/e/4B840EF5.2090306%40web.de
In-Reply-To: <fabb9a1e1002230907u6471efa5w234a5dabfa4ba5e1@mail.gmail.com>

```
> Until libgit2 is done, just shell out and call 'git format-patch'.

Thanks for the link.

I do not need the whole functionality of these commands for my library. I am
looking if the mentioned data items can also be really retrieved by command line
parameters.

Regards,
Markus

```

## Sverre Rabbelier, 2010-02-23 18:07

Subject: Re: APIs for automatic patch generation
Message-ID: <fabb9a1e1002231007p650d78fere904f6e5572b12d@mail.gmail.com>
URL: https://gitlist.dev/e/fabb9a1e1002231007p650d78fere904f6e5572b12d%40mail.gmail.com
In-Reply-To: <4B840EF5.2090306@web.de>

```
Heya,

On Tue, Feb 23, 2010 at 18:23, Markus Elfring <Markus.Elfring@web.de> wrote:
> I do not need the whole functionality of these commands for my library.

My answer still holds.

-- 
Cheers,

Sverre Rabbelier

```

## Markus Elfring, 2010-12-13 16:00

Subject: Re: APIs for automatic patch generation
Message-ID: <4D06431E.5020906@web.de>
URL: https://gitlist.dev/e/4D06431E.5020906%40web.de
In-Reply-To: <4B840AA2.3010604@web.de>

```
> The commands "git diff" and "git format-patch" contain functionality that I
> would like to reuse for my little application in a C++ class library.

Which functions exist in the recently published C API 
(http://libgit2.github.com/) that can provide the following data?
* a line like "index 8d16832..358c98b 100644"
* range specifications for difference hunks
* mail construction

Regards,
Markus

```
