git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Peter Baumann" <peter.baumann@gmail.com>
To: "Pierre Habouzit" <madcoder@debian.org>
Cc: git@vger.kernel.org, "Jeff King" <peff@peff.net>
Subject: Re: [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer.
Date: Tue, 17 Oct 2006 12:59:53 +0200	[thread overview]
Message-ID: <802d21790610170359v3f17438dn8009ae9a55b2405c@mail.gmail.com> (raw)
In-Reply-To: <200610171238.04372.madcoder@debian.org>

2006/10/17, Pierre Habouzit <madcoder@debian.org>:
> Le mar 17 octobre 2006 10:22, Peter Baumann a écrit :
> > 2006/10/17, Pierre Habouzit <madcoder@debian.org>:
> > > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> > > ---
> > >  contrib/vim/README                 |    6 ++++
> > >  contrib/vim/ftplugin/gitcommit.vim |   61
> > > ++++++++++++++++++++++++++++++++++++ 2 files changed, 67
> > > insertions(+), 0 deletions(-)
> > >
> > > diff --git a/contrib/vim/README b/contrib/vim/README
> > > index 9e7881f..26c1682 100644
> > > --- a/contrib/vim/README
> > > +++ b/contrib/vim/README
> > > @@ -6,3 +6,9 @@ To syntax highlight git's commit message
> > >       $ cat >>$HOME/.vimrc <<'EOF'
> > >       autocmd BufNewFile,BufRead COMMIT_EDITMSG set
> > > filetype=gitcommit EOF
> > > +
> > > +To use the fancy split-view with the currently commited diff, you
> > > need to: +  1. Copy ftplugin/gitcommit.vim to vim's ftplugin
> > > directory: +     $ mkdir -p $HOME/.vim/ftplugin
> > > +     $ cp ftplugin/gitcommit.vim $HOME/.vim/ftplugin
> > > +  2. Auto-detect the editing of git commit files (see above).
> > > diff --git a/contrib/vim/ftplugin/gitcommit.vim
> > > b/contrib/vim/ftplugin/gitcommit.vim new file mode 100644
> > > index 0000000..f9efd59
> > > --- /dev/null
> > > +++ b/contrib/vim/ftplugin/gitcommit.vim
> > > @@ -0,0 +1,61 @@
> > > +if exists("b:did_ftplugin")
> > > +  finish
> > > +endif
> > > +
> > > +let b:did_ftplugin = 1
> > > +
> > > +setlocal tw=74
> > > +setlocal nowarn nowb
> > > +
> > > +"{{{ function Git_diff_windows
> > > +
> > > +function! Git_diff_windows()
> > > +    let i = 0
> > > +    let list_of_files = ''
> > > +
> > > +    " drop everything until '#  (will commit)' and the next empty
> > > line +    while i <= line('$')
> > > +        let line = getline(i)
> > > +        if line =~ '^#\s*(will commit)$'
> > > +            let i = i + 2
> > > +            break
> > > +        endif
> > > +
> > > +        let i = i + 1
> > > +    endwhile
> > > +
> > > +    " read file names until we have EOF or an empty line
> > > +    while i <= line('$')
> > > +        let line = getline(i)
> > > +        if line =~ '^#\s*[a-z ]*:.*->.*$'
> > > +            let file = substitute(line,
> > > '\v^#[^:]*:.*->\s*(.*)\s*$', '\1', '') +            let
> > > list_of_files = list_of_files . ' '.file
> > > +            let file = substitute(line,
> > > '\v^#[^:]*:\s*(.*)\s*->.*$', '\1', '') +            let
> > > list_of_files = list_of_files . ' '.file
> > > +        elseif line =~ '^#\s*[a-z ]*:'
> > > +            let file = substitute(line, '\v^#[^:]*:\s*(.*)\s*$',
> > > '\1', '') +            let list_of_files = list_of_files . ' '.file
> > > +        elseif line =~ '^#\s*$'
> > > +            break
> > > +        endif
> > > +
> > > +        let i = i + 1
> > > +    endwhile
> > > +
> > > +    if list_of_files == ""
> > > +        return
> > > +    endif
> > > +
> > > +    rightbelow vnew
> >
> > I find it confusing that you split vertically, especially if I work
> > in small terminals.
> > I would prefere a horizontal split, thats why I changed it to the way
> > to the way it is
> > handled in the svn.vim commit case:
> >
> > below new
> >
> > > +    silent! setlocal ft=diff previewwindow bufhidden=delete
> > > nobackup noswf nobuflisted nowrap buftype=nofile +    exe 'normal
> > > :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . "\n1Gdd" +
> > > exe 'normal :r!LANG=C cd ..; git diff HEAD -- ' . list_of_files . "
> > > \| git apply --stat\no\<esc>1GddO\<esc>"
> >
> > Why changing directory? I had to remove the cd .. to make it work.
> > Otherwise git diff couldn't find the repository.
>
> because for me, wherever I'm from, the cwd is .git/ but it's maybe due
> to the fact that I use autochdir, I don't know.
>

Wouldn't it make sense to use something like 'git-rev-parse --git-dir' or
'git-rev-parse --show-cdup' to get to the root of the repository?

Greetings,
  Peter

  reply	other threads:[~2006-10-17 11:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-17  0:31 [PATCH] be more vim-ish, and also syntax hilight Signed-off-by lines Pierre Habouzit
2006-10-17  0:31 ` [PATCH] nice ftplugin for vim, that shows the commited diff in a split'ed buffer Pierre Habouzit
2006-10-17  8:22   ` Peter Baumann
2006-10-17 10:38     ` Pierre Habouzit
2006-10-17 10:59       ` Peter Baumann [this message]
2006-10-17 11:04         ` Pierre Habouzit
2006-10-17 21:48           ` Christian MICHON
2006-10-17 22:04             ` Junio C Hamano
2006-10-18  1:57             ` Petr Baudis
2006-10-17  7:46 ` [PATCH] be more vim-ish, and also syntax hilight Signed-off-by lines Junio C Hamano
2006-10-18  0:38   ` contrib/vim patches, replace the previous set Pierre Habouzit
2006-10-18  0:39   ` Pierre Habouzit
2006-10-18  0:39     ` [PATCH] be more vim-ish, and also syntax hilight Signed-off-by lines Pierre Habouzit
2006-10-18  0:39       ` [PATCH] Nice ftplugin for vim, that shows the commited diff in a split'ed buffer Pierre Habouzit
2006-10-18  0:40         ` Pierre Habouzit
2006-10-18  0:47       ` Make the ftplugin right wrt gitdir Pierre Habouzit
2006-10-18  0:47         ` [PATCH] be more robust wrt the git-dir Pierre Habouzit
2006-10-18  7:02         ` Make the ftplugin right wrt gitdir Jeff King
2006-10-18  8:10           ` Pierre Habouzit
2006-10-18  9:02             ` Jeff King
2006-10-18  9:07               ` Pierre Habouzit
2006-10-18  9:46                 ` Jeff King
2006-10-18  6:59       ` [PATCH] be more vim-ish, and also syntax hilight Signed-off-by lines Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=802d21790610170359v3f17438dn8009ae9a55b2405c@mail.gmail.com \
    --to=peter.baumann@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=madcoder@debian.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).