forked from enlightenment/edi
edi_scm: make sure we always delete the file if it is untracked.
Summary: there are times when new files are difficult to delete without adding commiting and removing etc. this should stop that. Reviewers: ajwillia.ms Reviewed By: ajwillia.ms Differential Revision: https://phab.enlightenment.org/D5120
This commit is contained in:
parent
61b79e7ed6
commit
d4d8d4fb91
|
@ -214,11 +214,17 @@ static void
|
||||||
_item_menu_scm_del_do_cb(void *data)
|
_item_menu_scm_del_do_cb(void *data)
|
||||||
{
|
{
|
||||||
Edi_Dir_Data *sd;
|
Edi_Dir_Data *sd;
|
||||||
|
Edi_Scm_Status_Code status;
|
||||||
|
|
||||||
sd = data;
|
sd = data;
|
||||||
|
|
||||||
edi_mainview_item_close_path(sd->path);
|
edi_mainview_item_close_path(sd->path);
|
||||||
|
|
||||||
|
status = edi_scm_file_status(sd->path);
|
||||||
|
if (status != EDI_SCM_STATUS_UNTRACKED)
|
||||||
edi_scm_del(sd->path);
|
edi_scm_del(sd->path);
|
||||||
|
else
|
||||||
|
ecore_file_unlink(sd->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -197,6 +197,33 @@ _parse_line(char *line)
|
||||||
return status;
|
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 *
|
static Eina_List *
|
||||||
_edi_scm_git_status_get(void)
|
_edi_scm_git_status_get(void)
|
||||||
{
|
{
|
||||||
|
@ -490,6 +517,14 @@ edi_scm_status_get(void)
|
||||||
return EINA_TRUE;
|
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
|
static void
|
||||||
_edi_scm_commit_thread_cb(void *data, Ecore_Thread *thread)
|
_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->pull = _edi_scm_git_pull;
|
||||||
engine->push = _edi_scm_git_push;
|
engine->push = _edi_scm_git_push;
|
||||||
engine->stash = _edi_scm_git_stash;
|
engine->stash = _edi_scm_git_stash;
|
||||||
|
engine->file_status = _edi_scm_git_file_status;
|
||||||
|
|
||||||
engine->remote_add = _edi_scm_git_remote_add;
|
engine->remote_add = _edi_scm_git_remote_add;
|
||||||
engine->remote_name_get = _edi_scm_git_remote_name_get;
|
engine->remote_name_get = _edi_scm_git_remote_name_get;
|
||||||
|
|
|
@ -10,23 +10,6 @@ extern "C" {
|
||||||
* @brief These routines are used for Edi SCM management.
|
* @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 {
|
typedef enum {
|
||||||
EDI_SCM_STATUS_ADDED = 1,
|
EDI_SCM_STATUS_ADDED = 1,
|
||||||
EDI_SCM_STATUS_DELETED,
|
EDI_SCM_STATUS_DELETED,
|
||||||
|
@ -43,6 +26,24 @@ typedef struct _Edi_Scm_Status
|
||||||
Eina_Bool staged;
|
Eina_Bool staged;
|
||||||
} Edi_Scm_Status;
|
} 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
|
typedef struct _Edi_Scm_Engine
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -56,6 +57,7 @@ typedef struct _Edi_Scm_Engine
|
||||||
scm_fn_move *move;
|
scm_fn_move *move;
|
||||||
scm_fn_commit *commit;
|
scm_fn_commit *commit;
|
||||||
scm_fn_status *status;
|
scm_fn_status *status;
|
||||||
|
scm_fn_file_status *file_status;
|
||||||
scm_fn_push *push;
|
scm_fn_push *push;
|
||||||
scm_fn_pull *pull;
|
scm_fn_pull *pull;
|
||||||
scm_fn_stash *stash;
|
scm_fn_stash *stash;
|
||||||
|
@ -157,6 +159,16 @@ void edi_scm_commit(const char *message);
|
||||||
*/
|
*/
|
||||||
void edi_scm_status(void);
|
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.
|
* Get status of repository.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue