Hi, I am learning `builtin/branch.c`. I find that it will call `branch_get`
before create and [un]set upstream, and die with "no such branch" if failed.
but `branch_get` seems never fail, it is a get_or_create. Also, it was
confused that getting a branch before it has created.

builtin/branch.c #811

    } else if (argc > 0 && argc <= 2) {
        struct branch *branch = branch_get(argv[0]);

        if (!branch)
            die(_("no such branch '%s'"), argv[0]);

        if (filter.kind != FILTER_REFS_BRANCHES)
            die(_("-a and -r options to 'git branch' do not make sense with a 
branch name"));

        if (track == BRANCH_TRACK_OVERRIDE)
            die(_("the '--set-upstream' option is no longer supported. Please 
use '--track' or '--set-upstream-to' instead."));

        create_branch(argv[0], (argc == 2) ? argv[1] : head,
                  force, 0, reflog, quiet, track);


Reply via email to