mirror of
https://github.com/xHyroM/gimi.git
synced 2024-11-09 10:18: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;
|
||||
}
|
||||
|
||||
char *branch = fgets(output, sizeof(output), file_ptr);
|
||||
if (branch != NULL) {
|
||||
// remove new line
|
||||
size_t len = strlen(branch);
|
||||
if (len > 0 && branch[len - 1] == '\n') {
|
||||
branch[len - 1] = '\0';
|
||||
}
|
||||
if (fgets(output, sizeof(output), file_ptr) == NULL) {
|
||||
pclose(file_ptr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// remove new line
|
||||
size_t len = strlen(output);
|
||||
if (len > 0 && output[len - 1] == '\n') {
|
||||
output[len - 1] = '\0';
|
||||
}
|
||||
|
||||
pclose(file_ptr);
|
||||
|
||||
return branch;
|
||||
return strdup(output);
|
||||
}
|
||||
|
||||
|
||||
int git_push(char *provider_name, char *branch_name, int options) {
|
||||
FILE *file_ptr;
|
||||
char output[1024];
|
||||
|
@ -97,6 +100,7 @@ int cli_command_push(int argc, char **argv) {
|
|||
printf("info: successfully pushed into '%s'.\n", provider->name);
|
||||
}
|
||||
|
||||
free(branch_name);
|
||||
config_free(cfg);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue