librelist archives

« back to archive

Did libgit2 support for Unicode unde Windows? Request for simple demo

Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
罗勇刚(Yonggang Luo)
Date:
2011-10-18 @ 17:55
How to do a simple commit with libgit2?
For example, under a bare git repository, I want to commit file
*filename:a.txt content:'First Commit'*
other information are random.
How to do that?
-- 
         此致

罗勇刚
Yours
    sincerely,
Yonggang Luo

Re: [libgit2] Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
schu
Date:
2011-10-18 @ 18:08
On 10/18/2011 07:55 PM, 罗勇刚 (Yonggang Luo) wrote:
> How to do a simple commit with libgit2?
> For example, under a bare git repository, I want to commit file
> *filename:a.txt content:'First Commit'*
> other information are random.
> How to do that?

Hi, in a nutshell: you need to

* create a blob,
* create a tree referencing the blob and
* create a commit referencing the tree.

You will find more documentation in the header files under

	include/git2

and some example code here:

	http://libgit2.github.com/libgit2/ex/HEAD/general.html

HTH.

Re: Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
罗勇刚(Yonggang Luo)
Date:
2011-10-18 @ 18:27
And unicode?

2011/10/19, schu <schu-github@schulog.org>:
> On 10/18/2011 07:55 PM, 罗勇刚 (Yonggang Luo) wrote:
>> How to do a simple commit with libgit2?
>> For example, under a bare git repository, I want to commit file
>> *filename:a.txt content:'First Commit'*
>> other information are random.
>> How to do that?
>
> Hi, in a nutshell: you need to
>
> * create a blob,
> * create a tree referencing the blob and
> * create a commit referencing the tree.
>
> You will find more documentation in the header files under
>
> 	include/git2
>
> and some example code here:
>
> 	http://libgit2.github.com/libgit2/ex/HEAD/general.html
>
> HTH.
>
>
>

-- 
从我的移动设备发送

         此致

罗勇刚
Yours
    sincerely,
Yonggang Luo

Re: [libgit2] Re: Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
Vicent Marti
Date:
2011-10-18 @ 19:27
Hey,

Git is, by design, encoding agnostic. The raw bytes you may pass to
any method in libgit2 will be treated opaquely regarding encoding, and
will be stored raw on the Git data structures. This is not our design
decision, but one that comes straight from core Git.

If you use UTF-8 encoded strings (which is going to be, under all
circumstances, the most reasonable option), your Unicode paths will be
handled seamlessly by the library and the OS. If your OS uses some
special (Eastern/Asian) encoding, you can pass paths in that encoding,
but that will make your repository unaccessible on other OSes that use
standard encodings.

Sorry for the limitations. Once again, these encoding issues are not
up to us: we need to retain compatibility with Core Git.

Cheers,
Vicent

On Tue, Oct 18, 2011 at 6:27 PM, 罗勇刚 (Yonggang Luo)
<luoyonggang@gmail.com> wrote:
> And unicode?
>
> 2011/10/19, schu <schu-github@schulog.org>:
>> On 10/18/2011 07:55 PM, 罗勇刚 (Yonggang Luo) wrote:
>>> How to do a simple commit with libgit2?
>>> For example, under a bare git repository, I want to commit file
>>> *filename:a.txt content:'First Commit'*
>>> other information are random.
>>> How to do that?
>>
>> Hi, in a nutshell: you need to
>>
>> * create a blob,
>> * create a tree referencing the blob and
>> * create a commit referencing the tree.
>>
>> You will find more documentation in the header files under
>>
>>       include/git2
>>
>> and some example code here:
>>
>>       http://libgit2.github.com/libgit2/ex/HEAD/general.html
>>
>> HTH.
>>
>>
>>
>
> --
> 从我的移动设备发送
>
>         此致
> 礼
> 罗勇刚
> Yours
>    sincerely,
> Yonggang Luo
>

Re: Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
罗勇刚(Yonggang Luo)
Date:
2011-10-19 @ 00:59
Supporting for utf8 filename encoding on Win is very important for
asia and non-latin users, indeed, msysgit is already start do that, so
that make sense libgit2 also do that, and its more latter, more
harder, and I think its a must be feature, we have to do it sooner or
latter.

2011/10/19, Vicent Marti <vicent@github.com>:
> Hey,
>
> Git is, by design, encoding agnostic. The raw bytes you may pass to
> any method in libgit2 will be treated opaquely regarding encoding, and
> will be stored raw on the Git data structures. This is not our design
> decision, but one that comes straight from core Git.
>
> If you use UTF-8 encoded strings (which is going to be, under all
> circumstances, the most reasonable option), your Unicode paths will be
> handled seamlessly by the library and the OS. If your OS uses some
> special (Eastern/Asian) encoding, you can pass paths in that encoding,
> but that will make your repository unaccessible on other OSes that use
> standard encodings.
>
> Sorry for the limitations. Once again, these encoding issues are not
> up to us: we need to retain compatibility with Core Git.
>
> Cheers,
> Vicent
>
> On Tue, Oct 18, 2011 at 6:27 PM, 罗勇刚 (Yonggang Luo)
> <luoyonggang@gmail.com> wrote:
>> And unicode?
>>
>> 2011/10/19, schu <schu-github@schulog.org>:
>>> On 10/18/2011 07:55 PM, 罗勇刚 (Yonggang Luo) wrote:
>>>> How to do a simple commit with libgit2?
>>>> For example, under a bare git repository, I want to commit file
>>>> *filename:a.txt content:'First Commit'*
>>>> other information are random.
>>>> How to do that?
>>>
>>> Hi, in a nutshell: you need to
>>>
>>> * create a blob,
>>> * create a tree referencing the blob and
>>> * create a commit referencing the tree.
>>>
>>> You will find more documentation in the header files under
>>>
>>>       include/git2
>>>
>>> and some example code here:
>>>
>>>       http://libgit2.github.com/libgit2/ex/HEAD/general.html
>>>
>>> HTH.
>>>
>>>
>>>
>>
>> --
>> 从我的移动设备发送
>>
>>         此致
>> 礼
>> 罗勇刚
>> Yours
>>    sincerely,
>> Yonggang Luo
>>
>

-- 
从我的移动设备发送

         此致

罗勇刚
Yours
    sincerely,
Yonggang Luo

Re: [libgit2] Re: Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
Vicent Marti
Date:
2011-10-19 @ 01:04
Hey,

I'm afraid we lost something in translation here. :)

libgit2 is already fully compliant with UTF-8 paths, in both Linux,
Mac OS X and Windows. Under Windows, it internally translates all
paths to UTF-16 and uses the `W` calls on the Windows API -- making it
more consistent than msysgit.

Please report back if you find any issues while using non-ASCII paths
on the library.

Cheers,
Vicent

On Wed, Oct 19, 2011 at 12:59 AM, 罗勇刚 (Yonggang Luo)
<luoyonggang@gmail.com> wrote:
> Supporting for utf8 filename encoding on Win is very important for
> asia and non-latin users, indeed, msysgit is already start do that, so
> that make sense libgit2 also do that, and its more latter, more
> harder, and I think its a must be feature, we have to do it sooner or
> latter.
>
> 2011/10/19, Vicent Marti <vicent@github.com>:
>> Hey,
>>
>> Git is, by design, encoding agnostic. The raw bytes you may pass to
>> any method in libgit2 will be treated opaquely regarding encoding, and
>> will be stored raw on the Git data structures. This is not our design
>> decision, but one that comes straight from core Git.
>>
>> If you use UTF-8 encoded strings (which is going to be, under all
>> circumstances, the most reasonable option), your Unicode paths will be
>> handled seamlessly by the library and the OS. If your OS uses some
>> special (Eastern/Asian) encoding, you can pass paths in that encoding,
>> but that will make your repository unaccessible on other OSes that use
>> standard encodings.
>>
>> Sorry for the limitations. Once again, these encoding issues are not
>> up to us: we need to retain compatibility with Core Git.
>>
>> Cheers,
>> Vicent
>>
>> On Tue, Oct 18, 2011 at 6:27 PM, 罗勇刚 (Yonggang Luo)
>> <luoyonggang@gmail.com> wrote:
>>> And unicode?
>>>
>>> 2011/10/19, schu <schu-github@schulog.org>:
>>>> On 10/18/2011 07:55 PM, 罗勇刚 (Yonggang Luo) wrote:
>>>>> How to do a simple commit with libgit2?
>>>>> For example, under a bare git repository, I want to commit file
>>>>> *filename:a.txt content:'First Commit'*
>>>>> other information are random.
>>>>> How to do that?
>>>>
>>>> Hi, in a nutshell: you need to
>>>>
>>>> * create a blob,
>>>> * create a tree referencing the blob and
>>>> * create a commit referencing the tree.
>>>>
>>>> You will find more documentation in the header files under
>>>>
>>>>       include/git2
>>>>
>>>> and some example code here:
>>>>
>>>>       http://libgit2.github.com/libgit2/ex/HEAD/general.html
>>>>
>>>> HTH.
>>>>
>>>>
>>>>
>>>
>>> --
>>> 从我的移动设备发送
>>>
>>>         此致
>>> 礼
>>> 罗勇刚
>>> Yours
>>>    sincerely,
>>> Yonggang Luo
>>>
>>
>
> --
> 从我的移动设备发送
>
>         此致
> 礼
> 罗勇刚
> Yours
>    sincerely,
> Yonggang Luo
>

Re: [libgit2] Re: Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
Meinrad Recheis
Date:
2011-10-21 @ 07:53
On Wed, Oct 19, 2011 at 3:04 AM, Vicent Marti <vicent@github.com> wrote:

> Hey,
>
> I'm afraid we lost something in translation here. :)
>
> libgit2 is already fully compliant with UTF-8 paths, in both Linux,
> Mac OS X and Windows. Under Windows, it internally translates all
> paths to UTF-16 and uses the `W` calls on the Windows API -- making it
> more consistent than msysgit.
>

Hi Vicent,
That's great! Currently with with msysgit it can happen that German umlauts
in file names cause git index operations to fail. Therefor one needs to
avoid non-ascii chars in paths. What do you think, will this feature be able
to find its way into msysgit in the near future?

>
> Please report back if you find any issues while using non-ASCII paths
> on the library.
>
> Cheers,
> Vicent
>
> On Wed, Oct 19, 2011 at 12:59 AM, 罗勇刚 (Yonggang Luo)
> <luoyonggang@gmail.com> wrote:
> > Supporting for utf8 filename encoding on Win is very important for
> > asia and non-latin users, indeed, msysgit is already start do that, so
> > that make sense libgit2 also do that, and its more latter, more
> > harder, and I think its a must be feature, we have to do it sooner or
> > latter.
> >
> > 2011/10/19, Vicent Marti <vicent@github.com>:
> >> Hey,
> >>
> >> Git is, by design, encoding agnostic. The raw bytes you may pass to
> >> any method in libgit2 will be treated opaquely regarding encoding, and
> >> will be stored raw on the Git data structures. This is not our design
> >> decision, but one that comes straight from core Git.
> >>
> >> If you use UTF-8 encoded strings (which is going to be, under all
> >> circumstances, the most reasonable option), your Unicode paths will be
> >> handled seamlessly by the library and the OS. If your OS uses some
> >> special (Eastern/Asian) encoding, you can pass paths in that encoding,
> >> but that will make your repository unaccessible on other OSes that use
> >> standard encodings.
> >>
> >> Sorry for the limitations. Once again, these encoding issues are not
> >> up to us: we need to retain compatibility with Core Git.
> >>
> >> Cheers,
> >> Vicent
> >>
> >> On Tue, Oct 18, 2011 at 6:27 PM, 罗勇刚 (Yonggang Luo)
> >> <luoyonggang@gmail.com> wrote:
> >>> And unicode?
> >>>
> >>> 2011/10/19, schu <schu-github@schulog.org>:
> >>>> On 10/18/2011 07:55 PM, 罗勇刚 (Yonggang Luo) wrote:
> >>>>> How to do a simple commit with libgit2?
> >>>>> For example, under a bare git repository, I want to commit file
> >>>>> *filename:a.txt content:'First Commit'*
> >>>>> other information are random.
> >>>>> How to do that?
> >>>>
> >>>> Hi, in a nutshell: you need to
> >>>>
> >>>> * create a blob,
> >>>> * create a tree referencing the blob and
> >>>> * create a commit referencing the tree.
> >>>>
> >>>> You will find more documentation in the header files under
> >>>>
> >>>>       include/git2
> >>>>
> >>>> and some example code here:
> >>>>
> >>>>       http://libgit2.github.com/libgit2/ex/HEAD/general.html
> >>>>
> >>>> HTH.
> >>>>
> >>>>
> >>>>
> >>>
> >>> --
> >>> 从我的移动设备发送
> >>>
> >>>         此致
> >>> 礼
> >>> 罗勇刚
> >>> Yours
> >>>    sincerely,
> >>> Yonggang Luo
> >>>
> >>
> >
> > --
> > 从我的移动设备发送
> >
> >         此致
> > 礼
> > 罗勇刚
> > Yours
> >    sincerely,
> > Yonggang Luo
> >
>

Re: [libgit2] Re: Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
Carlos Martín Nieto
Date:
2011-10-21 @ 09:43
On Fri, 2011-10-21 at 09:53 +0200, Meinrad Recheis wrote:
> On Wed, Oct 19, 2011 at 3:04 AM, Vicent Marti <vicent@github.com> wrote:
> 
> > Hey,
> >
> > I'm afraid we lost something in translation here. :)
> >
> > libgit2 is already fully compliant with UTF-8 paths, in both Linux,
> > Mac OS X and Windows. Under Windows, it internally translates all
> > paths to UTF-16 and uses the `W` calls on the Windows API -- making it
> > more consistent than msysgit.
> >
> 
> Hi Vicent,
> That's great! Currently with with msysgit it can happen that German umlauts
> in file names cause git index operations to fail. Therefor one needs to
> avoid non-ascii chars in paths. What do you think, will this feature be able
> to find its way into msysgit in the near future?

Karsten Blees is currently working on this. You can see his work at
https://github.com/kblees/msysgit/tree/kb/msys/unicode and
https://github.com/kblees/msysgit/tree/kb/msys/less

Notice however, that it's much more complicated that just telling git to
use Unicode. The rest of the MSYS environment must also support Unicode
paths.

> 
> >
> > Please report back if you find any issues while using non-ASCII paths
> > on the library.
> >
> > Cheers,
> > Vicent
> >
> > On Wed, Oct 19, 2011 at 12:59 AM, 罗勇刚 (Yonggang Luo)
> > <luoyonggang@gmail.com> wrote:
> > > Supporting for utf8 filename encoding on Win is very important for
> > > asia and non-latin users, indeed, msysgit is already start do that, so
> > > that make sense libgit2 also do that, and its more latter, more
> > > harder, and I think its a must be feature, we have to do it sooner or
> > > latter.
> > >
> > > 2011/10/19, Vicent Marti <vicent@github.com>:
> > >> Hey,
> > >>
> > >> Git is, by design, encoding agnostic. The raw bytes you may pass to
> > >> any method in libgit2 will be treated opaquely regarding encoding, and
> > >> will be stored raw on the Git data structures. This is not our design
> > >> decision, but one that comes straight from core Git.
> > >>
> > >> If you use UTF-8 encoded strings (which is going to be, under all
> > >> circumstances, the most reasonable option), your Unicode paths will be
> > >> handled seamlessly by the library and the OS. If your OS uses some
> > >> special (Eastern/Asian) encoding, you can pass paths in that encoding,
> > >> but that will make your repository unaccessible on other OSes that use
> > >> standard encodings.
> > >>
> > >> Sorry for the limitations. Once again, these encoding issues are not
> > >> up to us: we need to retain compatibility with Core Git.
> > >>
> > >> Cheers,
> > >> Vicent
> > >>
> > >> On Tue, Oct 18, 2011 at 6:27 PM, 罗勇刚 (Yonggang Luo)
> > >> <luoyonggang@gmail.com> wrote:
> > >>> And unicode?
> > >>>
> > >>> 2011/10/19, schu <schu-github@schulog.org>:
> > >>>> On 10/18/2011 07:55 PM, 罗勇刚 (Yonggang Luo) wrote:
> > >>>>> How to do a simple commit with libgit2?
> > >>>>> For example, under a bare git repository, I want to commit file
> > >>>>> *filename:a.txt content:'First Commit'*
> > >>>>> other information are random.
> > >>>>> How to do that?
> > >>>>
> > >>>> Hi, in a nutshell: you need to
> > >>>>
> > >>>> * create a blob,
> > >>>> * create a tree referencing the blob and
> > >>>> * create a commit referencing the tree.
> > >>>>
> > >>>> You will find more documentation in the header files under
> > >>>>
> > >>>>       include/git2
> > >>>>
> > >>>> and some example code here:
> > >>>>
> > >>>>       http://libgit2.github.com/libgit2/ex/HEAD/general.html
> > >>>>
> > >>>> HTH.
> > >>>>
> > >>>>
> > >>>>
> > >>>
> > >>> --
> > >>> 从我的移动设备发送
> > >>>
> > >>>         此致
> > >>> 礼
> > >>> 罗勇刚
> > >>> Yours
> > >>>    sincerely,
> > >>> Yonggang Luo
> > >>>
> > >>
> > >
> > > --
> > > 从我的移动设备发送
> > >
> > >         此致
> > > 礼
> > > 罗勇刚
> > > Yours
> > >    sincerely,
> > > Yonggang Luo
> > >
> >


-- 
Carlos Martín Nieto        http://www.cmartin.tk

"¿Cómo voy a decir bobadas si soy mudo?" -- CACHAI

Re: Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
罗勇刚(Yonggang Luo)
Date:
2011-10-19 @ 01:40
That's great, thanks.

2011/10/19, Vicent Marti <vicent@github.com>:
> Hey,
>
> I'm afraid we lost something in translation here. :)
>
> libgit2 is already fully compliant with UTF-8 paths, in both Linux,
> Mac OS X and Windows. Under Windows, it internally translates all
> paths to UTF-16 and uses the `W` calls on the Windows API -- making it
> more consistent than msysgit.
>
> Please report back if you find any issues while using non-ASCII paths
> on the library.
>
> Cheers,
> Vicent
>
> On Wed, Oct 19, 2011 at 12:59 AM, 罗勇刚 (Yonggang Luo)
> <luoyonggang@gmail.com> wrote:
>> Supporting for utf8 filename encoding on Win is very important for
>> asia and non-latin users, indeed, msysgit is already start do that, so
>> that make sense libgit2 also do that, and its more latter, more
>> harder, and I think its a must be feature, we have to do it sooner or
>> latter.
>>
>> 2011/10/19, Vicent Marti <vicent@github.com>:
>>> Hey,
>>>
>>> Git is, by design, encoding agnostic. The raw bytes you may pass to
>>> any method in libgit2 will be treated opaquely regarding encoding, and
>>> will be stored raw on the Git data structures. This is not our design
>>> decision, but one that comes straight from core Git.
>>>
>>> If you use UTF-8 encoded strings (which is going to be, under all
>>> circumstances, the most reasonable option), your Unicode paths will be
>>> handled seamlessly by the library and the OS. If your OS uses some
>>> special (Eastern/Asian) encoding, you can pass paths in that encoding,
>>> but that will make your repository unaccessible on other OSes that use
>>> standard encodings.
>>>
>>> Sorry for the limitations. Once again, these encoding issues are not
>>> up to us: we need to retain compatibility with Core Git.
>>>
>>> Cheers,
>>> Vicent
>>>
>>> On Tue, Oct 18, 2011 at 6:27 PM, 罗勇刚 (Yonggang Luo)
>>> <luoyonggang@gmail.com> wrote:
>>>> And unicode?
>>>>
>>>> 2011/10/19, schu <schu-github@schulog.org>:
>>>>> On 10/18/2011 07:55 PM, 罗勇刚 (Yonggang Luo) wrote:
>>>>>> How to do a simple commit with libgit2?
>>>>>> For example, under a bare git repository, I want to commit file
>>>>>> *filename:a.txt content:'First Commit'*
>>>>>> other information are random.
>>>>>> How to do that?
>>>>>
>>>>> Hi, in a nutshell: you need to
>>>>>
>>>>> * create a blob,
>>>>> * create a tree referencing the blob and
>>>>> * create a commit referencing the tree.
>>>>>
>>>>> You will find more documentation in the header files under
>>>>>
>>>>>       include/git2
>>>>>
>>>>> and some example code here:
>>>>>
>>>>>       http://libgit2.github.com/libgit2/ex/HEAD/general.html
>>>>>
>>>>> HTH.
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> 从我的移动设备发送
>>>>
>>>>         此致
>>>> 礼
>>>> 罗勇刚
>>>> Yours
>>>>    sincerely,
>>>> Yonggang Luo
>>>>
>>>
>>
>> --
>> 从我的移动设备发送
>>
>>         此致
>> 礼
>> 罗勇刚
>> Yours
>>    sincerely,
>> Yonggang Luo
>>
>

-- 
从我的移动设备发送

         此致

罗勇刚
Yours
    sincerely,
Yonggang Luo

Re: [libgit2] Did libgit2 support for Unicode unde Windows? Request for simple demo

From:
Emeric Fermas
Date:
2011-10-18 @ 18:25
Hello,

If C# doesn't scare you away, you can take a look how repo.Commit() has been
implemented in LibGit2Sharp [0] by orchestrating libgit2 methods. Beware,
this only works (for now) against standard repository with working directory
and leverages Index operations (Stage/Unstage).
In order to give you a high level view of how repo.Commit() works, you can
take a look at this test [1].

 [0]:

https://github.com/libgit2/libgit2sharp/blob/master/LibGit2Sharp/CommitCollection.cs#L126
 [1]:

https://github.com/libgit2/libgit2sharp/blob/master/LibGit2Sharp.Tests/CommitFixture.cs#L357

HTH Too,

Cheers,
Em.


On Tue, Oct 18, 2011 at 7:55 PM, 罗勇刚 (Yonggang Luo)
<luoyonggang@gmail.com>wrote:

> How to do a simple commit with libgit2?
> For example, under a bare git repository, I want to commit file
> *filename:a.txt content:'First Commit'*
> other information are random.
>  How to do that?
> --
>          此致
> 礼
> 罗勇刚
> Yours
>     sincerely,
> Yonggang Luo
>
>