commit d3f84d51c4443f621486b49558aa86b4e5c45a04 from: Stefan Sperling date: Thu Jul 11 19:12:49 2019 UTC catch and prevent 'got branch -'; I've done this often enough now... commit - ba882ee388d95f88eb3e54d3ccd2b07e736e5190 commit + d3f84d51c4443f621486b49558aa86b4e5c45a04 blob - 60dad83c94dc3446dd85735658c86d79a896a26c blob + b141b0331a9ba966ddf63bb4ed602a7e9504f412 --- got/got.c +++ got/got.c @@ -2284,6 +2284,14 @@ add_branch(struct got_repository *repo, const char *br struct got_reference *ref = NULL; char *base_refname = NULL, *refname = NULL; struct got_reference *base_ref; + + /* + * Don't let the user create a branch named '-'. + * While technically a valid reference name, this case is usually + * an unintended typo. + */ + if (branch_name[0] == '-' && branch_name[1] == '\0') + return got_error(GOT_ERR_BAD_REF_NAME); if (strcmp(GOT_REF_HEAD, base_branch) == 0) { base_refname = strdup(GOT_REF_HEAD);