Skip to contentSkip to conversation

git pull --upload-pack reversion in git 2.5.0

PATCH In review Joey Hess 5 participants 8 messages Jun 15, 2016

lore
Share & tools
lore

Joey Hess

author
#0 lore raw

In git 2.1.4, I can run: git pull --upload-pack 'echo --foo'

This also seems to work in 2.4.6, but in 2.5.0, the option parser does something weird, apparently looking inside the quoted parameter and parsing parameters in there:

error: unknown option `foo'
usage: git fetch [<options>] [<repository> [<refspec>...]]

Needless to say, this broke my use of --upload-pack.

Signature · 1 line
see shy jo
#1 lore raw
Quoted 8 lines · Joey Hess

In git 2.1.4, I can run: git pull --upload-pack 'echo --foo'

This also seems to work in 2.4.6, but in 2.5.0, the option parser does something weird, apparently looking inside the quoted parameter and parsing parameters in there:

error: unknown option `foo'
usage: git fetch [<options>] [<repository> [<refspec>...]]

This bisects down to:

commit e3b601da2af53cbb9a63e59113d524a8d946ea12 (junio/pt/pull-optparse)

Author: Paul Tan <[email protected]>
Date:   Tue Jun 2 22:22:53 2015 +0800

pull: use git-rev-parse --parseopt for option parsing

To enable unambiguous parsing of abbreviated options, bundled short options, separate form options and to provide consistent usage help, use git-rev-parse --parseopt for option parsing. With this, simplify the option parsing code.

=> Cc-ing Paul.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
author
#2 lore raw

I think this comes down to a lack of quoting where git-pull runs git-fetch. Before eb2a8d9ed3fca2ba2f617b704992d483605f3bb6, "$@" was passed through to git-fetch, but now there is a $upload_pack which is passed without being quoted.

Signature · 1 line
see shy jo
#3 lore raw
Quoted 4 lines · Joey Hess

I think this comes down to a lack of quoting where git-pull runs git-fetch. Before eb2a8d9ed3fca2ba2f617b704992d483605f3bb6, "$@" was passed through to git-fetch, but now there is a $upload_pack which is passed without being quoted.

Yes, it is not just the matter of using "$upload_pack", though ;-)

${upload_pack+"$upload_pack"} or something.

#4 lore raw

PATCH 1/1 pull.sh: quote $upload_pack when passing it to git-fetch

The previous code broke for example

  git pull --upload-pack 'echo --foo'

---

Quoted 1 line · Junio

${upload_pack+"$upload_pack"} or something.

Indeed, we need to pass nothing, not the empty string if $upload_pack is not defined.

This should fix it.

 git-pull.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-pull.sh +1 -1
index a814bf6..26c5e9f 100755
@@ -295,7 +295,7 @@ test true = "$rebase" && {
 }
 orig_head=$(git rev-parse -q --verify HEAD)
 git fetch $verbosity $progress $dry_run $recurse_submodules $all $append \
-$upload_pack $force $tags $prune $keep $depth $unshallow $update_shallow \
+${upload_pack+"$upload_pack"} $force $tags $prune $keep $depth $unshallow $update_shallow \
 $refmap --update-head-ok "$@" || exit 1
 test -z "$dry_run" || exit 0
 
Signature · 1 line
2.5.0.rc0.7.ge1edd74.dirty
#6 lore raw

Re: [PATCH] pull.sh: quote $upload_pack when passing it to git-fetch

In reply to Matthieu Moy
Quoted 7 lines · Matthieu Moy

The previous code broke for example

  git pull --upload-pack 'echo --foo'
Quoted 8 lines

---

Quoted 1 line · Junio

${upload_pack+"$upload_pack"} or something.

Indeed, we need to pass nothing, not the empty string if $upload_pack is not defined.

This should fix it.

The problematic commit touches a lot more than upload-pack, but all others that take user-supplied strings are meant for "git merge" or "git rebase" that are properly quoted and then eval'ed, so this should be sufficient.

Thanks.

Quoted 17 lines
 git-pull.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-pull.sh +1 -1
index a814bf6..26c5e9f 100755
@@ -295,7 +295,7 @@ test true = "$rebase" && {
 }
 orig_head=$(git rev-parse -q --verify HEAD)
 git fetch $verbosity $progress $dry_run $recurse_submodules $all $append \
-$upload_pack $force $tags $prune $keep $depth $unshallow $update_shallow \
+${upload_pack+"$upload_pack"} $force $tags $prune $keep $depth
 $unshallow $update_shallow \
 $refmap --update-head-ok "$@" || exit 1
 test -z "$dry_run" || exit 0
#7 lore raw
In reply to Junio C Hamano
Quoted 9 lines · Junio C Hamano
Quoted 4 lines · Joey Hess

I think this comes down to a lack of quoting where git-pull runs git-fetch. Before eb2a8d9ed3fca2ba2f617b704992d483605f3bb6, "$@" was passed through to git-fetch, but now there is a $upload_pack which is passed without being quoted.

Yes, it is not just the matter of using "$upload_pack", though ;-)

${upload_pack+"$upload_pack"} or something.

Thanks for a bug report.

The next time, I'd appreciate if these regressions are caught before it hits the tagged release, during the pre-release -rc period at the latest, but preferrably earlier. I'm greedy and expect far more from those who are known to be competent heavy Git users than from "I update every few releases" casual folks ;-)

Thanks, anyway.