forked from enlightenment/edi
edi_scm: move project root detection into the library.
Previous commit wasn't really right.
This commit is contained in:
parent
39c821d41a
commit
33556aeae2
|
@ -505,45 +505,6 @@ _edi_scm_ui_file_changes_cb(void *data EINA_UNUSED, int type EINA_UNUSED,
|
|||
return ECORE_CALLBACK_DONE;
|
||||
}
|
||||
|
||||
char *
|
||||
_edi_scm_engine_root_dir_get(void)
|
||||
{
|
||||
Edi_Scm_Engine *engine;
|
||||
char *directory, *engine_root, *path, *tmp;
|
||||
|
||||
engine = edi_scm_engine_get();
|
||||
if (!engine)
|
||||
exit(2 << 1);
|
||||
|
||||
tmp = path = engine_root = NULL;
|
||||
|
||||
directory = strdup(engine->workdir);
|
||||
|
||||
while (directory)
|
||||
{
|
||||
path = edi_path_append(directory, engine->directory);
|
||||
if (ecore_file_exists(path) && ecore_file_is_dir(path))
|
||||
{
|
||||
engine_root = strdup(directory);
|
||||
break;
|
||||
}
|
||||
|
||||
tmp = ecore_file_dir_get(directory);
|
||||
free(directory);
|
||||
directory = tmp;
|
||||
free(path);
|
||||
path = NULL;
|
||||
}
|
||||
|
||||
if (path)
|
||||
free(path);
|
||||
|
||||
if (directory)
|
||||
free(directory);
|
||||
|
||||
return engine_root;
|
||||
}
|
||||
|
||||
char *
|
||||
_edi_scm_ui_workdir_get(void)
|
||||
{
|
||||
|
@ -706,7 +667,6 @@ edi_scm_ui_add(Evas_Object *parent)
|
|||
exit(1 << 1);
|
||||
|
||||
edi_scm = calloc(1, sizeof(Edi_Scm_Ui));
|
||||
engine->workdir = _edi_scm_engine_root_dir_get();
|
||||
edi_scm->workdir = engine->workdir;
|
||||
edi_scm->monitor = eio_monitor_add(edi_scm->workdir);
|
||||
edi_scm->parent = parent;
|
||||
|
|
|
@ -742,6 +742,45 @@ edi_scm_push(void)
|
|||
ecore_thread_run(_edi_scm_push_thread_cb, NULL, NULL, e);
|
||||
}
|
||||
|
||||
static char *
|
||||
_edi_scm_git_project_root_get(void)
|
||||
{
|
||||
Edi_Scm_Engine *engine;
|
||||
char *directory, *engine_root, *path, *tmp;
|
||||
|
||||
engine = edi_scm_engine_get();
|
||||
if (!engine)
|
||||
return NULL;
|
||||
|
||||
tmp = path = engine_root = NULL;
|
||||
|
||||
directory = getcwd(NULL, PATH_MAX);
|
||||
|
||||
while (directory)
|
||||
{
|
||||
path = edi_path_append(directory, engine->directory);
|
||||
if (ecore_file_exists(path) && ecore_file_is_dir(path))
|
||||
{
|
||||
engine_root = strdup(directory);
|
||||
break;
|
||||
}
|
||||
|
||||
tmp = ecore_file_dir_get(directory);
|
||||
free(directory);
|
||||
directory = tmp;
|
||||
free(path);
|
||||
path = NULL;
|
||||
}
|
||||
|
||||
if (path)
|
||||
free(path);
|
||||
|
||||
if (directory)
|
||||
free(directory);
|
||||
|
||||
return engine_root;
|
||||
}
|
||||
|
||||
static Edi_Scm_Engine *
|
||||
_edi_scm_git_init()
|
||||
{
|
||||
|
@ -776,7 +815,7 @@ _edi_scm_git_init()
|
|||
if (edi_project_get())
|
||||
engine->workdir = strdup(edi_project_get());
|
||||
else
|
||||
engine->workdir = getcwd(NULL, PATH_MAX);
|
||||
engine->workdir = _edi_scm_git_project_root_get();
|
||||
|
||||
engine->initialized = EINA_TRUE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue