summaryrefslogtreecommitdiff
path: root/git-sh-setup.sh
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2010-10-19 14:39:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-10-28 20:28:44 (GMT)
commit92c62a3f4f93432c0c82e3031a9e64e03ba290f7 (patch)
treea17cf82fbe26678b12ab794ab6aeddfb5948fd9b /git-sh-setup.sh
parentca209065f3cc3462eb0ae6090f6b13f38aa2114c (diff)
downloadgit-92c62a3f4f93432c0c82e3031a9e64e03ba290f7.zip
git-92c62a3f4f93432c0c82e3031a9e64e03ba290f7.tar.gz
git-92c62a3f4f93432c0c82e3031a9e64e03ba290f7.tar.bz2
Porcelain scripts: Rewrite cryptic "needs update" error message
Although Git interally has the facility to differentiate between porcelain and plubmbing commands and appropriately print errors, several shell scripts invoke plubming commands triggering cryptic plumbing errors to be displayed on a porcelain interface. This patch replaces the "needs update" message in git-pull and git-rebase, when `git update-index` is run, with a more friendly message. Reported-by: Joshua Jensen <jjensen@workspacewhiz.com> Reported-by: Thore Husfeldt <thore.husfeldt@gmail.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-sh-setup.sh')
-rw-r--r--git-sh-setup.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index ae031a1..aa16b83 100644
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -145,6 +145,35 @@ require_work_tree () {
die "fatal: $0 cannot be used without a working tree."
}
+require_clean_work_tree () {
+ git rev-parse --verify HEAD >/dev/null || exit 1
+ git update-index -q --ignore-submodules --refresh
+ err=0
+
+ if ! git diff-files --quiet --ignore-submodules
+ then
+ echo >&2 "Cannot $1: You have unstaged changes."
+ err=1
+ fi
+
+ if ! git diff-index --cached --quiet --ignore-submodules HEAD --
+ then
+ if [ $err = 0 ]
+ then
+ echo >&2 "Cannot $1: Your index contains uncommitted changes."
+ else
+ echo >&2 "Additionally, your index contains uncommitted changes."
+ fi
+ err=1
+ fi
+
+ if [ $err = 1 ]
+ then
+ test -n "$2" && echo >&2 "$2"
+ exit 1
+ fi
+}
+
get_author_ident_from_commit () {
pick_author_script='
/^author /{