threads / bug / 25941

BUG: git pull --rebase on detatched head prints a lot of usage warnings

Subject: BUG: git pull --rebase on detatched head prints a lot of usage warnings

## tl;dr

8 messages between Dec 3, 2010 and Dec 3, 2010.

replies: 7people: 4as markdown or json

Sverre Rabbelier· Dec 3, 2010, 18:38 UTC · lore
Heya,
sverre@laptop-sverre:~/code/Melange
$ git pull --rebase
usage: git merge-base [-a|--all] [--octopus] <commit> <commit>...
   or: git merge-base --independent <commit>...
    -a, --all             output all common ancestors
    --octopus             find ancestors for a single n-way merge
    --independent         list revs not reachable from others
usage: git merge-base [-a|--all] [--octopus] <commit> <commit>...
   or: git merge-base --independent <commit>...
    -a, --all             output all common ancestors
    --octopus             find ancestors for a single n-way merge
    --independent         list revs not reachable from others
usage: git merge-base [-a|--all] [--octopus] <commit> <commit>...
   or: git merge-base --independent <commit>...
    -a, --all             output all common ancestors
    --octopus             find ancestors for a single n-way merge
    --independent         list revs not reachable from others
[... many more snipped ...]

You are not currently on a branch, so I cannot use any 'branch.<branchname>.merge' in your configuration file. Please specify which remote branch you want to use on the command line and try again (e.g. 'git pull <repository> <refspec>'). See git-pull(1) for details.

There are 127 helpful messages in total.
Output with GIT_TRACE set:

trace: exec: 'git-pull' '--rebase' trace: run_command: 'git-pull' '--rebase' trace: built-in: git 'rev-parse' '--git-dir' trace: built-in: git 'rev-parse' '--is-inside-work-tree' trace: built-in: git 'rev-parse' '--show-toplevel' trace: built-in: git 'ls-files' '-u' trace: built-in: git 'symbolic-ref' '-q' 'HEAD' trace: built-in: git 'config' '--bool' 'branch..rebase' trace: built-in: git 'rev-parse' '-q' '--verify' 'HEAD' trace: built-in: git 'rev-parse' '--verify' 'HEAD' trace: built-in: git 'update-index' '-q' '--ignore-submodules' '--refresh' trace: built-in: git 'diff-files' '--quiet' '--ignore-submodules' trace: built-in: git 'diff-index' '--cached' '--quiet' '--ignore-submodules' 'HEAD' '--' trace: built-in: git 'rev-parse' '-q' '--git-dir' trace: built-in: git 'symbolic-ref' '-q' 'HEAD' trace: built-in: git 'config' '--get' 'branch..remote' trace: built-in: git 'symbolic-ref' '-q' 'HEAD' trace: built-in: git 'for-each-ref' '--format=%(upstream)' trace: built-in: git 'rev-parse' '-q' '--verify' 'refs/remotes/origin/tip' trace: built-in: git 'rev-list' '-g' 'refs/remotes/origin/tip' trace: built-in: git 'merge-base' '927b640697cf707a8d3d26b39c926be052c3aa7c' trace: built-in: git 'merge-base' '8281385d7b5132a51ae1f3ad515f0220478c7f40'

Tested on current next.
-- 
Cheers,

Sverre Rabbelier
Jonathan Nieder· Dec 3, 2010, 19:00 UTC · re: Sverre Rabbelier · lore

Re: BUG: git pull --rebase on detatched head prints a lot of usage warnings

Sverre Rabbelier wrote:
> $ git pull --rebase
> usage: git merge-base [-a|--all] [--octopus] <commit> <commit>...
[...]
Show 10 quoted lines
> [... many more snipped ...]
>
> You are not currently on a branch, so I cannot use any
> 'branch.<branchname>.merge' in your configuration file.
> Please specify which remote branch you want to use on the command
> line and try again (e.g. 'git pull <repository> <refspec>').
> See git-pull(1) for details.
>
>
> There are 127 helpful messages in total.
Does the following take care of it?

cc-ing Santi, author of the very nice v1.6.4.1~6^2 (pull: support rebased upstream + fetch + pull --rebase, 2009-07-19). Maybe we should make merge-base more tolerant.

diff --git a/git-pull.sh b/git-pull.sh
index 8eb74d4..bbc369d 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -212,7 +212,7 @@ test true = "$rebase" && {
 	oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&
 	for reflog in $(git rev-list -g $remoteref 2>/dev/null)
 	do
-		if test "$reflog" = "$(git merge-base $reflog $curr_branch)"
+		if test "$reflog" = "$(git show-branch --merge-base $reflog $curr_branch)"
 		then
 			oldremoteref="$reflog"
 			break
Sverre Rabbelier· Dec 3, 2010, 19:05 UTC · re: Jonathan Nieder · lore

Re: BUG: git pull --rebase on detatched head prints a lot of usage warnings

Heya,
On Fri, Dec 3, 2010 at 20:00, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Does the following take care of it?
Yes.
Tested-by: Sverre Rabbelier <srabbelier@gmail.com>
-- 
Cheers,

Sverre Rabbelier
Santi Béjar· Dec 3, 2010, 20:23 UTC · re: Sverre Rabbelier · lore

Re: BUG: git pull --rebase on detatched head prints a lot of usage warnings

On Fri, Dec 3, 2010 at 8:05 PM, Sverre Rabbelier <srabbelier@gmail.com> wrote:
Show 6 quoted lines
> Heya,
>
> On Fri, Dec 3, 2010 at 20:00, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> Does the following take care of it?
>
> Yes.

I also think it fixes, but I wonder if it's the best fix. One thing is that show-branch is an ancillary command, and not a plumbing command (but there is already a call to show-branch, but it should probably be change to merge-base now that it handles three commit as arguments).

The problem is that many parts of git-pull.sh/git-parse-remote.sh assume that you are not in a detached HEAD. Can you confirm that the following patch fixes it?

diff --git i/git-parse-remote.sh w/git-parse-remote.sh
index 5f47b18..6d0a5de 100644
--- i/git-parse-remote.sh
+++ w/git-parse-remote.sh
@@ -68,7 +68,7 @@ get_remote_merge_branch () {
            test -z "$origin" && origin=$default
            curr_branch=$(git symbolic-ref -q HEAD)
            [ "$origin" = "$default" ] &&
-           echo $(git for-each-ref --format='%(upstream)' $curr_branch)
+           echo $(git for-each-ref --format='%(upstream)' HEAD)
            ;;
        *)
            repo=$1

I'm wondering if most of $curr_branch should be changed to HEAD, I'll check it.

HTH,
Santi
Sverre Rabbelier· Dec 3, 2010, 20:45 UTC · re: Santi Béjar · lore

Re: BUG: git pull --rebase on detatched head prints a lot of usage warnings

Heya,
On Fri, Dec 3, 2010 at 21:23, Santi Béjar <santi@agolina.net> wrote:
> The problem is that many parts of git-pull.sh/git-parse-remote.sh
> assume that you are not in a detached HEAD. Can you confirm that the
> following patch fixes it?
Yes.
Tested-by: Sverre Rabbelier <srabbelier@gmail.com>
-- 
Cheers,

Sverre Rabbelier
Junio C Hamano· Dec 3, 2010, 21:06 UTC · re: Santi Béjar · lore

Re: BUG: git pull --rebase on detatched head prints a lot of usage warnings

Santi Béjar <santi@agolina.net> writes:
> I also think it fixes, but I wonder if it's the best fix. One thing is
> that show-branch is an ancillary command, and not a plumbing command
> (but there is already a call to show-branch, but it should probably be
> change to merge-base now that it handles three commit as arguments).

Are you sure "show-branch --merge-base A B C" and "merge-base A B C" are meant to compute the same thing?

I do not think ancillary necessarily means Porcelain, but that is a separate issue.

Santi Béjar· Dec 3, 2010, 22:16 UTC · re: Junio C Hamano · lore

Re: BUG: git pull --rebase on detatched head prints a lot of usage warnings

On Fri, Dec 3, 2010 at 10:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> Santi Béjar <santi@agolina.net> writes:
>
>> I also think it fixes, but I wonder if it's the best fix. One thing is
>> that show-branch is an ancillary command, and not a plumbing command
>> (but there is already a call to show-branch, but it should probably be
>> change to merge-base now that it handles three commit as arguments).
>
> Are you sure "show-branch --merge-base A B C" and "merge-base A B C" are
> meant to compute the same thing?

No, I'm not sure. In fact the documentation explicit says that they are different. But I fail to see when it matters, and more specifically (now that I've reread the docs), what is the point of "merge-base A B C".

Just a data point, show-branch --merge-base is only used once in the code, in git-pull.sh, but "git merge-base A B C" is not used (at least using my grep).

Or the equivalent is the undocumented "git merge-base --octopus A B C"?
>
> I do not think ancillary necessarily means Porcelain, but that is a
> separate issue.

Me neither. But is the promise to not change the behavior/output as hard as with plumbing?

Santi
Junio C Hamano· Dec 3, 2010, 22:31 UTC · re: Santi Béjar · lore

Re: BUG: git pull --rebase on detatched head prints a lot of usage warnings

Santi Béjar <santi@agolina.net> writes:
> No, I'm not sure. In fact the documentation explicit says that they
> are different. But I fail to see when it matters, and more
> specifically (now that I've reread the docs), what is the point of
> "merge-base A B C".

See c5dc9a2 (git-merge-octopus: use (merge-base A (merge B C D E...)) for stepwise merge, 2008-07-27), not the patch but the explanation.

> Just a data point, show-branch --merge-base is only used once in the
> code, in git-pull.sh, but "git merge-base A B C" is not used (at least
> using my grep).

Your grep skill needs honing ;-) The variable MRC in git-merge-octopus is a space separated list of commit object names, split at $IFS when merge-base is called.

← back to recent threads