This fixes `hub -C mydir merge <URL>` and other commands that might be
invoked with git global arguments by ensuring that those global
arguments are also fowarded to any accompanying `git` commands within
`Before()` and `After()` chains.
The old `args.After("echo", ...)` approach won't cut it on Windows since
there is no `echo` executable. Thus, nothing was printed on Windows.
Instead, expand Args type with extra functionality that allows Go
callbacks after all commands in the chain have been run.
Also, the new `args.NoForward()` is now preferred to `os.Exit()` since
it's more descriptive and allows `defer` in the calling function.
For git commands that are extended by hub, such as `git remote`, the
final git command would get executed without the git global flags
provided when executing hub in the first place.
This most notably broke the usage of `-C <dir>` flag.
Instead of displaying plain text help, `hub help <command>` will now
search for man pages to display.
* If `man` is available, hub first tries to locate the local
`../man/hub-<command>.1` file relative to the `hub` executable. If
found, open it with `man`. If not, execute `man 1 hub-<command>`.
* Otherwise, resort to displaying plain text help.
We used to recognize git global flags based on a hardcoded list.
Whenever git added more global flags, we didn't support them in hub
until we updated the list.
Now, treat all flags coming before the subcommand as global flags. These
are the rules:
1. Initially, every argument except `--help` and `--version` that starts
with a `-` is considered to be a global flag.
2. Additionally, `-c` and `-C` flags have a value.
3. When an argument appears that doesn't match the above rules, assume
that it's the git subcommand and stop global args parsing.
After `browse` was indicated as "GitExtension: false", it now gets
automatically parsed by pflag library. That has an adverse effect that
it loses information about the `--` value being passed, since pflag
treats it as terminator value and swallows it silently.
Now, introduce the `args.Terminator` property to check if terminator was
present or not, and use that in `browse` to restore previous behavior.
`Args.InsertParam` panics about index out of bound if the index is larger than param size. These changes reset the index to param size for such case. This is equivalent to appending new items to the end.
This fixes#812.