summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2005-08-18 22:31:40 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-08-18 23:26:50 (GMT)
commitd571c2be99cb4ab96ff70c62c31d587271db9567 (patch)
treefa38bcef80df2d3090d3eb95681f615d94f95a33
parent1bff6490b0225aef07d2fd13cbb806ac8ce115de (diff)
downloadgit-d571c2be99cb4ab96ff70c62c31d587271db9567.zip
git-d571c2be99cb4ab96ff70c62c31d587271db9567.tar.gz
git-d571c2be99cb4ab96ff70c62c31d587271db9567.tar.bz2
[PATCH] git-applymbox: verify that index is clean
This makes git-applymbox verify that the index matches the current HEAD before it starts applying patches. Otherwise, you might have updated the index with unrelated changes, and the first patch will commit not just the patch from the mbox, but also any changes you had in your index. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rwxr-xr-xtools/git-applymbox8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/git-applymbox b/tools/git-applymbox
index 889d4c1..afcb00a 100755
--- a/tools/git-applymbox
+++ b/tools/git-applymbox
@@ -18,6 +18,8 @@
## use a Signoff_file, because applypatch wants to append the sign-off
## message to msg-clean every time it is run.
+. git-sh-setup-script || die "Not a git archive"
+
keep_subject= query_apply= continue= resume=t
while case "$#" in 0) break ;; esac
do
@@ -39,6 +41,12 @@ case "$continue" in
shift
esac
+files=$(git-diff-cache --cached --name-only HEAD) || exit
+if [ "$files" ]; then
+ echo "Dirty index: cannot apply patches (dirty: $files)" >&2
+ exit 1
+fi
+
case "$query_apply" in
t) touch .dotest/.query_apply
esac