Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] _git: offer changed files relative to current directory



On Sat, Dec 05, 2009 at 03:32:43AM +0300, Alexey I. Froloff wrote:
> __git_changed_files() behavior should match git-commit, pass --relative
> to git-diff-index then looking for changed files.
> 
> Signed-off-by: Alexey I. Froloff <raorn@xxxxxxxxxxxx>
> ---
>  Completion/Unix/Command/_git |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
> index e483133..dd3617b 100644
> --- a/Completion/Unix/Command/_git
> +++ b/Completion/Unix/Command/_git
> @@ -2826,7 +2826,7 @@ __git_unmerged_files () {
>  __git_changed_files () {
>    local -a files
>  
> -  files=(${(ps:\0:)"$(_call_program files git diff-index -z --name-only --no-color HEAD 2>/dev/null)"})
> +  files=(${(ps:\0:)"$(_call_program files git diff-index -z --name-only --no-color --relative HEAD 2>/dev/null)"})
>    __git_command_successful || return
>  
>    _wanted files expl 'index file' _multi_parts $@ - / files
> -- 
> 1.6.5.3
> 
No, this is wrong as far as I recall.
I was solving the same problem before some time. Your solution (i.e.
git-diff-index --relative) only displays the changed files under a
subdirectory, which is incorrect when not in the repository root.

I solved the problem by writing a 50 line or so "ueberfunction" which
manually relativizes the paths returned by git-diff-index to the correct
form required by git-commit (i.e. relative to the current directory, no
matter what it is -- and still displaying all the changed files not only
under the current directory, but from the whole repository).  Seems to
work, but I don't really feel very "proud" of it so I haven't tried to
share it so far.

    ÅtÄpÃn



Messages sorted by: Reverse Date, Date, Thread, Author