Merge branch 'cl/send-email-reply-to'
authorJunio C Hamano <gitster@pobox.com>
Thu, 15 Mar 2018 22:00:45 +0000 (15:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Mar 2018 22:00:45 +0000 (15:00 -0700)
"git send-email" learned "--reply-to=<address>" option.

* cl/send-email-reply-to:
send-email: support separate Reply-To address
send-email: rename variable for clarity

1  2 
contrib/completion/git-completion.bash
git-send-email.perl
t/t9001-send-email.sh
index f1981aa75df2128f93a3d6b5b3434ab6bda86576,2a0dc4eef94cc1d8e3366f33856c4318425ebdfa..6da95b8095d9a18694f6a3cda139fe4ba832f4ee
@@@ -280,39 -280,6 +280,39 @@@ __gitcomp (
        esac
  }
  
 +# This function is equivalent to
 +#
 +#    __gitcomp "$(git xxx --git-completion-helper) ..."
 +#
 +# except that the output is cached. Accept 1-3 arguments:
 +# 1: the git command to execute, this is also the cache key
 +# 2: extra options to be added on top (e.g. negative forms)
 +# 3: options to be excluded
 +__gitcomp_builtin ()
 +{
 +      # spaces must be replaced with underscore for multi-word
 +      # commands, e.g. "git remote add" becomes remote_add.
 +      local cmd="$1"
 +      local incl="$2"
 +      local excl="$3"
 +
 +      local var=__gitcomp_builtin_"${cmd/-/_}"
 +      local options
 +      eval "options=\$$var"
 +
 +      if [ -z "$options" ]; then
 +              # leading and trailing spaces are significant to make
 +              # option removal work correctly.
 +              options=" $(__git ${cmd/_/ } --git-completion-helper) $incl "
 +              for i in $excl; do
 +                      options="${options/ $i / }"
 +              done
 +              eval "$var=\"$options\""
 +      fi
 +
 +      __gitcomp "$options"
 +}
 +
  # Variation of __gitcomp_nl () that appends to the existing list of
  # completion candidates, COMPREPLY.
  __gitcomp_nl_append ()
@@@ -472,7 -439,7 +472,7 @@@ __git_refs (
                        track=""
                        ;;
                *)
 -                      for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
 +                      for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
                                case "$i" in
                                $match*)
                                        if [ -e "$dir/$i" ]; then
@@@ -627,7 -594,7 +627,7 @@@ __git_is_configured_remote (
  
  __git_list_merge_strategies ()
  {
 -      git merge -s help 2>&1 |
 +      LANG=C LC_ALL=C git merge -s help 2>&1 |
        sed -n -e '/[Aa]vailable strategies are: /,/^$/{
                s/\.$//
                s/.*://
@@@ -1105,13 -1072,12 +1105,13 @@@ __git_count_arguments (
  }
  
  __git_whitespacelist="nowarn warn error error-all fix"
 +__git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
  
  _git_am ()
  {
        __git_find_repo_path
        if [ -d "$__git_repo_path"/rebase-apply ]; then
 -              __gitcomp "--skip --continue --resolved --abort"
 +              __gitcomp "$__git_am_inprogress_options"
                return
        fi
        case "$cur" in
                return
                ;;
        --*)
 -              __gitcomp "
 -                      --3way --committer-date-is-author-date --ignore-date
 -                      --ignore-whitespace --ignore-space-change
 -                      --interactive --keep --no-utf8 --signoff --utf8
 -                      --whitespace= --scissors
 -                      "
 +              __gitcomp_builtin am "--no-utf8" \
 +                      "$__git_am_inprogress_options"
                return
        esac
  }
@@@ -1134,7 -1104,14 +1134,7 @@@ _git_apply (
                return
                ;;
        --*)
 -              __gitcomp "
 -                      --stat --numstat --summary --check --index
 -                      --cached --index-info --reverse --reject --unidiff-zero
 -                      --apply --no-add --exclude=
 -                      --ignore-whitespace --ignore-space-change
 -                      --whitespace= --inaccurate-eof --verbose
 -                      --recount --directory=
 -                      "
 +              __gitcomp_builtin apply
                return
        esac
  }
@@@ -1143,7 -1120,10 +1143,7 @@@ _git_add (
  {
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --interactive --refresh --patch --update --dry-run
 -                      --ignore-errors --intent-to-add --force --edit --chmod=
 -                      "
 +              __gitcomp_builtin add
                return
        esac
  
@@@ -1220,8 -1200,12 +1220,8 @@@ _git_branch (
                __git_complete_refs --cur="${cur##--set-upstream-to=}"
                ;;
        --*)
 -              __gitcomp "
 -                      --color --no-color --verbose --abbrev= --no-abbrev
 -                      --track --no-track --contains --no-contains --merged --no-merged
 -                      --set-upstream-to= --edit-description --list
 -                      --unset-upstream --delete --move --copy --remotes
 -                      --column --no-column --sort= --points-at
 +              __gitcomp_builtin branch "--no-color --no-abbrev
 +                      --no-track --no-column
                        "
                ;;
        *)
@@@ -1263,7 -1247,11 +1263,7 @@@ _git_checkout (
                __gitcomp "diff3 merge" "" "${cur##--conflict=}"
                ;;
        --*)
 -              __gitcomp "
 -                      --quiet --ours --theirs --track --no-track --merge
 -                      --conflict= --orphan --patch --detach --ignore-skip-worktree-bits
 -                      --recurse-submodules --no-recurse-submodules
 -                      "
 +              __gitcomp_builtin checkout "--no-track --no-recurse-submodules"
                ;;
        *)
                # check if --track, --no-track, or --no-guess was specified
@@@ -1283,19 -1271,16 +1283,19 @@@ _git_cherry (
        __git_complete_refs
  }
  
 +__git_cherry_pick_inprogress_options="--continue --quit --abort"
 +
  _git_cherry_pick ()
  {
        __git_find_repo_path
        if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
 -              __gitcomp "--continue --quit --abort"
 +              __gitcomp "$__git_cherry_pick_inprogress_options"
                return
        fi
        case "$cur" in
        --*)
 -              __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
 +              __gitcomp_builtin cherry-pick "" \
 +                      "$__git_cherry_pick_inprogress_options"
                ;;
        *)
                __git_complete_refs
@@@ -1307,7 -1292,7 +1307,7 @@@ _git_clean (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--dry-run --quiet"
 +              __gitcomp_builtin clean
                return
                ;;
        esac
@@@ -1320,7 -1305,26 +1320,7 @@@ _git_clone (
  {
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --local
 -                      --no-hardlinks
 -                      --shared
 -                      --reference
 -                      --quiet
 -                      --no-checkout
 -                      --bare
 -                      --mirror
 -                      --origin
 -                      --upload-pack
 -                      --template=
 -                      --depth
 -                      --single-branch
 -                      --no-tags
 -                      --branch
 -                      --recurse-submodules
 -                      --no-single-branch
 -                      --shallow-submodules
 -                      "
 +              __gitcomp_builtin clone "--no-single-branch"
                return
                ;;
        esac
@@@ -1353,7 -1357,16 +1353,7 @@@ _git_commit (
                return
                ;;
        --*)
 -              __gitcomp "
 -                      --all --author= --signoff --verify --no-verify
 -                      --edit --no-edit
 -                      --amend --include --only --interactive
 -                      --dry-run --reuse-message= --reedit-message=
 -                      --reset-author --file= --message= --template=
 -                      --cleanup= --untracked-files --untracked-files=
 -                      --verbose --quiet --fixup= --squash=
 -                      --patch --short --date --allow-empty
 -                      "
 +              __gitcomp_builtin commit "--no-edit --verify"
                return
        esac
  
@@@ -1369,7 -1382,11 +1369,7 @@@ _git_describe (
  {
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --all --tags --contains --abbrev= --candidates=
 -                      --exact-match --debug --long --match --always --first-parent
 -                      --exclude --dirty --broken
 -                      "
 +              __gitcomp_builtin describe
                return
        esac
        __git_complete_refs
@@@ -1394,7 -1411,7 +1394,7 @@@ __git_diff_common_options="--stat --num
                        --dirstat --dirstat= --dirstat-by-file
                        --dirstat-by-file= --cumulative
                        --diff-algorithm=
 -                      --submodule --submodule=
 +                      --submodule --submodule= --ignore-submodules
  "
  
  _git_diff ()
@@@ -1435,11 -1452,11 +1435,11 @@@ _git_difftool (
                return
                ;;
        --*)
 -              __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
 -                      --base --ours --theirs
 -                      --no-renames --diff-filter= --find-copies-harder
 -                      --relative --ignore-submodules
 -                      --tool="
 +              __gitcomp_builtin difftool "$__git_diff_common_options
 +                                      --base --cached --ours --theirs
 +                                      --pickaxe-all --pickaxe-regex
 +                                      --relative --staged
 +                                      "
                return
                ;;
        esac
  
  __git_fetch_recurse_submodules="yes on-demand no"
  
 -__git_fetch_options="
 -      --quiet --verbose --append --upload-pack --force --keep --depth=
 -      --tags --no-tags --all --prune --dry-run --recurse-submodules=
 -      --unshallow --update-shallow
 -"
 -
  _git_fetch ()
  {
        case "$cur" in
                return
                ;;
        --*)
 -              __gitcomp "$__git_fetch_options"
 +              __gitcomp_builtin fetch "--no-tags"
                return
                ;;
        esac
@@@ -1493,7 -1516,10 +1493,7 @@@ _git_fsck (
  {
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --tags --root --unreachable --cache --no-reflogs --full
 -                      --strict --verbose --lost-found --name-objects
 -                      "
 +              __gitcomp_builtin fsck "--no-reflogs"
                return
                ;;
        esac
@@@ -1503,7 -1529,7 +1503,7 @@@ _git_gc (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--prune --aggressive"
 +              __gitcomp_builtin gc
                return
                ;;
        esac
@@@ -1559,7 -1585,21 +1559,7 @@@ _git_grep (
  
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --cached
 -                      --text --ignore-case --word-regexp --invert-match
 -                      --full-name --line-number
 -                      --extended-regexp --basic-regexp --fixed-strings
 -                      --perl-regexp
 -                      --threads
 -                      --files-with-matches --name-only
 -                      --files-without-match
 -                      --max-depth
 -                      --count
 -                      --and --or --not --all-match
 -                      --break --heading --show-function --function-context
 -                      --untracked --no-index
 -                      "
 +              __gitcomp_builtin grep
                return
                ;;
        esac
@@@ -1577,7 -1617,7 +1577,7 @@@ _git_help (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--all --guides --info --man --web"
 +              __gitcomp_builtin help
                return
                ;;
        esac
@@@ -1600,7 -1640,7 +1600,7 @@@ _git_init (
                return
                ;;
        --*)
 -              __gitcomp "--quiet --bare --template= --shared --shared="
 +              __gitcomp_builtin init
                return
                ;;
        esac
@@@ -1610,7 -1650,13 +1610,7 @@@ _git_ls_files (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--cached --deleted --modified --others --ignored
 -                      --stage --directory --no-empty-directory --unmerged
 -                      --killed --exclude= --exclude-from=
 -                      --exclude-per-directory= --exclude-standard
 -                      --error-unmatch --with-tree= --full-name
 -                      --abbrev --ignored --exclude-per-directory
 -                      "
 +              __gitcomp_builtin ls-files "--no-empty-directory"
                return
                ;;
        esac
@@@ -1624,7 -1670,7 +1624,7 @@@ _git_ls_remote (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--heads --tags --refs --get-url --symref"
 +              __gitcomp_builtin ls-remote
                return
                ;;
        esac
@@@ -1748,18 -1794,22 +1748,18 @@@ _git_log (
        __git_complete_revlist
  }
  
 -# Common merge options shared by git-merge(1) and git-pull(1).
 -__git_merge_options="
 -      --no-commit --no-stat --log --no-log --squash --strategy
 -      --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
 -      --verify-signatures --no-verify-signatures --gpg-sign
 -      --quiet --verbose --progress --no-progress
 -"
 -
  _git_merge ()
  {
        __git_complete_strategy && return
  
        case "$cur" in
        --*)
 -              __gitcomp "$__git_merge_options
 -                      --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
 +              __gitcomp_builtin merge "--no-rerere-autoupdate
 +                              --no-commit --no-edit --no-ff
 +                              --no-log --no-progress
 +                              --no-squash --no-stat
 +                              --no-verify-signatures
 +                              "
                return
        esac
        __git_complete_refs
@@@ -1783,7 -1833,7 +1783,7 @@@ _git_merge_base (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--octopus --independent --is-ancestor --fork-point"
 +              __gitcomp_builtin merge-base
                return
                ;;
        esac
@@@ -1794,7 -1844,7 +1794,7 @@@ _git_mv (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--dry-run"
 +              __gitcomp_builtin mv
                return
                ;;
        esac
  
  _git_name_rev ()
  {
 -      __gitcomp "--tags --all --stdin"
 +      __gitcomp_builtin name-rev
  }
  
  _git_notes ()
  {
 -      local subcommands='add append copy edit list prune remove show'
 +      local subcommands='add append copy edit get-ref list merge prune remove show'
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
  
        case "$subcommand,$cur" in
        ,--*)
 -              __gitcomp '--ref'
 +              __gitcomp_builtin notes
                ;;
        ,*)
                case "$prev" in
                        ;;
                esac
                ;;
 -      add,--reuse-message=*|append,--reuse-message=*|\
 -      add,--reedit-message=*|append,--reedit-message=*)
 +      *,--reuse-message=*|*,--reedit-message=*)
                __git_complete_refs --cur="${cur#*=}"
                ;;
 -      add,--*|append,--*)
 -              __gitcomp '--file= --message= --reedit-message=
 -                              --reuse-message='
 +      *,--*)
 +              __gitcomp_builtin notes_$subcommand
                ;;
 -      copy,--*)
 -              __gitcomp '--stdin'
 -              ;;
 -      prune,--*)
 -              __gitcomp '--dry-run --verbose'
 -              ;;
 -      prune,*)
 +      prune,*|get-ref,*)
 +              # this command does not take a ref, do not complete it
                ;;
        *)
                case "$prev" in
@@@ -1863,11 -1920,12 +1863,11 @@@ _git_pull (
                return
                ;;
        --*)
 -              __gitcomp "
 -                      --rebase --no-rebase
 -                      --autostash --no-autostash
 -                      $__git_merge_options
 -                      $__git_fetch_options
 -              "
 +              __gitcomp_builtin pull "--no-autostash --no-commit --no-edit
 +                                      --no-ff --no-log --no-progress --no-rebase
 +                                      --no-squash --no-stat --no-tags
 +                                      --no-verify-signatures"
 +
                return
                ;;
        esac
@@@ -1918,7 -1976,12 +1918,7 @@@ _git_push (
                return
                ;;
        --*)
 -              __gitcomp "
 -                      --all --mirror --tags --dry-run --force --verbose
 -                      --quiet --prune --delete --follow-tags
 -                      --receive-pack= --repo= --set-upstream
 -                      --force-with-lease --force-with-lease= --recurse-submodules=
 -              "
 +              __gitcomp_builtin push
                return
                ;;
        esac
@@@ -1929,11 -1992,11 +1929,11 @@@ _git_rebase (
  {
        __git_find_repo_path
        if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
 -              __gitcomp "--continue --skip --abort --quit --edit-todo"
 +              __gitcomp "--continue --skip --abort --quit --edit-todo --show-current-patch"
                return
        elif [ -d "$__git_repo_path"/rebase-apply ] || \
             [ -d "$__git_repo_path"/rebase-merge ]; then
 -              __gitcomp "--continue --skip --abort --quit"
 +              __gitcomp "--continue --skip --abort --quit --show-current-patch"
                return
        fi
        __git_complete_strategy && return
                        --autostash --no-autostash
                        --verify --no-verify
                        --keep-empty --root --force-rebase --no-ff
 +                      --rerere-autoupdate
                        --exec
                        "
  
@@@ -2019,7 -2081,7 +2019,7 @@@ _git_send_email (
                        --compose --confirm= --dry-run --envelope-sender
                        --from --identity
                        --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
-                       --no-suppress-from --no-thread --quiet
+                       --no-suppress-from --no-thread --quiet --reply-to
                        --signed-off-by-cc --smtp-pass --smtp-server
                        --smtp-server-port --smtp-encryption= --smtp-user
                        --subject --suppress-cc= --suppress-from --thread --to
@@@ -2057,7 -2119,11 +2057,7 @@@ _git_status (
                return
                ;;
        --*)
 -              __gitcomp "
 -                      --short --branch --porcelain --long --verbose
 -                      --untracked-files= --ignore-submodules= --ignored
 -                      --column= --no-column
 -                      "
 +              __gitcomp_builtin status "--no-column"
                return
                ;;
        esac
@@@ -2199,7 -2265,14 +2199,7 @@@ _git_config (
        esac
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --system --global --local --file=
 -                      --list --replace-all
 -                      --get --get-all --get-regexp
 -                      --add --unset --unset-all
 -                      --remove-section --rename-section
 -                      --name-only
 -                      "
 +              __gitcomp_builtin config
                return
                ;;
        branch.*.*)
@@@ -2599,7 -2672,7 +2599,7 @@@ _git_remote (
        if [ -z "$subcommand" ]; then
                case "$cur" in
                --*)
 -                      __gitcomp "--verbose"
 +                      __gitcomp_builtin remote
                        ;;
                *)
                        __gitcomp "$subcommands"
  
        case "$subcommand,$cur" in
        add,--*)
 -              __gitcomp "--track --master --fetch --tags --no-tags --mirror="
 +              __gitcomp_builtin remote_add "--no-tags"
                ;;
        add,*)
                ;;
        set-head,--*)
 -              __gitcomp "--auto --delete"
 +              __gitcomp_builtin remote_set-head
                ;;
        set-branches,--*)
 -              __gitcomp "--add"
 +              __gitcomp_builtin remote_set-branches
                ;;
        set-head,*|set-branches,*)
                __git_complete_remote_or_refspec
                ;;
        update,--*)
 -              __gitcomp "--prune"
 +              __gitcomp_builtin remote_update
                ;;
        update,*)
                __gitcomp "$(__git_get_config_variables "remotes")"
                ;;
        set-url,--*)
 -              __gitcomp "--push --add --delete"
 +              __gitcomp_builtin remote_set-url
                ;;
        get-url,--*)
 -              __gitcomp "--push --all"
 +              __gitcomp_builtin remote_get-url
                ;;
        prune,--*)
 -              __gitcomp "--dry-run"
 +              __gitcomp_builtin remote_prune
                ;;
        *)
                __gitcomp_nl "$(__git_remotes)"
@@@ -2648,7 -2721,7 +2648,7 @@@ _git_replace (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--edit --graft --format= --list --delete"
 +              __gitcomp_builtin replace
                return
                ;;
        esac
@@@ -2672,26 -2745,26 +2672,26 @@@ _git_reset (
  
        case "$cur" in
        --*)
 -              __gitcomp "--merge --mixed --hard --soft --patch --keep"
 +              __gitcomp_builtin reset
                return
                ;;
        esac
        __git_complete_refs
  }
  
 +__git_revert_inprogress_options="--continue --quit --abort"
 +
  _git_revert ()
  {
        __git_find_repo_path
        if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
 -              __gitcomp "--continue --quit --abort"
 +              __gitcomp "$__git_revert_inprogress_options"
                return
        fi
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --edit --mainline --no-edit --no-commit --signoff
 -                      --strategy= --strategy-option=
 -                      "
 +              __gitcomp_builtin revert "--no-edit" \
 +                      "$__git_revert_inprogress_options"
                return
                ;;
        esac
@@@ -2702,7 -2775,7 +2702,7 @@@ _git_rm (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
 +              __gitcomp_builtin rm
                return
                ;;
        esac
@@@ -2760,7 -2833,12 +2760,7 @@@ _git_show_branch (
  {
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --all --remotes --topo-order --date-order --current --more=
 -                      --list --independent --merge-base --no-name
 -                      --color --no-color
 -                      --sha1-name --sparse --topics --reflog
 -                      "
 +              __gitcomp_builtin show-branch "--no-color"
                return
                ;;
        esac
@@@ -2993,7 -3071,11 +2993,7 @@@ _git_tag (
  
        case "$cur" in
        --*)
 -              __gitcomp "
 -                      --list --delete --verify --annotate --message --file
 -                      --sign --cleanup --local-user --force --column --sort=
 -                      --contains --no-contains --points-at --merged --no-merged --create-reflog
 -                      "
 +              __gitcomp_builtin tag
                ;;
        esac
  }
@@@ -3005,26 -3087,23 +3005,26 @@@ _git_whatchanged (
  
  _git_worktree ()
  {
 -      local subcommands="add list lock prune unlock"
 +      local subcommands="add list lock move prune remove unlock"
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
        if [ -z "$subcommand" ]; then
                __gitcomp "$subcommands"
        else
                case "$subcommand,$cur" in
                add,--*)
 -                      __gitcomp "--detach"
 +                      __gitcomp_builtin worktree_add
                        ;;
                list,--*)
 -                      __gitcomp "--porcelain"
 +                      __gitcomp_builtin worktree_list
                        ;;
                lock,--*)
 -                      __gitcomp "--reason"
 +                      __gitcomp_builtin worktree_lock
                        ;;
                prune,--*)
 -                      __gitcomp "--dry-run --expire --verbose"
 +                      __gitcomp_builtin worktree_prune
 +                      ;;
 +              remove,--*)
 +                      __gitcomp "--force"
                        ;;
                *)
                        ;;
diff --combined git-send-email.perl
index a4a560bb834c9595fb3f2f1c315a00f8f7150e06,0aaf1dcbc6e96c2f370d7ec4a68b26a50957f9c1..3a68aae060226e6497d6a0e7d936efca95844f93
@@@ -26,11 -26,10 +26,11 @@@ use Text::ParseWords
  use Term::ANSIColor;
  use File::Temp qw/ tempdir tempfile /;
  use File::Spec::Functions qw(catdir catfile);
 -use Error qw(:try);
 +use Git::Error qw(:try);
  use Cwd qw(abs_path cwd);
  use Git;
  use Git::I18N;
 +use Git::Mail::Address;
  
  Getopt::Long::Configure qw/ pass_through /;
  
@@@ -57,6 -56,7 +57,7 @@@ git send-email --dump-aliase
      --[no-]cc               <str>  * Email Cc:
      --[no-]bcc              <str>  * Email Bcc:
      --subject               <str>  * Email "Subject:"
+     --reply-to              <str>  * Email "Reply-To:"
      --in-reply-to           <str>  * Email "In-Reply-To:"
      --[no-]xmailer                 * Add "X-Mailer:" header (default).
      --[no-]annotate                * Review each patch that will be sent in an editor.
@@@ -167,13 -167,13 +168,13 @@@ my $re_encoded_word = qr/=\?($re_token)
  
  # Variables we fill in automatically, or via prompting:
  my (@to,$no_to,@initial_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh,
-       $initial_reply_to,$initial_subject,@files,
+       $initial_in_reply_to,$reply_to,$initial_subject,@files,
        $author,$sender,$smtp_authpass,$annotate,$use_xmailer,$compose,$time);
  
  my $envelope_sender;
  
  # Example reply to:
- #$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
+ #$initial_in_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
  
  my $repo = eval { Git->repository() };
  my @repo = $repo ? ($repo) : ();
@@@ -315,7 -315,8 +316,8 @@@ die __("--dump-aliases incompatible wit
      if !$help and $dump_aliases and @ARGV;
  $rc = GetOptions(
                    "sender|from=s" => \$sender,
-                     "in-reply-to=s" => \$initial_reply_to,
+                     "in-reply-to=s" => \$initial_in_reply_to,
+                   "reply-to=s" => \$reply_to,
                    "subject=s" => \$initial_subject,
                    "to=s" => \@initial_to,
                    "to-cmd=s" => \$to_cmd,
@@@ -379,10 -380,6 +381,10 @@@ unless ($rc) 
  die __("Cannot run git format-patch from outside a repository\n")
        if $format_patch and not $repo;
  
 +die __("`batch-size` and `relogin` must be specified together " .
 +      "(via command-line or configuration option)\n")
 +      if defined $relogin_delay and not defined $batch_size;
 +
  # Now, let's fill any that aren't set in with defaults:
  
  sub read_config {
@@@ -494,7 -491,7 +496,7 @@@ my ($repoauthor, $repocommitter)
  ($repocommitter) = Git::ident_person(@repo, 'committer');
  
  sub parse_address_line {
 -      return Git::parse_mailboxes($_[0]);
 +      return map { $_->format } Mail::Address->parse($_[0]);
  }
  
  sub split_addrs {
@@@ -681,7 -678,8 +683,8 @@@ if ($compose) 
  
        my $tpl_sender = $sender || $repoauthor || $repocommitter || '';
        my $tpl_subject = $initial_subject || '';
-       my $tpl_reply_to = $initial_reply_to || '';
+       my $tpl_in_reply_to = $initial_in_reply_to || '';
+       my $tpl_reply_to = $reply_to || '';
  
        print $c <<EOT1, Git::prefix_lines("GIT: ", __ <<EOT2), <<EOT3;
  From $tpl_sender # This line is ignored.
@@@ -693,8 -691,9 +696,9 @@@ for the patch you are writing
  Clear the body content if you don't wish to send a summary.
  EOT2
  From: $tpl_sender
+ Reply-To: $tpl_reply_to
  Subject: $tpl_subject
- In-Reply-To: $tpl_reply_to
+ In-Reply-To: $tpl_in_reply_to
  
  EOT3
        for my $f (@files) {
                $sender = delete($parsed_email{'From'});
        }
        if ($parsed_email{'In-Reply-To'}) {
-               $initial_reply_to = delete($parsed_email{'In-Reply-To'});
+               $initial_in_reply_to = delete($parsed_email{'In-Reply-To'});
+       }
+       if ($parsed_email{'Reply-To'}) {
+               $reply_to = delete($parsed_email{'Reply-To'});
        }
        if ($parsed_email{'Subject'}) {
                $initial_subject = delete($parsed_email{'Subject'});
@@@ -916,16 -918,22 +923,22 @@@ sub expand_one_alias 
  @initial_cc = process_address_list(@initial_cc);
  @bcclist = process_address_list(@bcclist);
  
- if ($thread && !defined $initial_reply_to && $prompting) {
-       $initial_reply_to = ask(
+ if ($thread && !defined $initial_in_reply_to && $prompting) {
+       $initial_in_reply_to = ask(
                __("Message-ID to be used as In-Reply-To for the first email (if any)? "),
                default => "",
                valid_re => qr/\@.*\./, confirm_only => 1);
  }
- if (defined $initial_reply_to) {
-       $initial_reply_to =~ s/^\s*<?//;
-       $initial_reply_to =~ s/>?\s*$//;
-       $initial_reply_to = "<$initial_reply_to>" if $initial_reply_to ne '';
+ if (defined $initial_in_reply_to) {
+       $initial_in_reply_to =~ s/^\s*<?//;
+       $initial_in_reply_to =~ s/>?\s*$//;
+       $initial_in_reply_to = "<$initial_in_reply_to>" if $initial_in_reply_to ne '';
+ }
+ if (defined $reply_to) {
+       $reply_to =~ s/^\s+|\s+$//g;
+       ($reply_to) = expand_aliases($reply_to);
+       $reply_to = sanitize_address($reply_to);
  }
  
  if (!defined $smtp_server) {
@@@ -945,7 -953,7 +958,7 @@@ if ($compose && $compose > 0) 
  }
  
  # Variables we set as part of the loop over files
- our ($message_id, %mail, $subject, $reply_to, $references, $message,
+ our ($message_id, %mail, $subject, $in_reply_to, $references, $message,
        $needs_confirm, $message_num, $ask_default);
  
  sub extract_valid_address {
@@@ -1354,11 -1362,14 +1367,14 @@@ Message-Id: $message_i
        if ($use_xmailer) {
                $header .= "X-Mailer: git-send-email $gitversion\n";
        }
-       if ($reply_to) {
+       if ($in_reply_to) {
  
-               $header .= "In-Reply-To: $reply_to\n";
+               $header .= "In-Reply-To: $in_reply_to\n";
                $header .= "References: $references\n";
        }
+       if ($reply_to) {
+               $header .= "Reply-To: $reply_to\n";
+       }
        if (@xh) {
                $header .= join("\n", @xh) . "\n";
        }
@@@ -1533,8 -1544,8 +1549,8 @@@ EO
        return 1;
  }
  
- $reply_to = $initial_reply_to;
- $references = $initial_reply_to || '';
+ $in_reply_to = $initial_in_reply_to;
+ $references = $initial_in_reply_to || '';
  $subject = $initial_subject;
  $message_num = 0;
  
@@@ -1744,9 -1755,9 +1760,9 @@@ foreach my $t (@files) 
  
        # set up for the next message
        if ($thread && $message_was_sent &&
-               ($chain_reply_to || !defined $reply_to || length($reply_to) == 0 ||
+               ($chain_reply_to || !defined $in_reply_to || length($in_reply_to) == 0 ||
                $message_num == 1)) {
-               $reply_to = $message_id;
+               $in_reply_to = $message_id;
                if (length $references > 0) {
                        $references .= "\n $message_id";
                } else {
diff --combined t/t9001-send-email.sh
index 19601fb546d5a329e4889b352d817fe6f7fb7fb3,c97356a1ba082b26931f0e0d7cb00519483f9db3..e80eacbb1b81a319232c0b5f28aab3c82d795a93
@@@ -6,12 -6,6 +6,12 @@@ test_description='git send-email
  # May be altered later in the test
  PREREQ="PERL"
  
 +replace_variable_fields () {
 +      sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
 +              -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
 +              -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
 +}
 +
  test_expect_success $PREREQ 'prepare reference tree' '
        echo "1A quick brown fox jumps over the" >file &&
        echo "lazy dog" >>file &&
@@@ -178,25 -172,6 +178,25 @@@ test_expect_success $PREREQ 'cc traile
        test_cmp expected-cc commandline1
  '
  
 +test_expect_success $PREREQ 'setup fake get_maintainer.pl script for cc trailer' "
 +      write_script expected-cc-script.sh <<-EOF
 +      echo 'One Person <one@example.com> (supporter:THIS (FOO/bar))'
 +      echo 'Two Person <two@example.com> (maintainer:THIS THING)'
 +      echo 'Third List <three@example.com> (moderated list:THIS THING (FOO/bar))'
 +      echo '<four@example.com> (moderated list:FOR THING)'
 +      echo 'five@example.com (open list:FOR THING (FOO/bar))'
 +      echo 'six@example.com (open list)'
 +      EOF
 +"
 +
 +test_expect_success $PREREQ 'cc trailer with get_maintainer.pl output' '
 +      clean_fake_sendmail &&
 +      git send-email -1 --to=recipient@example.com \
 +              --cc-cmd=./expected-cc-script.sh \
 +              --smtp-server="$(pwd)/fake.sendmail" &&
 +      test_cmp expected-cc commandline1
 +'
 +
  test_expect_success $PREREQ 'setup expect' "
  cat >expected-show-all-headers <<\EOF
  0001-Second.patch
@@@ -224,6 -199,7 +224,7 @@@ Message-Id: MESSAGE-ID-STRIN
  X-Mailer: X-MAILER-STRING
  In-Reply-To: <unique-message-id@example.com>
  References: <unique-message-id@example.com>
+ Reply-To: Reply <reply@example.com>
  
  Result: OK
  EOF
@@@ -316,12 -292,16 +317,13 @@@ test_expect_success $PREREQ 'Show all h
                --dry-run \
                --suppress-cc=sob \
                --from="Example <from@example.com>" \
+               --reply-to="Reply <reply@example.com>" \
                --to=to@example.com \
                --cc=cc@example.com \
                --bcc=bcc@example.com \
                --in-reply-to="<unique-message-id@example.com>" \
                --smtp-server relay.example.com \
 -              $patches |
 -      sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
 -              -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
 -              -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
 +              $patches | replace_variable_fields \
                >actual-show-all-headers &&
        test_cmp expected-show-all-headers actual-show-all-headers
  '
@@@ -576,6 -556,12 +578,6 @@@ Result: O
  EOF
  "
  
 -replace_variable_fields () {
 -      sed     -e "s/^\(Date:\).*/\1 DATE-STRING/" \
 -              -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
 -              -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
 -}
 -
  test_suppression () {
        git send-email \
                --dry-run \