@matheusbsbs / matheus-bagliano / commits / 9b752a6e31
Fork 0

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 <s-beyer@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephan Beyer committed Aug 17, 2008 at 06:25 UTC 9b752a6e31f93f2925856a0c0607c2ffc2a93375
1 file changed +16 -5
git-rebase.sh
+16 -5
@@ -144,8 +144,19 @@ is_interactive () {
144 done && test -n "$1"
145 }
146
147 +test -f "$GIT_DIR"/rebase-apply/applying &&
148 + die 'It looks like git-am is in progress. Cannot rebase.'
149 +
150 is_interactive "$@" && exec git-rebase--interactive "$@"
151
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 +
160 while test $# != 0
161 do
162 case "$1" in
@@ -268,16 +279,16 @@ done
279 # Make sure we do not have $GIT_DIR/rebase-apply
280 if test -z "$do_merge"
281 then
271 - if mkdir "$GIT_DIR"/rebase-apply
282 + if mkdir "$GIT_DIR"/rebase-apply 2>/dev/null
283 then
284 rmdir "$GIT_DIR"/rebase-apply
285 else
286 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
289 rebase. If that is not the case, please
290 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
292 valuable there.'
293 exit 1
294 fi
@@ -285,7 +296,7 @@ else
296 if test -d "$dotest"
297 then
298 die "previous rebase directory $dotest still exists." \
288 - 'try git-rebase < --continue | --abort >'
299 + 'Try git rebase (--continue | --abort | --skip)'
300 fi
301 fi
302