librelist archives

« back to archive

difficult in implementing git porcelain command

difficult in implementing git porcelain command

From:
徐迪
Date:
2011-10-24 @ 13:38
Hi, list
I just want to implement some git porcelain command which based on
libgit2, like 'git add', and I found it's rather difficult to do so.

Support I already have a repository in $HOME/test/.git and I have a
subdir in it, let's name it dir1, and it has a file named file1,
so here we have $HOME/test/dir1/file1, and my current work dir is
$HOME/test/dir1, I want to use "add file1" to add file1 to stage it,
just like normal git command. I use git_repository_discover,
git_repository_open and git_repository_index to get index file, but I
can not figure out how to use git_index_add to add a file, as libgit2
API says "The file `path` must be relative to the repository's working
folder", I couldn't find any API related to this, does this means I
have to implement my own api to do so? Why doesn't libgit2 implement
this api?