All of lore.kernel.org
 help / color / mirror / Atom feed
* git-walkthrough-add script
@ 2008-01-04  6:14 William Morgan
  2008-01-04  7:26 ` Jeff King
  2008-01-04 23:26 ` Pedro Melo
  0 siblings, 2 replies; 16+ messages in thread
From: William Morgan @ 2008-01-04  6:14 UTC (permalink / raw)
  To: Git Mailing List

Hi all,

I've written a little script to do darcs-style hunk-by-hunk
walkthroughs. It's based on the git-hunk-commit script that was floating
around. Maybe someone else will find it useful.

http://git-wt-commit.rubyforge.org/

-- 
William <wmorgan-git@masanjin.net>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-04  6:14 git-walkthrough-add script William Morgan
@ 2008-01-04  7:26 ` Jeff King
  2008-01-04 18:31   ` William Morgan
  2008-01-04 23:26 ` Pedro Melo
  1 sibling, 1 reply; 16+ messages in thread
From: Jeff King @ 2008-01-04  7:26 UTC (permalink / raw)
  To: William Morgan; +Cc: Git Mailing List

On Thu, Jan 03, 2008 at 10:14:31PM -0800, William Morgan wrote:

> I've written a little script to do darcs-style hunk-by-hunk
> walkthroughs. It's based on the git-hunk-commit script that was floating
> around. Maybe someone else will find it useful.
> 
> http://git-wt-commit.rubyforge.org/

It didn't work for me, since the diff parsing failed to match my
particular colors (I needed /^.....diff/ instead of /^....diff/). I
suspect the color matching needs to be more flexible to be generally
useful.

However, I'm not clear what advantages this has over "git add -p".

-Peff

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-04  7:26 ` Jeff King
@ 2008-01-04 18:31   ` William Morgan
  2008-01-04 21:07     ` Jeff King
  0 siblings, 1 reply; 16+ messages in thread
From: William Morgan @ 2008-01-04 18:31 UTC (permalink / raw)
  To: Git Mailing List

Excerpts from Jeff King's message of Thu Jan 03 23:26:50 -0800 2008:
> It didn't work for me, since the diff parsing failed to match my
> particular colors (I needed /^.....diff/ instead of /^....diff/). I
> suspect the color matching needs to be more flexible to be generally
> useful.

Fixed, thanks.

> However, I'm not clear what advantages this has over "git add -p".

A better interface. (Where by "better", I mean, behaves how I personally
prefer.)

-- 
William <wmorgan-git@masanjin.net>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-04 18:31   ` William Morgan
@ 2008-01-04 21:07     ` Jeff King
  2008-01-05  2:37       ` William Morgan
  0 siblings, 1 reply; 16+ messages in thread
From: Jeff King @ 2008-01-04 21:07 UTC (permalink / raw)
  To: William Morgan; +Cc: Git Mailing List

On Fri, Jan 04, 2008 at 10:31:03AM -0800, William Morgan wrote:

> > However, I'm not clear what advantages this has over "git add -p".
> 
> A better interface. (Where by "better", I mean, behaves how I personally
> prefer.)

OK. If it works for you, then I'm not one to say you shouldn't use it.
But if you have interface improvement suggestions for "git-add -i" or
"git-add -p", I'm sure they would be well-received (post-1.5.4 release,
of course).

-Peff

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-04  6:14 git-walkthrough-add script William Morgan
  2008-01-04  7:26 ` Jeff King
@ 2008-01-04 23:26 ` Pedro Melo
  2008-01-04 23:28   ` Junio C Hamano
                     ` (2 more replies)
  1 sibling, 3 replies; 16+ messages in thread
From: Pedro Melo @ 2008-01-04 23:26 UTC (permalink / raw)
  To: William Morgan; +Cc: Git Mailing List

Hi,

On Jan 4, 2008, at 6:14 AM, William Morgan wrote:

> I've written a little script to do darcs-style hunk-by-hunk
> walkthroughs. It's based on the git-hunk-commit script that was  
> floating
> around. Maybe someone else will find it useful.
>
> http://git-wt-commit.rubyforge.org/

Maybe I'm doing something wrong, but comparing git-add -p with your  
script, git-add -p is more darcs'ish. With git-add, if I have several  
changes in the same file, I get to choose per hunk.

You script asks me to add all the changes in the same file at once.

Best regards,
-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo@simplicidade.org
Use XMPP!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-04 23:26 ` Pedro Melo
@ 2008-01-04 23:28   ` Junio C Hamano
  2008-01-05  0:02   ` William Morgan
  2008-01-05  1:00   ` Miklos Vajna
  2 siblings, 0 replies; 16+ messages in thread
From: Junio C Hamano @ 2008-01-04 23:28 UTC (permalink / raw)
  To: Pedro Melo; +Cc: William Morgan, Git Mailing List

Pedro Melo <melo@simplicidade.org> writes:

> Maybe I'm doing something wrong, but comparing git-add -p with your
> script, git-add -p is more darcs'ish. With git-add, if I have several
> changes in the same file, I get to choose per hunk.

Heh, thanks from somebody who did "add -i" who admits he used
darcs for a few months ;-).

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-04 23:26 ` Pedro Melo
  2008-01-04 23:28   ` Junio C Hamano
@ 2008-01-05  0:02   ` William Morgan
  2008-01-05  0:17     ` Pedro Melo
  2008-01-05  1:00   ` Miklos Vajna
  2 siblings, 1 reply; 16+ messages in thread
From: William Morgan @ 2008-01-05  0:02 UTC (permalink / raw)
  To: Git Mailing List

Excerpts from Pedro Melo's message of Fri Jan 04 15:26:41 -0800 2008:
> You script asks me to add all the changes in the same file at once.

It shouldn't. The whole point is to walk through and allow selection on
a per-hunk basis.

Maybe I'm parsing the output of git diff incorrectly and not picking up
hunk boundaries? Would you mind sending the output of a git diff that
results in this behavior?

-- 
William <wmorgan-git@masanjin.net>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-05  0:02   ` William Morgan
@ 2008-01-05  0:17     ` Pedro Melo
  0 siblings, 0 replies; 16+ messages in thread
From: Pedro Melo @ 2008-01-05  0:17 UTC (permalink / raw)
  To: William Morgan; +Cc: Git Mailing List

Hi,

On Jan 5, 2008, at 12:02 AM, William Morgan wrote:
> Excerpts from Pedro Melo's message of Fri Jan 04 15:26:41 -0800 2008:
>> You script asks me to add all the changes in the same file at once.
>
> It shouldn't. The whole point is to walk through and allow  
> selection on
> a per-hunk basis.
>
> Maybe I'm parsing the output of git diff incorrectly and not  
> picking up
> hunk boundaries? Would you mind sending the output of a git diff that
> results in this behavior?

I used a new git repo, just to test your script.

The diff is:

------ snip
diff --git a/a b/a
index b6b8cab..456bb2d 100644
--- a/a
+++ b/a
@@ -1,4 +1,5 @@
  asasas
+****
  assas
  assas
  asas
@@ -37,6 +38,7 @@ asasas
  assas
  assas
  asas
+=fsdfsdfsadfasdfsad=

  asasas
  assas
@@ -46,5 +48,6 @@ asas
  asasas
  assas
  assas
+asdasdasdasda=DASD=AS=DA=SD=
  asas

------ snip

Best regards
-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo@simplicidade.org
Use XMPP!

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-04 23:26 ` Pedro Melo
  2008-01-04 23:28   ` Junio C Hamano
  2008-01-05  0:02   ` William Morgan
@ 2008-01-05  1:00   ` Miklos Vajna
  2008-01-05  2:54     ` William Morgan
  2 siblings, 1 reply; 16+ messages in thread
From: Miklos Vajna @ 2008-01-05  1:00 UTC (permalink / raw)
  To: Pedro Melo; +Cc: William Morgan, Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

On Fri, Jan 04, 2008 at 11:26:41PM +0000, Pedro Melo <melo@simplicidade.org> wrote:
> Maybe I'm doing something wrong, but comparing git-add -p with your script, 
> git-add -p is more darcs'ish. With git-add, if I have several changes in 
> the same file, I get to choose per hunk.

hm, if you want a darcs-like record interface.. darcs record asks you if
you want to include a newly added file in a commit or not,
git-walkthrough-add won't do so :s

you might want to have a look at dg record
(http://git.frugalware.org/repos/pacman-tools/darcs-git.py) which does
this for you.

- VMiklos

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-04 21:07     ` Jeff King
@ 2008-01-05  2:37       ` William Morgan
  2008-01-05  2:50         ` Junio C Hamano
  0 siblings, 1 reply; 16+ messages in thread
From: William Morgan @ 2008-01-05  2:37 UTC (permalink / raw)
  To: Git Mailing List

Excerpts from Jeff King's message of Fri Jan 04 13:07:51 -0800 2008:
> But if you have interface improvement suggestions for "git-add -i" or
> "git-add -p", I'm sure they would be well-received (post-1.5.4
> release, of course).

Not to show off my git newbness any more than necessary, but when I run
both git-add -i and git-add -p, I see exactly the same output and
interface. Are they meant to be different? This is with both master and
next branches of the git repo.

  ~/devel/sup$ ~/devel/git/installed/bin/git-add -i
             staged     unstaged path
    1:    unchanged        +1/-0 doc/TODO
    2:    unchanged        +1/-1 lib/sup/message.rb
    3:    unchanged      +28/-43 lib/sup/thread.rb
  
  *** Commands ***
    1: status       2: update       3: revert       4: add untracked
    5: patch        6: diff         7: quit         8: help
  What now> 
  Bye.
  ~/devel/sup$ ~/devel/git/installed/bin/git-add -p
             staged     unstaged path
    1:    unchanged        +1/-0 doc/TODO
    2:    unchanged        +1/-1 lib/sup/message.rb
    3:    unchanged      +28/-43 lib/sup/thread.rb
  
  *** Commands ***
    1: status       2: update       3: revert       4: add untracked
    5: patch        6: diff         7: quit         8: help
  What now> 
  Bye.

-- 
William <wmorgan-git@masanjin.net>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-05  2:37       ` William Morgan
@ 2008-01-05  2:50         ` Junio C Hamano
  2008-01-05  2:55           ` Junio C Hamano
  2008-01-05  4:08           ` Pedro Melo
  0 siblings, 2 replies; 16+ messages in thread
From: Junio C Hamano @ 2008-01-05  2:50 UTC (permalink / raw)
  To: William Morgan; +Cc: Git Mailing List

William Morgan <wmorgan-git@masanjin.net> writes:

> Excerpts from Jeff King's message of Fri Jan 04 13:07:51 -0800 2008:
>> But if you have interface improvement suggestions for "git-add -i" or
>> "git-add -p", I'm sure they would be well-received (post-1.5.4
>> release, of course).
>
> Not to show off my git newbness any more than necessary, but when I run
> both git-add -i and git-add -p, I see exactly the same output and
> interface. Are they meant to be different?

They are meant to be different.

    $ git reset --hard
    $ echo >>Makefile
    $ echo >>psql/Makefile
    $ git add -p
    diff --git a/Makefile b/Makefile
    index a2177bc..eb250b0 100644
    --- a/Makefile
    +++ b/Makefile
    @@ -54,3 +54,4 @@ snapdiff ::
            latest=`ls -1dr $(_snap)/release-????-??-?? | head -n 1` &&
            \
            diff -X dontdiff -ru "$$latest" .

    +
    Stage this hunk [y/n/a/d/?]? ^C

    $ git add -i
               staged     unstaged path
      1:    unchanged        +1/-0 Makefile
      2:    unchanged        +1/-0 psql/Makefile

    *** Commands ***
      1: [s]tatus     2: [u]pdate     3: [r]evert     4: [a]dd
      untracked
      5: [p]atch      6: [d]iff       7: [q]uit       8: [h]elp
    What now> ^C

There may be something broken with your git installation.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-05  1:00   ` Miklos Vajna
@ 2008-01-05  2:54     ` William Morgan
  2008-01-05  3:43       ` Jeff King
  0 siblings, 1 reply; 16+ messages in thread
From: William Morgan @ 2008-01-05  2:54 UTC (permalink / raw)
  To: Git Mailing List

Excerpts from Miklos Vajna's message of Fri Jan 04 17:00:11 -0800 2008:
> you might want to have a look at dg record
> (http://git.frugalware.org/repos/pacman-tools/darcs-git.py) which does
> this for you.

That's very similar. But I wasn't trying to mimick the darcs interface
exactly, just steal the parts I liked. For example, I don't actually
like being forced to commit immediately after staging some changes;
often I like to git diff --cached first.

Also, mine has color support. :)

-- 
William <wmorgan-git@masanjin.net>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-05  2:50         ` Junio C Hamano
@ 2008-01-05  2:55           ` Junio C Hamano
  2008-01-05  3:02             ` William Morgan
  2008-01-05  4:08           ` Pedro Melo
  1 sibling, 1 reply; 16+ messages in thread
From: Junio C Hamano @ 2008-01-05  2:55 UTC (permalink / raw)
  To: William Morgan; +Cc: Git Mailing List

Junio C Hamano <gitster@pobox.com> writes:

> William Morgan <wmorgan-git@masanjin.net> writes:
>
>> Not to show off my git newbness any more than necessary, but when I run
>> both git-add -i and git-add -p, I see exactly the same output and
>> interface. Are they meant to be different?
>
> They are meant to be different.
> ...
> There may be something broken with your git installation.

A shot in the dark.  Do you have more than one installation of
git, one of which is ancient and whose git-add--interactive does
not even have --patch option?

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-05  2:55           ` Junio C Hamano
@ 2008-01-05  3:02             ` William Morgan
  0 siblings, 0 replies; 16+ messages in thread
From: William Morgan @ 2008-01-05  3:02 UTC (permalink / raw)
  To: Git Mailing List

Excerpts from Junio C Hamano's message of Fri Jan 04 18:55:41 -0800 2008:
> A shot in the dark.  Do you have more than one installation of git,
> one of which is ancient and whose git-add--interactive does not even
> have --patch option?

Precisely. Now I finally see what you were talking about.

Well, yup, this is pretty much what I had in mind. If only I had known.
Guess I'll throw away my script now!

-- 
William <wmorgan-git@masanjin.net>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-05  2:54     ` William Morgan
@ 2008-01-05  3:43       ` Jeff King
  0 siblings, 0 replies; 16+ messages in thread
From: Jeff King @ 2008-01-05  3:43 UTC (permalink / raw)
  To: William Morgan; +Cc: Git Mailing List

On Fri, Jan 04, 2008 at 06:54:02PM -0800, William Morgan wrote:

> Also, mine has color support. :)

On the current master, try:

  git config color.interactive auto
  git config color.diff auto
  git add -i

-Peff

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: git-walkthrough-add script
  2008-01-05  2:50         ` Junio C Hamano
  2008-01-05  2:55           ` Junio C Hamano
@ 2008-01-05  4:08           ` Pedro Melo
  1 sibling, 0 replies; 16+ messages in thread
From: Pedro Melo @ 2008-01-05  4:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: William Morgan, Git Mailing List


On Jan 5, 2008, at 2:50 AM, Junio C Hamano wrote:
> They are meant to be different.
>
>     $ git reset --hard
>     $ echo >>Makefile
>     $ echo >>psql/Makefile
>     $ git add -p
>     diff --git a/Makefile b/Makefile
>     index a2177bc..eb250b0 100644
>     --- a/Makefile
>     +++ b/Makefile
>     @@ -54,3 +54,4 @@ snapdiff ::
>             latest=`ls -1dr $(_snap)/release-????-??-?? | head -n  
> 1` &&
>             \
>             diff -X dontdiff -ru "$$latest" .
>
>     +
>     Stage this hunk [y/n/a/d/?]? ^C

BTW, I'm using 1.5.4rc2 and this prompt shows:

Stage this hunk [y/n/a/d/j/J/?]?

but the help (after you press ?) also mentions:

k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks

but those three options don't seem to work.

Best regards,
-- 
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: melo@simplicidade.org
Use XMPP!

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2008-01-05  4:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-04  6:14 git-walkthrough-add script William Morgan
2008-01-04  7:26 ` Jeff King
2008-01-04 18:31   ` William Morgan
2008-01-04 21:07     ` Jeff King
2008-01-05  2:37       ` William Morgan
2008-01-05  2:50         ` Junio C Hamano
2008-01-05  2:55           ` Junio C Hamano
2008-01-05  3:02             ` William Morgan
2008-01-05  4:08           ` Pedro Melo
2008-01-04 23:26 ` Pedro Melo
2008-01-04 23:28   ` Junio C Hamano
2008-01-05  0:02   ` William Morgan
2008-01-05  0:17     ` Pedro Melo
2008-01-05  1:00   ` Miklos Vajna
2008-01-05  2:54     ` William Morgan
2008-01-05  3:43       ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.