Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Wed, 9 Dec 2009 06:47:09 +0000 (22:47 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Dec 2009 06:47:09 +0000 (22:47 -0800)
* maint:
add-interactive: fix deletion of non-empty files
pull: clarify advice for the unconfigured error case

1  2 
git-add--interactive.perl
git-pull.sh
index f813ffdaa1526aa68b4ed8e7d4d04b48e270496a,75b71967a7c2f861c8e75e17c17e5cdce824e2e3..cd43c3491260cb2aa51f0d19fd18ab66e4ad8217
@@@ -990,7 -990,8 +990,7 @@@ sub edit_hunk_manually 
  EOF
        close $fh;
  
 -      my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor")
 -              || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
 +      chomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));
        system('sh', '-c', $editor.' "$@"', $editor, $hunkfile);
  
        if ($? != 0) {
@@@ -1216,7 -1217,11 +1216,11 @@@ sub patch_update_file 
        if (@{$mode->{TEXT}}) {
                unshift @hunk, $mode;
        }
-       if (@{$deletion->{TEXT}} && !@hunk) {
+       if (@{$deletion->{TEXT}}) {
+               foreach my $hunk (@hunk) {
+                       push @{$deletion->{TEXT}}, @{$hunk->{TEXT}};
+                       push @{$deletion->{DISPLAY}}, @{$hunk->{DISPLAY}};
+               }
                @hunk = ($deletion);
        }
  
diff --combined git-pull.sh
index bfeb4a0ff65fabaa49b212411ee2451cbf656f3d,2530f21861594bc47dce852cac9a286b7767f395..9e69ada413bd81948591a9e99287f97499573673
@@@ -16,8 -16,7 +16,8 @@@ cd_to_topleve
  test -z "$(git ls-files -u)" ||
        die "You are in the middle of a conflicted merge."
  
 -strategy_args= diffstat= no_commit= squash= no_ff= log_arg= verbosity=
 +strategy_args= diffstat= no_commit= squash= no_ff= ff_only=
 +log_arg= verbosity=
  curr_branch=$(git symbolic-ref -q HEAD)
  curr_branch_short=$(echo "$curr_branch" | sed "s|refs/heads/||")
  rebase=$(git config --bool branch.$curr_branch_short.rebase)
@@@ -46,8 -45,6 +46,8 @@@ d
                no_ff=--ff ;;
        --no-ff)
                no_ff=--no-ff ;;
 +      --ff-only)
 +              ff_only=--ff-only ;;
        -s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\
                --strateg=*|--strategy=*|\
        -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
@@@ -91,45 -88,63 +91,63 @@@ error_on_no_merge_candidates () 
                esac
        done
  
+       if test true = "$rebase"
+       then
+               op_type=rebase
+               op_prep=against
+       else
+               op_type=merge
+               op_prep=with
+       fi
        curr_branch=${curr_branch#refs/heads/}
        upstream=$(git config "branch.$curr_branch.merge")
        remote=$(git config "branch.$curr_branch.remote")
  
        if [ $# -gt 1 ]; then
-               echo "There are no candidates for merging in the refs that you just fetched."
+               if [ "$rebase" = true ]; then
+                       printf "There is no candidate for rebasing against "
+               else
+                       printf "There are no candidates for merging "
+               fi
+               echo "among the refs that you just fetched."
                echo "Generally this means that you provided a wildcard refspec which had no"
                echo "matches on the remote end."
        elif [ $# -gt 0 ] && [ "$1" != "$remote" ]; then
                echo "You asked to pull from the remote '$1', but did not specify"
-               echo "a branch to merge. Because this is not the default configured remote"
+               echo "a branch. Because this is not the default configured remote"
                echo "for your current branch, you must specify a branch on the command line."
        elif [ -z "$curr_branch" ]; then
                echo "You are not currently on a branch, so I cannot use any"
                echo "'branch.<branchname>.merge' in your configuration file."
-               echo "Please specify which branch you want to merge on the command"
+               echo "Please specify which remote branch you want to use on the command"
                echo "line and try again (e.g. 'git pull <repository> <refspec>')."
                echo "See git-pull(1) for details."
        elif [ -z "$upstream" ]; then
                echo "You asked me to pull without telling me which branch you"
-               echo "want to merge with, and 'branch.${curr_branch}.merge' in"
-               echo "your configuration file does not tell me either.  Please"
-               echo "specify which branch you want to merge on the command line and"
+               echo "want to $op_type $op_prep, and 'branch.${curr_branch}.merge' in"
+               echo "your configuration file does not tell me, either. Please"
+               echo "specify which branch you want to use on the command line and"
                echo "try again (e.g. 'git pull <repository> <refspec>')."
                echo "See git-pull(1) for details."
                echo
-               echo "If you often merge with the same branch, you may want to"
-               echo "configure the following variables in your configuration"
-               echo "file:"
+               echo "If you often $op_type $op_prep the same branch, you may want to"
+               echo "use something like the following in your configuration file:"
+               echo
+               echo "    [branch \"${curr_branch}\"]"
+               echo "    remote = <nickname>"
+               echo "    merge = <remote-ref>"
+               test rebase = "$op_type" &&
+                       echo "    rebase = true"
                echo
-               echo "    branch.${curr_branch}.remote = <nickname>"
-               echo "    branch.${curr_branch}.merge = <remote-ref>"
-               echo "    remote.<nickname>.url = <url>"
-               echo "    remote.<nickname>.fetch = <refspec>"
+               echo "    [remote \"<nickname>\"]"
+               echo "    url = <url>"
+               echo "    fetch = <refspec>"
                echo
                echo "See git-config(1) for details."
        else
-               echo "Your configuration specifies to merge the ref '${upstream#refs/heads/}' from the"
-               echo "remote, but no such ref was fetched."
+               echo "Your configuration specifies to $op_type $op_prep the ref '${upstream#refs/heads/}'"
+               echo "from the remote, but no such ref was fetched."
        fi
        exit 1
  }
@@@ -174,7 -189,7 +192,7 @@@ the
        # First update the working tree to match $curr_head.
  
        echo >&2 "Warning: fetch updated the current branch head."
 -      echo >&2 "Warning: fast forwarding your working tree from"
 +      echo >&2 "Warning: fast-forwarding your working tree from"
        echo >&2 "Warning: commit $orig_head."
        git update-index -q --refresh
        git read-tree -u -m "$orig_head" "$curr_head" ||
@@@ -218,5 -233,5 +236,5 @@@ merge_name=$(git fmt-merge-msg $log_ar
  test true = "$rebase" &&
        exec git-rebase $diffstat $strategy_args --onto $merge_head \
        ${oldremoteref:-$merge_head}
 -exec git-merge $diffstat $no_commit $squash $no_ff $log_arg $strategy_args \
 +exec git-merge $diffstat $no_commit $squash $no_ff $ff_only $log_arg $strategy_args \
        "$merge_name" HEAD $merge_head $verbosity