From: Philip Oakley Date: Mon, 06 Jun 2016 16:29:39 GMT Subject: Re: [RFC/PATCH v2] pull: add --set-upstream Message-ID: <2DE0829216C940168DCD804378CD18CC@PhilipOakley> In-Reply-To: <20160606093437.1992-1-erwan.mathoniere@grenoble-inp.org> From: "Erwan Mathoniere" > Implement `git pull [--set-upstream | -u] ` that set > tracking to the remote branch the user just pulled from. > > After successfully pulling from ``, for each `` > described in format `:`, set > `branch..remote` to `` and > `branch..merge` to `refs/heads/`. If > `` lacks `` in the previous format or directly > refers to a branch, use the current branch as `` in the > above configuration setting. > > `git push` has already its `--set-upstream`, it makes sense to have its > symmetrical for `git pull`. > > For a beginner, when trying to use argumentless `git pull` without > tracking information set, advising to use > `git branch --set-upstream-to` to set upstream can be quite confusing. > Using this `git pull --set-upstream` is easier and more natural. > > Signed-off-by: Erwan Mathoniere > Signed-off-by: Jordan De Gea > Signed-off-by: Matthieu Moy > --- > > Changes from v1: > - Code reshaped to : > * warn + no-op when pulling from or to something that isn't a branch > or a configured remote > * set upstream only after successfully merging/rebasing > - More relevant documentation > - Tests reshaped to be more independent from each others > - More tests (tags, detached heads, non-configured remote...) > > > For now, the documentation is quite hard to understand, but I didn't > figure how to explain without using too technical words. Should it stay > as it is or should I write something similar the above commit message? > > Allowing to set non-configured repository as upstream isn't easy to > handle since the type of refspec must be checked and this is done by > verifying the existence of the remote-tracking branch at > `refs/remotes//`. > > > Documentation/git-pull.txt | 18 +++++ > builtin/pull.c | 106 ++++++++++++++++++++++++++++- > t/t5544-pull-upstream.sh | 164 > +++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 285 insertions(+), 3 deletions(-) > create mode 100755 t/t5544-pull-upstream.sh > > diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt > index d033b25..6ae5e58 100644 > --- a/Documentation/git-pull.txt > +++ b/Documentation/git-pull.txt > @@ -93,6 +93,24 @@ OPTIONS > has to be called afterwards to bring the work tree up to date with the > merge result. > > +-u:: > +--set-upstream:: > + After successfully pulling from explicitly given and s/from explicitly/from an explicitly/ > + , set the configuration of the local branches pulled on, so s/branches pulled on/branches that were pulled/ > + that each one tracks the remote branch pulled from. If a configuration > + already exists, it is overwriten. For example, with `git pull -u origin > + branch` the current branch will track `branch` from `origin`. > ++ > +If two or more branches are pulled on the same local branch, only the > last one > +in arguments will be tracked. Is this specific to this pull --setupstream or a general worning ? i.e. that a second entry is created in the config file, or that only the last branch refspec will be added? > ++ > +The given must be a configured remote. Can only set tracking > to > +remote branches (e.g. can't set upstream to remote HEAD). > ++ > +Works symmetrically as `--set-upstream` for linkgit:git-push[1]. Allow > using > +argumentless linkgit:git-pull[1] and other commands. For more > information, see > +`branch..merge` in linkgit:git-config[1]. > + > Options related to merging > ~~~~~~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/builtin/pull.c b/builtin/pull.c [snip]