Skip to content

Commit 78c6e0f

Browse files
committed
Merge branch 'mz/rebase'
* mz/rebase: (34 commits) rebase: define options in OPTIONS_SPEC Makefile: do not install sourced rebase scripts rebase: use @{upstream} if no upstream specified rebase -i: remove unnecessary state rebase-root rebase -i: don't read unused variable preserve_merges git-rebase--am: remove unnecessary --3way option rebase -m: don't print exit code 2 when merge fails rebase -m: remember allow_rerere_autoupdate option rebase: remember strategy and strategy options rebase: remember verbose option rebase: extract code for writing basic state rebase: factor out sub command handling rebase: make -v a tiny bit more verbose rebase -i: align variable names rebase: show consistent conflict resolution hint rebase: extract am code to new source file rebase: extract merge code to new source file rebase: remove $branch as synonym for $orig_head rebase -i: support --stat rebase: factor out call to pre-rebase hook ...
2 parents ac9666f + 45e2acf commit 78c6e0f

14 files changed

+844
-868
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@
101101
/git-quiltimport
102102
/git-read-tree
103103
/git-rebase
104+
/git-rebase--am
104105
/git-rebase--interactive
106+
/git-rebase--merge
105107
/git-receive-pack
106108
/git-reflog
107109
/git-relink

Documentation/config.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ branch.<name>.remote::
641641

642642
branch.<name>.merge::
643643
Defines, together with branch.<name>.remote, the upstream branch
644-
for the given branch. It tells 'git fetch'/'git pull' which
644+
for the given branch. It tells 'git fetch'/'git pull'/'git rebase' which
645645
branch to merge and can also affect 'git push' (see push.default).
646646
When in branch <name>, it tells 'git fetch' the default
647647
refspec to be marked for merging in FETCH_HEAD. The value is

Documentation/git-rebase.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git rebase' [-i | --interactive] [options] [--onto <newbase>]
12-
<upstream> [<branch>]
12+
[<upstream>] [<branch>]
1313
'git rebase' [-i | --interactive] [options] --onto <newbase>
1414
--root [<branch>]
1515

@@ -21,6 +21,12 @@ If <branch> is specified, 'git rebase' will perform an automatic
2121
`git checkout <branch>` before doing anything else. Otherwise
2222
it remains on the current branch.
2323

24+
If <upstream> is not specified, the upstream configured in
25+
branch.<name>.remote and branch.<name>.merge options will be used; see
26+
linkgit:git-config[1] for details. If you are currently not on any
27+
branch or if the current branch does not have a configured upstream,
28+
the rebase will abort.
29+
2430
All changes made by commits in the current branch but that are not
2531
in <upstream> are saved to a temporary area. This is the same set
2632
of commits that would be shown by `git log <upstream>..HEAD` (or
@@ -217,7 +223,8 @@ leave out at most one of A and B, in which case it defaults to HEAD.
217223

218224
<upstream>::
219225
Upstream branch to compare against. May be any valid commit,
220-
not just an existing branch name.
226+
not just an existing branch name. Defaults to the configured
227+
upstream for the current branch.
221228

222229
<branch>::
223230
Working branch; defaults to HEAD.

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ SCRIPT_SH += git-merge-resolve.sh
368368
SCRIPT_SH += git-mergetool.sh
369369
SCRIPT_SH += git-pull.sh
370370
SCRIPT_SH += git-quiltimport.sh
371-
SCRIPT_SH += git-rebase--interactive.sh
372371
SCRIPT_SH += git-rebase.sh
373372
SCRIPT_SH += git-repack.sh
374373
SCRIPT_SH += git-request-pull.sh
@@ -378,6 +377,9 @@ SCRIPT_SH += git-web--browse.sh
378377

379378
SCRIPT_LIB += git-mergetool--lib
380379
SCRIPT_LIB += git-parse-remote
380+
SCRIPT_LIB += git-rebase--am
381+
SCRIPT_LIB += git-rebase--interactive
382+
SCRIPT_LIB += git-rebase--merge
381383
SCRIPT_LIB += git-sh-setup
382384

383385
SCRIPT_PERL += git-add--interactive.perl

git-parse-remote.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,41 @@ get_remote_merge_branch () {
5050
esac
5151
esac
5252
}
53+
54+
error_on_missing_default_upstream () {
55+
cmd="$1"
56+
op_type="$2"
57+
op_prep="$3"
58+
example="$4"
59+
branch_name=$(git symbolic-ref -q HEAD)
60+
if test -z "$branch_name"
61+
then
62+
echo "You are not currently on a branch, so I cannot use any
63+
'branch.<branchname>.merge' in your configuration file.
64+
Please specify which branch you want to $op_type $op_prep on the command
65+
line and try again (e.g. '$example').
66+
See git-${cmd}(1) for details."
67+
else
68+
echo "You asked me to $cmd without telling me which branch you
69+
want to $op_type $op_prep, and 'branch.${branch_name#refs/heads/}.merge' in
70+
your configuration file does not tell me, either. Please
71+
specify which branch you want to use on the command line and
72+
try again (e.g. '$example').
73+
See git-${cmd}(1) for details.
74+
75+
If you often $op_type $op_prep the same branch, you may want to
76+
use something like the following in your configuration file:
77+
[branch \"${branch_name#refs/heads/}\"]
78+
remote = <nickname>
79+
merge = <remote-ref>"
80+
test rebase = "$op_type" &&
81+
echo " rebase = true"
82+
echo "
83+
[remote \"<nickname>\"]
84+
url = <url>
85+
fetch = <refspec>
86+
87+
See git-config(1) for details."
88+
fi
89+
exit 1
90+
}

git-pull.sh

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -168,34 +168,10 @@ error_on_no_merge_candidates () {
168168
echo "You asked to pull from the remote '$1', but did not specify"
169169
echo "a branch. Because this is not the default configured remote"
170170
echo "for your current branch, you must specify a branch on the command line."
171-
elif [ -z "$curr_branch" ]; then
172-
echo "You are not currently on a branch, so I cannot use any"
173-
echo "'branch.<branchname>.merge' in your configuration file."
174-
echo "Please specify which remote branch you want to use on the command"
175-
echo "line and try again (e.g. 'git pull <repository> <refspec>')."
176-
echo "See git-pull(1) for details."
177-
elif [ -z "$upstream" ]; then
178-
echo "You asked me to pull without telling me which branch you"
179-
echo "want to $op_type $op_prep, and 'branch.${curr_branch}.merge' in"
180-
echo "your configuration file does not tell me, either. Please"
181-
echo "specify which branch you want to use on the command line and"
182-
echo "try again (e.g. 'git pull <repository> <refspec>')."
183-
echo "See git-pull(1) for details."
184-
echo
185-
echo "If you often $op_type $op_prep the same branch, you may want to"
186-
echo "use something like the following in your configuration file:"
187-
echo
188-
echo " [branch \"${curr_branch}\"]"
189-
echo " remote = <nickname>"
190-
echo " merge = <remote-ref>"
191-
test rebase = "$op_type" &&
192-
echo " rebase = true"
193-
echo
194-
echo " [remote \"<nickname>\"]"
195-
echo " url = <url>"
196-
echo " fetch = <refspec>"
197-
echo
198-
echo "See git-config(1) for details."
171+
elif [ -z "$curr_branch" -o -z "$upstream" ]; then
172+
. git-parse-remote
173+
error_on_missing_default_upstream "pull" $op_type $op_prep \
174+
"git pull <repository> <refspec>"
199175
else
200176
echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
201177
echo "from the remote, but no such ref was fetched."

git-rebase--am.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2010 Junio C Hamano.
4+
#
5+
6+
. git-sh-setup
7+
8+
case "$action" in
9+
continue)
10+
git am --resolved --resolvemsg="$resolvemsg" &&
11+
move_to_original_branch
12+
exit
13+
;;
14+
skip)
15+
git am --skip --resolvemsg="$resolvemsg" &&
16+
move_to_original_branch
17+
exit
18+
;;
19+
esac
20+
21+
test -n "$rebase_root" && root_flag=--root
22+
23+
git format-patch -k --stdout --full-index --ignore-if-in-upstream \
24+
--src-prefix=a/ --dst-prefix=b/ \
25+
--no-renames $root_flag "$revisions" |
26+
git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" &&
27+
move_to_original_branch
28+
ret=$?
29+
test 0 != $ret -a -d "$state_dir" && write_basic_state
30+
exit $ret

0 commit comments

Comments
 (0)