* [RFC] best way to show diff of commit
@ 2007-11-25 21:18 Pierre Habouzit
2007-11-25 21:27 ` J. Bruce Fields
2007-11-26 0:25 ` Jan Hudec
0 siblings, 2 replies; 14+ messages in thread
From: Pierre Habouzit @ 2007-11-25 21:18 UTC (permalink / raw)
To: Git ML
[-- Attachment #1: Type: text/plain, Size: 1281 bytes --]
Hi there,
There is specific script I run in my vim with git, that tries to show
from the 'status' git commit shows in the buffer which list of files has
changed, and builds a diff from it quite clumsily[0].
I wonder how hard it would be for git commit to "stash" the current
commit being sent somewhere editors would be able to have a look at (an
alternate index is probably fine). Note that maybe I'm stupid and
overlooked that such a thing already exists. I'd like to have it in two
flavors: normal and amend mode. normal mode would show what the
resulting commit diff looks like, and the amend mode only shows the
incrementall diff the amend adds to the previous commit.
My question is: what do you think is the best way to do that, and
where ?
[0] the issue with this approach is that it's completely broken in
amending mode (does not shows the proper thing), and the generated
diffs aren't excellent, because as an editor plugin, it's hard to
treat renames and copies easily, so I generate really really nasty
diffs in that case too.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-25 21:18 [RFC] best way to show diff of commit Pierre Habouzit
@ 2007-11-25 21:27 ` J. Bruce Fields
2007-11-25 22:09 ` Pierre Habouzit
2007-11-26 0:25 ` Jan Hudec
1 sibling, 1 reply; 14+ messages in thread
From: J. Bruce Fields @ 2007-11-25 21:27 UTC (permalink / raw)
To: Pierre Habouzit, Git ML
On Sun, Nov 25, 2007 at 10:18:31PM +0100, Pierre Habouzit wrote:
> There is specific script I run in my vim with git, that tries to show
> from the 'status' git commit shows in the buffer which list of files has
> changed, and builds a diff from it quite clumsily[0].
>
> I wonder how hard it would be for git commit to "stash" the current
> commit being sent somewhere editors would be able to have a look at (an
> alternate index is probably fine). Note that maybe I'm stupid and
> overlooked that such a thing already exists. I'd like to have it in two
> flavors: normal and amend mode. normal mode would show what the
> resulting commit diff looks like, and the amend mode only shows the
> incrementall diff the amend adds to the previous commit.
>
> My question is: what do you think is the best way to do that, and
> where ?
Have you checked whether "git-commit -v" already does what you want?
--b.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-25 21:27 ` J. Bruce Fields
@ 2007-11-25 22:09 ` Pierre Habouzit
2007-11-25 22:27 ` Junio C Hamano
0 siblings, 1 reply; 14+ messages in thread
From: Pierre Habouzit @ 2007-11-25 22:09 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: Git ML
[-- Attachment #1: Type: text/plain, Size: 1735 bytes --]
On Sun, Nov 25, 2007 at 09:27:48PM +0000, J. Bruce Fields wrote:
> On Sun, Nov 25, 2007 at 10:18:31PM +0100, Pierre Habouzit wrote:
> > There is specific script I run in my vim with git, that tries to show
> > from the 'status' git commit shows in the buffer which list of files has
> > changed, and builds a diff from it quite clumsily[0].
> >
> > I wonder how hard it would be for git commit to "stash" the current
> > commit being sent somewhere editors would be able to have a look at (an
> > alternate index is probably fine). Note that maybe I'm stupid and
> > overlooked that such a thing already exists. I'd like to have it in two
> > flavors: normal and amend mode. normal mode would show what the
> > resulting commit diff looks like, and the amend mode only shows the
> > incrementall diff the amend adds to the previous commit.
> >
> > My question is: what do you think is the best way to do that, and
> > where ?
>
> Have you checked whether "git-commit -v" already does what you want?
Hmm it doesn't because I would have to call git commit -v each time I
commit and well I _like_ having the status better. And moreover I want
the diff to go in a separated buffer too.
I'd rather have some kind of way to have git-commit let a trail of
what he's doing if the user validate the commit, and use that from the
editor. I'm sure it would be useful to simple GUIs as well (most
advanced GUIs would like to have fine control to what gets commited and
are likely to have the command like used quite right).
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-25 22:09 ` Pierre Habouzit
@ 2007-11-25 22:27 ` Junio C Hamano
2007-11-25 22:31 ` Pierre Habouzit
2007-11-25 23:43 ` David Brown
0 siblings, 2 replies; 14+ messages in thread
From: Junio C Hamano @ 2007-11-25 22:27 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: J. Bruce Fields, Git ML
Pierre Habouzit <madcoder@debian.org> writes:
> Hmm it doesn't because I would have to call git commit -v each time I
> commit and well I _like_ having the status better. And moreover I want
> the diff to go in a separated buffer too.
I've never felt it a problem while editing the log message in Emacs.
Don't enhanced vi implementations let you split the same buffer into
two allowing you to view different portions of it these days?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-25 22:27 ` Junio C Hamano
@ 2007-11-25 22:31 ` Pierre Habouzit
2007-11-25 22:52 ` Junio C Hamano
2007-11-25 23:43 ` David Brown
1 sibling, 1 reply; 14+ messages in thread
From: Pierre Habouzit @ 2007-11-25 22:31 UTC (permalink / raw)
To: Junio C Hamano; +Cc: J. Bruce Fields, Git ML
[-- Attachment #1: Type: text/plain, Size: 1012 bytes --]
On Sun, Nov 25, 2007 at 10:27:09PM +0000, Junio C Hamano wrote:
> Pierre Habouzit <madcoder@debian.org> writes:
>
> > Hmm it doesn't because I would have to call git commit -v each time I
> > commit and well I _like_ having the status better. And moreover I want
> > the diff to go in a separated buffer too.
>
> I've never felt it a problem while editing the log message in Emacs.
>
> Don't enhanced vi implementations let you split the same buffer into
> two allowing you to view different portions of it these days?
Well, maybe I could write my plugin so that it cuts the diff out from
the main buffer indeed, though I will have to learn using git commit -v
instead of git commit :P
That and the fact that the syntax colorization of the diff doesn't
work, but it's probably not up to git to fix that.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-25 22:31 ` Pierre Habouzit
@ 2007-11-25 22:52 ` Junio C Hamano
2007-11-25 23:47 ` Pierre Habouzit
0 siblings, 1 reply; 14+ messages in thread
From: Junio C Hamano @ 2007-11-25 22:52 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: J. Bruce Fields, Git ML
Pierre Habouzit <madcoder@debian.org> writes:
> On Sun, Nov 25, 2007 at 10:27:09PM +0000, Junio C Hamano wrote:
>> Pierre Habouzit <madcoder@debian.org> writes:
>>
>> > Hmm it doesn't because I would have to call git commit -v each time I
>> > commit and well I _like_ having the status better. And moreover I want
>> > the diff to go in a separated buffer too.
>>
>> I've never felt it a problem while editing the log message in Emacs.
>>
>> Don't enhanced vi implementations let you split the same buffer into
>> two allowing you to view different portions of it these days?
>
> Well, maybe I could write my plugin so that it cuts the diff out from
> the main buffer indeed, though I will have to learn using git commit -v
> instead of git commit :P
>
> That and the fact that the syntax colorization of the diff doesn't
> work, but it's probably not up to git to fix that.
Or you can use pre-commit hook (which will be run with GIT_INDEX_FILE
set to the index file used for the commit) to generate the diff in a
separate file, and set EDITOR (or GIT_EDITOR) to a script around vim to
open the given COMMIT_EDITMSG as well as that file you create.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-25 22:27 ` Junio C Hamano
2007-11-25 22:31 ` Pierre Habouzit
@ 2007-11-25 23:43 ` David Brown
1 sibling, 0 replies; 14+ messages in thread
From: David Brown @ 2007-11-25 23:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Pierre Habouzit, J. Bruce Fields, Git ML
On Sun, Nov 25, 2007 at 02:27:09PM -0800, Junio C Hamano wrote:
>Pierre Habouzit <madcoder@debian.org> writes:
>
>> Hmm it doesn't because I would have to call git commit -v each time I
>> commit and well I _like_ having the status better. And moreover I want
>> the diff to go in a separated buffer too.
>
>I've never felt it a problem while editing the log message in Emacs.
>
>Don't enhanced vi implementations let you split the same buffer into
>two allowing you to view different portions of it these days?
Yes, certainly with vim, which is what most distributions seem to include
as the enhanced vim. I have noticed that there seem to be fewer vim users
that figure out these kinds of things than emacs users, though.
Dave
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-25 22:52 ` Junio C Hamano
@ 2007-11-25 23:47 ` Pierre Habouzit
0 siblings, 0 replies; 14+ messages in thread
From: Pierre Habouzit @ 2007-11-25 23:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: J. Bruce Fields, Git ML
[-- Attachment #1: Type: text/plain, Size: 1582 bytes --]
On Sun, Nov 25, 2007 at 10:52:28PM +0000, Junio C Hamano wrote:
> Pierre Habouzit <madcoder@debian.org> writes:
>
> > On Sun, Nov 25, 2007 at 10:27:09PM +0000, Junio C Hamano wrote:
> >> Pierre Habouzit <madcoder@debian.org> writes:
> >>
> >> > Hmm it doesn't because I would have to call git commit -v each time I
> >> > commit and well I _like_ having the status better. And moreover I want
> >> > the diff to go in a separated buffer too.
> >>
> >> I've never felt it a problem while editing the log message in Emacs.
> >>
> >> Don't enhanced vi implementations let you split the same buffer into
> >> two allowing you to view different portions of it these days?
> >
> > Well, maybe I could write my plugin so that it cuts the diff out from
> > the main buffer indeed, though I will have to learn using git commit -v
> > instead of git commit :P
> >
> > That and the fact that the syntax colorization of the diff doesn't
> > work, but it's probably not up to git to fix that.
>
> Or you can use pre-commit hook (which will be run with GIT_INDEX_FILE
> set to the index file used for the commit) to generate the diff in a
> separate file, and set EDITOR (or GIT_EDITOR) to a script around vim to
> open the given COMMIT_EDITMSG as well as that file you create.
*ha* _that_ sounds more like the kind of things I was lurking for.
Sounds like a plan thanks :)
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-25 21:18 [RFC] best way to show diff of commit Pierre Habouzit
2007-11-25 21:27 ` J. Bruce Fields
@ 2007-11-26 0:25 ` Jan Hudec
2007-11-26 8:42 ` Pierre Habouzit
2007-11-26 8:47 ` Pierre Habouzit
1 sibling, 2 replies; 14+ messages in thread
From: Jan Hudec @ 2007-11-26 0:25 UTC (permalink / raw)
To: Pierre Habouzit, Git ML; +Cc: Kristian Høgsberg
On Sun, Nov 25, 2007 at 22:18:31 +0100, Pierre Habouzit wrote:
> Hi there,
>
> There is specific script I run in my vim with git, that tries to show
> from the 'status' git commit shows in the buffer which list of files has
> changed, and builds a diff from it quite clumsily[0].
>
> I wonder how hard it would be for git commit to "stash" the current
> commit being sent somewhere editors would be able to have a look at (an
> alternate index is probably fine). Note that maybe I'm stupid and
> overlooked that such a thing already exists. I'd like to have it in two
> flavors: normal and amend mode. normal mode would show what the
> resulting commit diff looks like, and the amend mode only shows the
> incrementall diff the amend adds to the previous commit.
Such thing does already exist. When the editor is called, the index pointed
to by GIT_INDEX_FILE (or the default index if unset) is exactly what will
be in the commit.
Hm, looking at the builtin-commit.c that is currently cooking in next, it
does not seem to be the case there. It probably should, so the editor can
inspect what will be commited.
> My question is: what do you think is the best way to do that, and
> where ?
Are you talking about the ftplugins/git.vim script from vim-scripts package,
right?
All it needs to do is call 'git diff --cached'. The below patch seems to work
here (tried commit, commit -a, commit --amend, commit -a --amend and commit
from subdirectory and they seemed to all work).
> [0] the issue with this approach is that it's completely broken in
> amending mode (does not shows the proper thing), and the generated
I didn't find any issue with amending mode (showed incremental diff for me
all right). The problem was when a file was being touched by the commit but
work tree had unstaged changes. Such changes were shown when they shouldn't.
> diffs aren't excellent, because as an editor plugin, it's hard to
> treat renames and copies easily, so I generate really really nasty
> diffs in that case too.
With --cached, detecting copies is just a matter of adding -C. In the patch
below I added only one -C, but it should probably be user-configurable to use
no, one or two (equivalent of --find-copies-harder).
--
Jan 'Bulb' Hudec <bulb@ucw.cz>
---8<---
--- vim-scripts/ftplugin/git.vim.orig 2007-07-24 09:46:19.000000000 +0200
+++ vim-scripts/ftplugin/git.vim 2007-11-26 01:01:59.000000000 +0100
@@ -14,41 +14,6 @@
"{{{ function Git_diff_windows
function! Git_diff_windows(vertsplit, auto)
- 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 == '# Changes to be committed:'
- let i = i + 3
- 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, '^#[^:]*:.*->\s*\(.*\)\s*$', '\1', '')
- let list_of_files = list_of_files . ' '.file
- let file = substitute(line, '^#[^:]*:\s*\(.*\)\s*->.*$', '\1', '')
- let list_of_files = list_of_files . ' '.file
- elseif line =~ '^#\s*[a-z ]*:'
- let file = substitute(line, '^#[^:]*:\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
if a:vertsplit
rightbelow vnew
@@ -56,15 +21,8 @@
rightbelow new
endif
silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile
- let gitDir = system('git rev-parse --git-dir 2>/dev/null')
- let gitDir = substitute(gitDir, '.git\n', '', '')
- let wd = getcwd()
- if gitDir != ''
- exe 'cd '.gitDir
- endif
- exe 'normal :r!LANG=C git diff HEAD -- ' . list_of_files . "\n1Gdd"
- exe 'normal :r!LANG=C git diff --stat HEAD -- ' . list_of_files . "\no\<esc>1GddO\<esc>"
- exe 'cd '.wd
+ exe "normal :r!LANG=C git diff --cached -C\n1Gdd"
+ exe "normal :r!LANG=C git diff --stat --cached -C\no\<esc>1GddO\<esc>"
setlocal nomodifiable
noremap <buffer> q :bw<cr>
if a:auto
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-26 0:25 ` Jan Hudec
@ 2007-11-26 8:42 ` Pierre Habouzit
2007-11-26 8:47 ` Pierre Habouzit
1 sibling, 0 replies; 14+ messages in thread
From: Pierre Habouzit @ 2007-11-26 8:42 UTC (permalink / raw)
To: Jan Hudec; +Cc: Git ML, Kristian Høgsberg
[-- Attachment #1: Type: text/plain, Size: 4079 bytes --]
On Mon, Nov 26, 2007 at 12:25:19AM +0000, Jan Hudec wrote:
> On Sun, Nov 25, 2007 at 22:18:31 +0100, Pierre Habouzit wrote:
> > My question is: what do you think is the best way to do that, and
> > where ?
>
> Are you talking about the ftplugins/git.vim script from vim-scripts package,
> right?
Yes, its author.
> All it needs to do is call 'git diff --cached'. The below patch seems to work
> here (tried commit, commit -a, commit --amend, commit -a --amend and commit
> from subdirectory and they seemed to all work).
Damn if that's so simple, I really feel like a big fool now.
> > [0] the issue with this approach is that it's completely broken in
> > amending mode (does not shows the proper thing), and the generated
>
> I didn't find any issue with amending mode (showed incremental diff for me
> all right). The problem was when a file was being touched by the commit but
> work tree had unstaged changes. Such changes were shown when they shouldn't.
Yep, that's the point.
> > diffs aren't excellent, because as an editor plugin, it's hard to
> > treat renames and copies easily, so I generate really really nasty
> > diffs in that case too.
>
> With --cached, detecting copies is just a matter of adding -C. In the patch
> below I added only one -C, but it should probably be user-configurable to use
> no, one or two (equivalent of --find-copies-harder).
Sure, I'll do that obviously.
Thanks a lot for the tip.
>
> --
> Jan 'Bulb' Hudec <bulb@ucw.cz>
>
> ---8<---
> --- vim-scripts/ftplugin/git.vim.orig 2007-07-24 09:46:19.000000000 +0200
> +++ vim-scripts/ftplugin/git.vim 2007-11-26 01:01:59.000000000 +0100
> @@ -14,41 +14,6 @@
> "{{{ function Git_diff_windows
>
> function! Git_diff_windows(vertsplit, auto)
> - 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 == '# Changes to be committed:'
> - let i = i + 3
> - 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, '^#[^:]*:.*->\s*\(.*\)\s*$', '\1', '')
> - let list_of_files = list_of_files . ' '.file
> - let file = substitute(line, '^#[^:]*:\s*\(.*\)\s*->.*$', '\1', '')
> - let list_of_files = list_of_files . ' '.file
> - elseif line =~ '^#\s*[a-z ]*:'
> - let file = substitute(line, '^#[^:]*:\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
>
> if a:vertsplit
> rightbelow vnew
> @@ -56,15 +21,8 @@
> rightbelow new
> endif
> silent! setlocal ft=diff previewwindow bufhidden=delete nobackup noswf nobuflisted nowrap buftype=nofile
> - let gitDir = system('git rev-parse --git-dir 2>/dev/null')
> - let gitDir = substitute(gitDir, '.git\n', '', '')
> - let wd = getcwd()
> - if gitDir != ''
> - exe 'cd '.gitDir
> - endif
> - exe 'normal :r!LANG=C git diff HEAD -- ' . list_of_files . "\n1Gdd"
> - exe 'normal :r!LANG=C git diff --stat HEAD -- ' . list_of_files . "\no\<esc>1GddO\<esc>"
> - exe 'cd '.wd
> + exe "normal :r!LANG=C git diff --cached -C\n1Gdd"
> + exe "normal :r!LANG=C git diff --stat --cached -C\no\<esc>1GddO\<esc>"
> setlocal nomodifiable
> noremap <buffer> q :bw<cr>
> if a:auto
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [RFC] best way to show diff of commit
2007-11-26 0:25 ` Jan Hudec
2007-11-26 8:42 ` Pierre Habouzit
@ 2007-11-26 8:47 ` Pierre Habouzit
2007-11-26 8:59 ` [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well Pierre Habouzit
1 sibling, 1 reply; 14+ messages in thread
From: Pierre Habouzit @ 2007-11-26 8:47 UTC (permalink / raw)
To: Jan Hudec; +Cc: Git ML, Kristian Høgsberg
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]
On Mon, Nov 26, 2007 at 12:25:19AM +0000, Jan Hudec wrote:
> Hm, looking at the builtin-commit.c that is currently cooking in next, it
> does not seem to be the case there. It probably should, so the editor can
> inspect what will be commited.
I confirm that it's broken now, but that it works at the top of main.
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well.
2007-11-26 8:47 ` Pierre Habouzit
@ 2007-11-26 8:59 ` Pierre Habouzit
2007-11-26 9:38 ` Pierre Habouzit
2007-11-26 15:27 ` Kristian Høgsberg
0 siblings, 2 replies; 14+ messages in thread
From: Pierre Habouzit @ 2007-11-26 8:59 UTC (permalink / raw)
To: Jan Hudec, Git ML, Kristian Høgsberg, Junio C Hamano
[-- Attachment #1: Type: text/plain, Size: 2602 bytes --]
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
And here's the fix for this tiny problem …
builtin-commit.c | 9 ++++++---
builtin-tag.c | 6 +++---
strbuf.h | 2 +-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 5d27102..6e6b9f2 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -748,9 +748,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
/* Get the commit message and validate it */
header_len = sb.len;
- if (!no_edit)
- launch_editor(git_path(commit_editmsg), &sb);
- else if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
+ if (!no_edit) {
+ char index[PATH_MAX];
+ const char *env[2] = { index, NULL };
+ snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
+ launch_editor(git_path(commit_editmsg), &sb, env);
+ } else if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
rollback_index_files();
die("could not read commit message\n");
}
diff --git a/builtin-tag.c b/builtin-tag.c
index e89b201..8cc7f9c 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -23,7 +23,7 @@ static const char * const git_tag_usage[] = {
static char signingkey[1000];
-void launch_editor(const char *path, struct strbuf *buffer)
+void launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
{
const char *editor, *terminal;
@@ -49,7 +49,7 @@ void launch_editor(const char *path, struct strbuf *buffer)
if (strcmp(editor, ":")) {
const char *args[] = { editor, path, NULL };
- if (run_command_v_opt(args, 0))
+ if (run_command_v_opt_cd_env(args, 0, NULL, env))
die("There was a problem with the editor %s.", editor);
}
@@ -318,7 +318,7 @@ static void create_tag(const unsigned char *object, const char *tag,
write_or_die(fd, tag_template, strlen(tag_template));
close(fd);
- launch_editor(path, buf);
+ launch_editor(path, buf, NULL);
unlink(path);
free(path);
diff --git a/strbuf.h b/strbuf.h
index 8334a9b..36d61db 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -117,6 +117,6 @@ extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
extern int strbuf_getline(struct strbuf *, FILE *, int);
extern void stripspace(struct strbuf *buf, int skip_comments);
-extern void launch_editor(const char *path, struct strbuf *buffer);
+extern void launch_editor(const char *path, struct strbuf *buffer, const char *const *env);
#endif /* STRBUF_H */
--
1.5.3.6.2015.g9baba-dirty
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well.
2007-11-26 8:59 ` [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well Pierre Habouzit
@ 2007-11-26 9:38 ` Pierre Habouzit
2007-11-26 15:27 ` Kristian Høgsberg
1 sibling, 0 replies; 14+ messages in thread
From: Pierre Habouzit @ 2007-11-26 9:38 UTC (permalink / raw)
To: Git ML
[-- Attachment #1: Type: text/plain, Size: 268 bytes --]
and here's the updated git.vim:
http://www.vim.org/scripts/script.php?script_id=1934
--
·O· Pierre Habouzit
··O madcoder@debian.org
OOO http://www.madism.org
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well.
2007-11-26 8:59 ` [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well Pierre Habouzit
2007-11-26 9:38 ` Pierre Habouzit
@ 2007-11-26 15:27 ` Kristian Høgsberg
1 sibling, 0 replies; 14+ messages in thread
From: Kristian Høgsberg @ 2007-11-26 15:27 UTC (permalink / raw)
To: Pierre Habouzit; +Cc: Jan Hudec, Git ML, Junio C Hamano
On Mon, 2007-11-26 at 09:59 +0100, Pierre Habouzit wrote:
> Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> ---
>
> And here's the fix for this tiny problem …
That looks good to me.
Signed-off-by: Kristian Høgsberg <krh@redhat.com>
>
>
> builtin-commit.c | 9 ++++++---
> builtin-tag.c | 6 +++---
> strbuf.h | 2 +-
> 3 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/builtin-commit.c b/builtin-commit.c
> index 5d27102..6e6b9f2 100644
> --- a/builtin-commit.c
> +++ b/builtin-commit.c
> @@ -748,9 +748,12 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
>
> /* Get the commit message and validate it */
> header_len = sb.len;
> - if (!no_edit)
> - launch_editor(git_path(commit_editmsg), &sb);
> - else if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
> + if (!no_edit) {
> + char index[PATH_MAX];
> + const char *env[2] = { index, NULL };
> + snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
> + launch_editor(git_path(commit_editmsg), &sb, env);
> + } else if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
> rollback_index_files();
> die("could not read commit message\n");
> }
> diff --git a/builtin-tag.c b/builtin-tag.c
> index e89b201..8cc7f9c 100644
> --- a/builtin-tag.c
> +++ b/builtin-tag.c
> @@ -23,7 +23,7 @@ static const char * const git_tag_usage[] = {
>
> static char signingkey[1000];
>
> -void launch_editor(const char *path, struct strbuf *buffer)
> +void launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
> {
> const char *editor, *terminal;
>
> @@ -49,7 +49,7 @@ void launch_editor(const char *path, struct strbuf *buffer)
> if (strcmp(editor, ":")) {
> const char *args[] = { editor, path, NULL };
>
> - if (run_command_v_opt(args, 0))
> + if (run_command_v_opt_cd_env(args, 0, NULL, env))
> die("There was a problem with the editor %s.", editor);
> }
>
> @@ -318,7 +318,7 @@ static void create_tag(const unsigned char *object, const char *tag,
> write_or_die(fd, tag_template, strlen(tag_template));
> close(fd);
>
> - launch_editor(path, buf);
> + launch_editor(path, buf, NULL);
>
> unlink(path);
> free(path);
> diff --git a/strbuf.h b/strbuf.h
> index 8334a9b..36d61db 100644
> --- a/strbuf.h
> +++ b/strbuf.h
> @@ -117,6 +117,6 @@ extern int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint);
> extern int strbuf_getline(struct strbuf *, FILE *, int);
>
> extern void stripspace(struct strbuf *buf, int skip_comments);
> -extern void launch_editor(const char *path, struct strbuf *buffer);
> +extern void launch_editor(const char *path, struct strbuf *buffer, const char *const *env);
>
> #endif /* STRBUF_H */
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2007-11-26 15:33 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-25 21:18 [RFC] best way to show diff of commit Pierre Habouzit
2007-11-25 21:27 ` J. Bruce Fields
2007-11-25 22:09 ` Pierre Habouzit
2007-11-25 22:27 ` Junio C Hamano
2007-11-25 22:31 ` Pierre Habouzit
2007-11-25 22:52 ` Junio C Hamano
2007-11-25 23:47 ` Pierre Habouzit
2007-11-25 23:43 ` David Brown
2007-11-26 0:25 ` Jan Hudec
2007-11-26 8:42 ` Pierre Habouzit
2007-11-26 8:47 ` Pierre Habouzit
2007-11-26 8:59 ` [PATCH] Make builtin-commit.c export GIT_INDEX_FILE for launch_editor as well Pierre Habouzit
2007-11-26 9:38 ` Pierre Habouzit
2007-11-26 15:27 ` Kristian Høgsberg
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).