pull: pass --strategy along to to rebase
PATCH 1/2 pull: pass --strategy along to to rebase
rebase supports --strategy, so pull should pass the option along to it.
---
I noticed the other day that pull didn't pass --strategy along to rebase, but forgot I'd noticed, even though Johannes replied w/a patch. Anyway, my next patch documents pull's usage via its OPTIONS_SPEC and I noticed the problem again. I fix it here so that I can document its use in the next patch. :-)
git-pull.sh | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
git-pull.sh +2 -1
@@ -174,6 +174,7 @@ fi merge_name=$(git fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit test true = "$rebase" && - exec git-rebase --onto $merge_head ${oldremoteref:-$merge_head} + exec git-rebase $strategy_args --onto $merge_head \ + ${oldremoteref:-$merge_head} exec git-merge $no_summary $no_commit $squash $no_ff $strategy_args \ "$merge_name" HEAD $merge_head
Signature · 1 line
1.5.4.2.285.g1e9f
PATCH 2/2 pull: document usage via OPTIONS_SPEC
document usage via OPTIONS_SPEC
--- git-pull.sh | 32 +++++++++++++++++++++++++++++--- 1 files changed, 29 insertions(+), 3 deletions(-)
git-pull.sh +29 -3
@@ -4,10 +4,36 @@ # # Fetch one or more remote refs and merge it/them into the current HEAD. -USAGE='[-n | --no-summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...' -LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.' SUBDIRECTORY_OK=Yes -OPTIONS_SPEC= +OPTIONS_SPEC="\ +git pull [options] [<repo>] [<refspec>] +-- + fetch options +q,quiet make the fetch process less verbose +v,verbose make the fetch process more verbose +a,append append to FETCH_HEAD instead of overwritting +upload-pack=, specify path to git-fetch-pack on remote end +f,force force local branch to be updated by remote branch +t,tags fetch all remote tags +no-tags do not fetch any remote tags +k,keep keep downloaded pack +u,update-head-ok used internally between git pull and git fetch +depth= deep shallow history by specified number of commits + merge options +summary show diffstat at end of merge +n,no-summary do not show diff stat at end of merge +commit commit the result after merging +no-commit do not commit the result after merging +squash update the index and working tree only +no-squash override --squash, perform a normal merge and commit +ff only update branch pointer if merge is a fast-forward +no-ff do a merge commit even if the merge is a fast-forward +s,strategy= use given merge strategy + rebase options +rebase rebase after fetching +no-rebase merge after fetching +s,strategy= use given merge strategy; implies -m to rebase +" . git-sh-setup set_reflog_action "pull $*" require_work_tree
Signature · 1 line
1.5.4.2.285.g1e9f
Re: [PATCH 2/2] pull: document usage via OPTIONS_SPEC
OPTIONS_SPEC is not just for documentation but it actively mucks with the incoming options list.
Have you checked if you did not break the actual parsing?
Re: [PATCH 2/2] pull: document usage via OPTIONS_SPEC
Quoted 4 lines · Junio C Hamano
OPTIONS_SPECis not just for documentation but it actively mucks
with the incoming options list.Have you checked if you did not break the actual parsing?
Duh, no. Sorry. Will do.
j.
PATCH v2 1/1 pull: document usage via OPTIONS_SPEC
In reply to Junio C HamanoReplaced USAGE and LONG_USAGE with OPTIONS_SPEC
---
Okay, I'm pretty sure this is correct now. make test passes, and it also passes my "it looks right" test after having gone over it a few times.
This isn't quite ready for inclusion yet though because I want some feedback:
* There is one semantic change. You can't use "-s=<strategy>" anymore. That's not really proper usage of a short option (it's either "-s<strategy>" or "-s <strategy>"). Is it okay to not accept the "-s=<strategy>" form?
* Is it worth doing this at all? If the plan is to rewrite everything as builtins I kinda feel like I'm wasting my time. If not, I'll work on doing this for all the other scripts which are missing an OPTIONS_SPEC. Then maybe they can all be merged at once?
* You can see I added the GIT_PULL_DEBUG_ARGS blob. Frankly, I can't really think of a good way to test this change other than to do something like that and then add a test for each individual option. But that's going to really bloat the test suite. Is it worth it to do this for every script? Or is passing the existing test suite and enough eyeballs looking at it in next good enough? Can you think of another way to check for regressions?
j.
git-pull.sh | 94 ++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 61 insertions(+), 33 deletions(-)
git-pull.sh +61 -33
@@ -4,10 +4,36 @@ # # Fetch one or more remote refs and merge it/them into the current HEAD. -USAGE='[-n | --no-summary] [--[no-]commit] [--[no-]squash] [--[no-]ff] [-s strategy]... [<fetch-options>] <repo> <head>...' -LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEAD.' SUBDIRECTORY_OK=Yes -OPTIONS_SPEC= +OPTIONS_SPEC="\ +git pull [options] [<repo>] [<refspec>] +-- + fetch options +q,quiet make the fetch process less verbose +v,verbose make the fetch process more verbose +a,append append to FETCH_HEAD instead of overwritting +upload-pack=, specify path to git-fetch-pack on remote end +f,force force local branch to be updated by remote branch +t,tags fetch all remote tags +no-tags do not fetch any remote tags +k,keep keep downloaded pack +u,update-head-ok used internally between git pull and git fetch +depth= deep shallow history by specified number of commits + merge options +summary show diffstat at end of merge +n,no-summary do not show diff stat at end of merge +commit commit the result after merging +no-commit do not commit the result after merging +squash update the index and working tree only +no-squash override --squash, perform a normal merge and commit +ff only update branch pointer if merge is a fast-forward +no-ff do a merge commit even if the merge is a fast-forward +s,strategy= use given merge strategy + rebase options +rebase rebase after fetching +no-rebase merge after fetching +s,strategy= use given merge strategy; implies -m to rebase +" . git-sh-setup set_reflog_action "pull $*" require_work_tree
@@ -23,46 +49,33 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase) while : do case "$1" in - -n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\ - --no-summa|--no-summar|--no-summary) + -n|--no-summary) no_summary=-n ;; --summary) - no_summary=$1 - ;; - --no-c|--no-co|--no-com|--no-comm|--no-commi|--no-commit) + no_summary=$1 ;; + --no-commit) no_commit=--no-commit ;; - --c|--co|--com|--comm|--commi|--commit) + --commit) no_commit=--commit ;; - --sq|--squ|--squa|--squas|--squash) + --squash) squash=--squash ;; - --no-sq|--no-squ|--no-squa|--no-squas|--no-squash) + --no-squash) squash=--no-squash ;; --ff) no_ff=--ff ;; --no-ff) no_ff=--no-ff ;; - -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\ - --strateg=*|--strategy=*|\ - -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy) - case "$#,$1" in - *,*=*) - strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;; - 1,*) - usage ;; - *) - strategy="$2" - shift ;; - esac - strategy_args="${strategy_args}-s $strategy " - ;; - -r|--r|--re|--reb|--reba|--rebas|--rebase) - rebase=true - ;; - --no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase) - rebase=false + -s|--strategy) + shift + strategy_args="${strategy_args}-s $1 " ;; - -h|--h|--he|--hel|--help) - usage + -r|--rebase) + rebase=true ;; + --no-rebase) + rebase=false ;; + --) + shift + break ;; *) # Pass thru anything that may be meant for fetch.
@@ -72,12 +85,27 @@ do shift done +test '' != "$GIT_PULL_DEBUG_ARGS" && { + exec >&2 + for var in strategy_args no_summary no_commit squash no_ff rebase + do + echo "$var='$(eval echo "\$$var")'" + done + argnum=1 + for opt + do + echo "$argnum='$opt'" + argnum=$(($argnum + 1)) + done + exit 0 +} + error_on_no_merge_candidates () { exec >&2 for opt do case "$opt" in - -t|--t|--ta|--tag|--tags) + -t|--tags) echo "Fetching tags only, you probably meant:" echo " git fetch --tags" exit 1
Signature · 1 line
1.5.4.3.345.g651f8
Re: [PATCH v2] pull: document usage via OPTIONS_SPEC
Quoted 3 lines · Jay Soffian
* There is one semantic change. You can't use "-s=<strategy>" anymore. That's not really proper usage of a short option (it's either "-s<strategy>" or "-s <strategy>"). Is it okay to not accept the "-s=<strategy>" form?
Well, with my maintainer hat on, I must resist _any_ change ;-). Personally I would not mind this. It is a borderline between regression and making the option parameters more consistent.
Quoted 2 lines
* Is it worth doing this at all? If the plan is to rewrite everything as builtins I kinda feel like I'm wasting my time.
If a contributor feels wasting his time, what should reviewers feel reviewing such patches ;-)?
Quoted 3 lines
* You can see I added the
GIT_PULL_DEBUG_ARGSblob. Frankly, I can't really think of a good way to test this change other than to do something like that and then add a test for each individual option.
I see this would be useful while you are developing. But the testsuite is meant to check the behaviour that is externally observable. It does not matter if you change the way you internally represent --verbose option from settting $verbose to resetting $quiet, but tests based on GIT_PULL_DEBUG_ARGS would notice the difference in the implementation detail, so I do not see much point leaving this in; it would not be useful for test scripts, I suspect.
git-pull.sh line 17
Quoted 9 lines
git-pull.sh +9
-0+git pull [options] [<repo>] [<refspec>] +-- + fetch options +q,quiet make the fetch process less verbose +v,verbose make the fetch process more verbose +a,append append to FETCH_HEAD instead of overwritting +upload-pack=, specify path to git-fetch-pack on remote end +f,force force local branch to be updated by remote branch +t,tags fetch all remote tags
While it is technically correct that you _can_ feed any option meant for git-fetch to this command, some options do not make any sense in the context of git-pull, and we should not advertise them, or better yet, actively reject them if you can.
I think --tags is one of them.
Quoted 11 lines
. git-sh-setup
set_reflog_action"pull $*"
require_work_treegit-pull.sh +0
-0@@ -23,46 +49,33 @@ rebase=$(git config --bool branch.$curr_branch_short.rebase) while : do case "$1" in ;; *) # Pass thru anything that may be meant for fetch.
Quoted 1 line
break
Because the loop breaks here, the option description above should mention that options meant for fetch should come after all the options you want to give to git-pull itself. For example, I do not think "git pull -q -s stupid $there $that" is meant to work.
A better long-term alternative would be to lift that restriction.
I do not recall offhand but does the parse-options reorder the options in any way? If that is the case, it makes the above not a long-term thing but a must-be-done in a patch that starts to use parse-options.
Re: [PATCH v2] pull: document usage via OPTIONS_SPEC
Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Jay Soffian
* There is one semantic change. You can't use "-s=<strategy>" anymore. That's not really proper usage of a short option (it's either "-s<strategy>" or "-s <strategy>"). Is it okay to not accept the "-s=<strategy>" form?
Well, with my maintainer hat on, I must resist _any_ change ;-). Personally I would not mind this. It is a borderline between regression and making the option parameters more consistent.
My reasoning was that were the script converted to a built-in, the -s= behavior would not likely be maintained (or even noticed...). And that form certainly isn't documented. I think it was an accident that it ever worked.
Quoted 2 lines
If a contributor feels wasting his time, what should reviewers feel reviewing such patches ;-)?
I get the smiley, but let me rephrase: is there a long term goal to replace all shell scripts with builtins?
And to answer your rhetorical question, reviewers should feel appreciated, because they are.
Quoted 4 lines
While it is technically correct that you _can_ feed any option meant for git-fetch to this command, some options do not make any sense in the context of git-pull, and we should not advertise them, or better yet, actively reject them if you can.
Well then we have a documentation issue then, because it was from the git pull docs that I wrote the option spec. So I suppose this patch should include a documentation cleanup at the same time.
Quoted 7 lines
Because the loop breaks here, the option description above should mention that options meant for fetch should come after all the options you want to give to git-pull itself. For example, I do not think "git pull -q -s stupid $there $that" is meant to work.
A better long-term alternative would be to lift that restriction.
Sigh, nothing is ever as simple as it seems. And here I was just trying to improve the usage statement. :-(
Quoted 4 lines
I do not recall offhand but does the parse-options reorder the options in any way? If that is the case, it makes the above not a long-term thing but a must-be-done in a patch that starts to use parse-options.
I don't think it does.
Back to the drawing board...
j.