@matheusbsbs / matheus-bagliano / commits / e2f5f6ef67
Fork 0

Do not require clean tree when reverting and cherry-picking.

My stupidity deserved to be yelled at by Linus ... there is no reason to require the working tree to be clean when merging -- the only requirements are index to match HEAD commit and the paths involved in merge are up to date in the working tree. Revert and cherry-pick are just specialized forms of merge, and the requirements should be the same. Remove the 'general purpose routine to make sure tree is clean' from git-sh-setup, to prevent me from getting tempted again. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Sep 24, 2005 at 22:52 UTC e2f5f6ef6795c880a2f13ea472b96704b4a4ca94
2 files changed +4 -12
git-revert.sh
+4 -1
@@ -56,9 +56,12 @@ t)
56 die "Your index file is unmerged."
57 ;;
58 *)
59 - check_clean_tree || die "Cannot run $me from a dirty tree."
59 head=$(git-rev-parse --verify HEAD) ||
60 die "You do not have a valid HEAD"
61 + files=$(git-diff-index --cached --name-only $head) || exit
62 + if [ "$files" ]; then
63 + die "Dirty index: cannot $me (dirty: $files)"
64 + fi
65 ;;
66 esac
67
git-sh-setup.sh
-11
@@ -17,17 +17,6 @@ die() {
17 exit 1
18 }
19
20 -check_clean_tree() {
21 - dirty1_=`git-update-index -q --refresh` && {
22 - dirty2_=`git-diff-index --name-only --cached HEAD`
23 - case "$dirty2_" in '') : ;; *) (exit 1) ;; esac
24 - } || {
25 - echo >&2 "$dirty1_"
26 - echo "$dirty2_" | sed >&2 -e 's/^/modified: /'
27 - (exit 1)
28 - }
29 -}
30 -
20 [ -h "$GIT_DIR/HEAD" ] &&
21 [ -d "$GIT_DIR/refs" ] &&
22 [ -d "$GIT_OBJECT_DIRECTORY/00" ]