@matheusbsbs / matheus-bagliano / commits / 29609e6822
Fork 0

pull: do nothing on --dry-run

Pull was never meant to take --dry-run at all. However, it passes unknown arguments to git-fetch, which does do a dry-run. Unfortunately, pull then attempts to merge whatever cruft was in FETCH_HEAD (which the dry-run fetch will not have written to). Even though we never advertise --dry-run as something that should work, it is still worth being defensive because: 1. Other commands (including fetch) take --dry-run, so a user might try it. 2. Rather than simply producing an error, it actually changes the repository in totally unexpected ways. This patch makes "pull --dry-run" equivalent to "fetch --dry-run". Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed May 25, 2010 at 02:07 UTC 29609e682226acbdaa3340145792b5bd7a1ef5a8
1 file changed +6 -1
git-pull.sh
+6 -1
@@ -43,6 +43,7 @@ merge_args=
43 curr_branch=$(git symbolic-ref -q HEAD)
44 curr_branch_short="${curr_branch#refs/heads/}"
45 rebase=$(git config --bool branch.$curr_branch_short.rebase)
46 +dry_run=
47 while :
48 do
49 case "$1" in
@@ -104,6 +105,9 @@ do
105 --no-r|--no-re|--no-reb|--no-reba|--no-rebas|--no-rebase)
106 rebase=false
107 ;;
108 + --d|--dr|--dry|--dry-|--dry-r|--dry-ru|--dry-run)
109 + dry_run=--dry-run
110 + ;;
111 -h|--h|--he|--hel|--help)
112 usage
113 ;;
@@ -216,7 +220,8 @@ test true = "$rebase" && {
220 done
221 }
222 orig_head=$(git rev-parse -q --verify HEAD)
219 -git fetch $verbosity $progress --update-head-ok "$@" || exit 1
223 +git fetch $verbosity $progress $dry_run --update-head-ok "$@" || exit 1
224 +test -z "$dry_run" || exit 0
225
226 curr_head=$(git rev-parse -q --verify HEAD)
227 if test -n "$orig_head" && test "$curr_head" != "$orig_head"