Skip to content

Commit 9b752a6

Browse files
sbeyergitster
authored andcommitted
Improve error output of git-rebase
"git rebase" without arguments on initial startup showed: fatal: Needed a single revision invalid upstream This patch makes it show the ordinary usage string. If .git/rebase-merge or .git/rebase-apply/rebasing exists, git-rebase will die with a message saying that a rebase is in progress and the user should try --skip/--abort/--continue. If .git/rebase-apply/applying exists, git-rebase will die with a message saying that git-am is in progress, regardless how many arguments are given. If no arguments are given and .git/rebase-apply/ exists, but neither a rebasing nor applying file is in that directory, git-rebase dies with a message saying that rebase-apply exists and no arguments were given. Signed-off-by: Stephan Beyer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 20a55f4 commit 9b752a6

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

git-rebase.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,19 @@ is_interactive () {
144144
done && test -n "$1"
145145
}
146146

147+
test -f "$GIT_DIR"/rebase-apply/applying &&
148+
die 'It looks like git-am is in progress. Cannot rebase.'
149+
147150
is_interactive "$@" && exec git-rebase--interactive "$@"
148151

152+
if test $# -eq 0
153+
then
154+
test -d "$dotest" -o -d "$GIT_DIR"/rebase-apply || usage
155+
test -d "$dotest" -o -f "$GIT_DIR"/rebase-apply/rebasing &&
156+
die 'A rebase is in progress, try --continue, --skip or --abort.'
157+
die "No arguments given and $GIT_DIR/rebase-apply already exists."
158+
fi
159+
149160
while test $# != 0
150161
do
151162
case "$1" in
@@ -268,24 +279,24 @@ done
268279
# Make sure we do not have $GIT_DIR/rebase-apply
269280
if test -z "$do_merge"
270281
then
271-
if mkdir "$GIT_DIR"/rebase-apply
282+
if mkdir "$GIT_DIR"/rebase-apply 2>/dev/null
272283
then
273284
rmdir "$GIT_DIR"/rebase-apply
274285
else
275286
echo >&2 '
276-
It seems that I cannot create a '"$GIT_DIR"'/rebase-apply directory,
277-
and I wonder if you are in the middle of patch application or another
287+
It seems that I cannot create a rebase-apply directory, and
288+
I wonder if you are in the middle of patch application or another
278289
rebase. If that is not the case, please
279290
rm -fr '"$GIT_DIR"'/rebase-apply
280-
and run me again. I am stopping in case you still have something
291+
and run me again. I am stopping in case you still have something
281292
valuable there.'
282293
exit 1
283294
fi
284295
else
285296
if test -d "$dotest"
286297
then
287298
die "previous rebase directory $dotest still exists." \
288-
'try git-rebase < --continue | --abort >'
299+
'Try git rebase (--continue | --abort | --skip)'
289300
fi
290301
fi
291302

0 commit comments

Comments
 (0)