diff options
author | Glen Choo <chooglen@google.com> | 2022-01-28 16:04:41 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-01 14:18:32 -0800 |
commit | e89f151db13684924feb0cd0a0ca3a13c1d71516 (patch) | |
tree | 4da091d2e684dca32e6711f3a508453380cd194c /builtin/branch.c | |
parent | 09e0be130d83ceedb3653d9a41768c6a13457ac5 (diff) | |
download | git-e89f151db13684924feb0cd0a0ca3a13c1d71516.tar.gz |
branch: move --set-upstream-to behavior to dwim_and_setup_tracking()
This commit is preparation for a future commit that will simplify
create_branch() so that it always creates a branch. This will allow
create_branch() to accept a dry_run parameter (which is needed for "git
branch --recurse-submodules").
create_branch() used to always create a branch, but 4fc5006676 (Add
branch --set-upstream, 2010-01-18) changed it to also be able to set
tracking information without creating a branch.
Refactor the code that sets tracking information into its own functions
dwim_branch_start() and dwim_and_setup_tracking(). Also change an
invocation of create_branch() in cmd_branch() in builtin/branch.c to use
dwim_and_setup_tracking(), since that invocation is only for setting
tracking information (in "git branch --set-upstream-to").
As of this commit, create_branch() is no longer invoked in a way that
does not create branches.
Helped-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Glen Choo <chooglen@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/branch.c')
-rw-r--r-- | builtin/branch.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index a77c4ad7ba..676825242a 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -823,12 +823,9 @@ int cmd_branch(int argc, const char **argv, const char *prefix) if (!ref_exists(branch->refname)) die(_("branch '%s' does not exist"), branch->name); - /* - * create_branch takes care of setting up the tracking - * info and making sure new_upstream is correct - */ - create_branch(the_repository, branch->name, new_upstream, - 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE); + dwim_and_setup_tracking(the_repository, branch->name, + new_upstream, BRANCH_TRACK_OVERRIDE, + quiet); } else if (unset_upstream) { struct branch *branch = branch_get(argv[0]); struct strbuf buf = STRBUF_INIT; |