Re: [PATCH 1/1] do not add common-main to lib

2016-08-15 Thread Christian Hesse
Jeff King  on Mon, 2016/08/15 08:02:
> On Mon, Aug 15, 2016 at 09:52:07AM +0200, Christian Hesse wrote:
> 
> > From: Christian Hesse 
> > 
> > Commit 08aade70 (mingw: declare main()'s argv as const) changed
> > declaration of main function. This breaks linking external projects
> > (e.g. cgit) to libgit.a with:
> > 
> > error: Multiple definition of `main'  
> 
> I'd expect the culprit is actually 3f2e229 (add an extra level of
> indirection to main(), 2016-07-01).

Ah, probably you are right...

> > So do not add common-main to lib and let projects have their own
> > main function.  
> 
> That is certainly an option, but I think it means that those projects
> are potentially buggy in the same way that some git commands were prior
> to the common-main series. Namely, the common main() may do some
> run-time setup that parts of libgit.a assume has been done.

Ok, got it.

> I would not be surprised if cgit crashes on Windows, for instance, for
> the reasons detailed in 650c449 (common-main: call
> git_extract_argv0_path(), 2016-07-01). I would also not be surprised if
> nobody actually builds cgit on Windows. :)

I never tried and probably nobody else did. :-p

> The "right" way to do it (according to the way libgit.a views the world)
> is for cgit's main to become cmd_main(), and let libgit.a do its
> run-time startup before getting there.

Looks like that does the job. I will give it some more testing.

Please ignore my patch... ;)
Thanks a lot!
-- 
main(a){char*c=/*Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/*Best regards my address:*/=0;b=c[a++];)
putchar(b-1/(/*Chriscc -ox -xc - && ./x*/b/42*2-3)*42);}


pgpptHBMuwcrB.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/1] do not add common-main to lib

2016-08-15 Thread Christian Hesse
Johannes Schindelin  on Mon, 2016/08/15 14:20:
> Hi Christian,
> 
> On Mon, 15 Aug 2016, Christian Hesse wrote:
> 
> > From: Christian Hesse 
> > 
> > Commit 08aade70 (mingw: declare main()'s argv as const) changed
> > declaration of main function. This breaks linking external projects
> > (e.g. cgit) to libgit.a with:
> > 
> > error: Multiple definition of `main'
> > 
> > So do not add common-main to lib and let projects have their own
> > main function.  
> 
> I am opposed to this change.

Me too. :-p

> For one, libgit.a is *not* a library with an API, for a good reason:
> nothing in Git's development guarantees any kind of stable API. For that
> reason, libgit.a is not installed, either, and neither are any headers.
> 
> And even more importantly: *iff* you *insist* on using libgit.a in your
> project *despite* having been told not to, it is your responsibility to
> stay up-to-date with the requirements of it.

cgit pulls in the git tree as a subproject. We are aware that the API changes
all the time and that's fine. Usually we just fix it, this time I missed the
background information of the change.

> One such requirement is that you now implement cmd_main() instead of
> main().
> 
> So if you want to continue to have an out-of-tree project that links
> against the (private) libgit.a, it is your out-of-tree project that needs
> changing, not libgit.a.

Already updated my code. ;)
Thanks!
-- 
main(a){char*c=/*Schoene Gruesse */"B?IJj;MEH"
"CX:;",b;for(a/*Best regards my address:*/=0;b=c[a++];)
putchar(b-1/(/*Chriscc -ox -xc - && ./x*/b/42*2-3)*42);}


pgp1A1xIdqYyY.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/1] do not add common-main to lib

2016-08-15 Thread Johannes Schindelin
Hi Christian,

On Mon, 15 Aug 2016, Christian Hesse wrote:

> From: Christian Hesse 
> 
> Commit 08aade70 (mingw: declare main()'s argv as const) changed
> declaration of main function. This breaks linking external projects
> (e.g. cgit) to libgit.a with:
> 
> error: Multiple definition of `main'
> 
> So do not add common-main to lib and let projects have their own
> main function.

I am opposed to this change.

For one, libgit.a is *not* a library with an API, for a good reason:
nothing in Git's development guarantees any kind of stable API. For that
reason, libgit.a is not installed, either, and neither are any headers.

And even more importantly: *iff* you *insist* on using libgit.a in your
project *despite* having been told not to, it is your responsibility to
stay up-to-date with the requirements of it.

One such requirement is that you now implement cmd_main() instead of
main().

So if you want to continue to have an out-of-tree project that links
against the (private) libgit.a, it is your out-of-tree project that needs
changing, not libgit.a.

Ciao,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] do not add common-main to lib

2016-08-15 Thread Jeff King
On Mon, Aug 15, 2016 at 09:52:07AM +0200, Christian Hesse wrote:

> From: Christian Hesse 
> 
> Commit 08aade70 (mingw: declare main()'s argv as const) changed
> declaration of main function. This breaks linking external projects
> (e.g. cgit) to libgit.a with:
> 
> error: Multiple definition of `main'

I'd expect the culprit is actually 3f2e229 (add an extra level of
indirection to main(), 2016-07-01).

> So do not add common-main to lib and let projects have their own
> main function.

That is certainly an option, but I think it means that those projects
are potentially buggy in the same way that some git commands were prior
to the common-main series. Namely, the common main() may do some
run-time setup that parts of libgit.a assume has been done.

I would not be surprised if cgit crashes on Windows, for instance, for
the reasons detailed in 650c449 (common-main: call
git_extract_argv0_path(), 2016-07-01). I would also not be surprised if
nobody actually builds cgit on Windows. :)

The "right" way to do it (according to the way libgit.a views the world)
is for cgit's main to become cmd_main(), and let libgit.a do its
run-time startup before getting there.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html