git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Question] builtin/branch.c
@ 2018-10-13  8:11 Tao Qingyun
  2018-10-14 10:19 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 8+ messages in thread
From: Tao Qingyun @ 2018-10-13  8:11 UTC (permalink / raw)
  To: git

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);



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-10-17 12:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-13  8:11 [Question] builtin/branch.c Tao Qingyun
2018-10-14 10:19 ` Ævar Arnfjörð Bjarmason
2018-10-15 14:08   ` [PATCH] builtin/branch.c: remove useless branch_get Tao Qingyun
2018-10-15 17:17     ` Jeff King
2018-10-16 14:54       ` [PATCH v2] " Tao Qingyun
2018-10-17  8:39         ` Jeff King
2018-10-17 12:58           ` Tao Qingyun
2018-10-15 17:14   ` [Question] builtin/branch.c Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).