mirror of
https://github.com/xHyroM/gimi.git
synced 2024-11-21 23:41:06 +01:00
fix: get current branch name correctly
This commit is contained in:
parent
67489a6c60
commit
9fa645fe69
1 changed files with 12 additions and 8 deletions
|
@ -20,20 +20,23 @@ char *get_current_branch_name() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *branch = fgets(output, sizeof(output), file_ptr);
|
if (fgets(output, sizeof(output), file_ptr) == NULL) {
|
||||||
if (branch != NULL) {
|
pclose(file_ptr);
|
||||||
// remove new line
|
return NULL;
|
||||||
size_t len = strlen(branch);
|
}
|
||||||
if (len > 0 && branch[len - 1] == '\n') {
|
|
||||||
branch[len - 1] = '\0';
|
// remove new line
|
||||||
}
|
size_t len = strlen(output);
|
||||||
|
if (len > 0 && output[len - 1] == '\n') {
|
||||||
|
output[len - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
pclose(file_ptr);
|
pclose(file_ptr);
|
||||||
|
|
||||||
return branch;
|
return strdup(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int git_push(char *provider_name, char *branch_name, int options) {
|
int git_push(char *provider_name, char *branch_name, int options) {
|
||||||
FILE *file_ptr;
|
FILE *file_ptr;
|
||||||
char output[1024];
|
char output[1024];
|
||||||
|
@ -97,6 +100,7 @@ int cli_command_push(int argc, char **argv) {
|
||||||
printf("info: successfully pushed into '%s'.\n", provider->name);
|
printf("info: successfully pushed into '%s'.\n", provider->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(branch_name);
|
||||||
config_free(cfg);
|
config_free(cfg);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue