diff --git a/src/bin/edi_filepanel.c b/src/bin/edi_filepanel.c index 43c0321..da2abfd 100644 --- a/src/bin/edi_filepanel.c +++ b/src/bin/edi_filepanel.c @@ -214,11 +214,17 @@ static void _item_menu_scm_del_do_cb(void *data) { Edi_Dir_Data *sd; + Edi_Scm_Status_Code status; sd = data; + edi_mainview_item_close_path(sd->path); - edi_scm_del(sd->path); + status = edi_scm_file_status(sd->path); + if (status != EDI_SCM_STATUS_UNTRACKED) + edi_scm_del(sd->path); + else + ecore_file_unlink(sd->path); } static void diff --git a/src/lib/edi_scm.c b/src/lib/edi_scm.c index 6d75b5d..93882ce 100644 --- a/src/lib/edi_scm.c +++ b/src/lib/edi_scm.c @@ -197,6 +197,33 @@ _parse_line(char *line) return status; } +static Edi_Scm_Status_Code +_edi_scm_git_file_status(const char *path) +{ + Eina_Strbuf *command; + Edi_Scm_Status *status; + Edi_Scm_Status_Code result; + char *line; + + command = eina_strbuf_new(); + + eina_strbuf_append_printf(command, "git status --porcelain %s", path); + + line = _edi_scm_exec_response(eina_strbuf_string_get(command)); + + status = _parse_line(line); + + eina_strbuf_free(command); + + free(line); + result = status->change; + + eina_stringshare_del(status->path); + free(status); + + return result; +} + static Eina_List * _edi_scm_git_status_get(void) { @@ -490,6 +517,14 @@ edi_scm_status_get(void) return EINA_TRUE; } +EAPI Edi_Scm_Status_Code +edi_scm_file_status(const char *path) +{ + Edi_Scm_Engine *e = edi_scm_engine_get(); + + return e->file_status(path); +} + static void _edi_scm_commit_thread_cb(void *data, Ecore_Thread *thread) { @@ -617,6 +652,7 @@ _edi_scm_git_init() engine->pull = _edi_scm_git_pull; engine->push = _edi_scm_git_push; engine->stash = _edi_scm_git_stash; + engine->file_status = _edi_scm_git_file_status; engine->remote_add = _edi_scm_git_remote_add; engine->remote_name_get = _edi_scm_git_remote_name_get; diff --git a/src/lib/edi_scm.h b/src/lib/edi_scm.h index ac885fc..d9144a1 100644 --- a/src/lib/edi_scm.h +++ b/src/lib/edi_scm.h @@ -10,23 +10,6 @@ extern "C" { * @brief These routines are used for Edi SCM management. */ -typedef int (scm_fn_add)(const char *path); -typedef int (scm_fn_mod)(const char *path); -typedef int (scm_fn_del)(const char *path); -typedef int (scm_fn_move)(const char *src, const char *dest); -typedef int (scm_fn_commit)(const char *message); -typedef int (scm_fn_status)(void); -typedef int (scm_fn_push)(void); -typedef int (scm_fn_pull)(void); -typedef int (scm_fn_stash)(void); - -typedef int (scm_fn_remote_add)(const char *remote_url); -typedef const char * (scm_fn_remote_name)(void); -typedef const char * (scm_fn_remote_email)(void); -typedef const char * (scm_fn_remote_url)(void); -typedef int (scm_fn_credentials)(const char *name, const char *email); -typedef Eina_List * (scm_fn_status_get)(void); - typedef enum { EDI_SCM_STATUS_ADDED = 1, EDI_SCM_STATUS_DELETED, @@ -43,6 +26,24 @@ typedef struct _Edi_Scm_Status Eina_Bool staged; } Edi_Scm_Status; +typedef int (scm_fn_add)(const char *path); +typedef int (scm_fn_mod)(const char *path); +typedef int (scm_fn_del)(const char *path); +typedef int (scm_fn_move)(const char *src, const char *dest); +typedef int (scm_fn_commit)(const char *message); +typedef int (scm_fn_status)(void); +typedef int (scm_fn_push)(void); +typedef int (scm_fn_pull)(void); +typedef int (scm_fn_stash)(void); +typedef Edi_Scm_Status_Code (scm_fn_file_status)(const char *path); + +typedef int (scm_fn_remote_add)(const char *remote_url); +typedef const char * (scm_fn_remote_name)(void); +typedef const char * (scm_fn_remote_email)(void); +typedef const char * (scm_fn_remote_url)(void); +typedef int (scm_fn_credentials)(const char *name, const char *email); +typedef Eina_List * (scm_fn_status_get)(void); + typedef struct _Edi_Scm_Engine { const char *name; @@ -50,15 +51,16 @@ typedef struct _Edi_Scm_Engine const char *path; Eina_List *statuses; - scm_fn_add *file_add; - scm_fn_mod *file_mod; - scm_fn_del *file_del; - scm_fn_move *move; - scm_fn_commit *commit; - scm_fn_status *status; - scm_fn_push *push; - scm_fn_pull *pull; - scm_fn_stash *stash; + scm_fn_add *file_add; + scm_fn_mod *file_mod; + scm_fn_del *file_del; + scm_fn_move *move; + scm_fn_commit *commit; + scm_fn_status *status; + scm_fn_file_status *file_status; + scm_fn_push *push; + scm_fn_pull *pull; + scm_fn_stash *stash; scm_fn_remote_add *remote_add; scm_fn_remote_name *remote_name_get; @@ -157,6 +159,16 @@ void edi_scm_commit(const char *message); */ void edi_scm_status(void); +/** + * Get file status within repository. + * + * @param path The file path. + * @return The status code of the file. + * + * @ingroup Scm + */ +Edi_Scm_Status_Code edi_scm_file_status(const char *path); + /** * Get status of repository. *