* An alternate model for preparing partial commits
@ 2008-06-27 6:50 Robert Anderson
2008-06-27 7:10 ` Björn Steinbrink
` (4 more replies)
0 siblings, 5 replies; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 6:50 UTC (permalink / raw)
To: Git Mailing List
Seems to me the concept of the "index" is a half-baked version of what
I really want, which is the ability to factor a working tree's changes
into its constituent parts in preparation for committing them. The
index provides some very nice facilities to factor out changes in a
working tree into a "staging area", but the fundamental flaw of this
in my view is that this "staging area" is not instantiated as a tree,
so it cannot be compiled and/or tested before committing.
Consider a facility where the state you want to commit next is built
up in the current working directory, and the original set of changes
exists in some proto-space like the index currently inhabits, where
you can query and manipulate that state, but it isn't instantiated in
your working tree.
Imagine a session like this:
You've got a couple of conflated changes in your working tree, that
you think you can break up into two orthogonal changes, each of which
will compile and pass a set of tests you've got. You think. You'd
like to verify the build and test before you commit each piece.
git prep
where "prep" means "prepare commit". Don't get hung up on command or
option names I'm using as placeholders, I just made that up without
much deep thought about what to call it.
Now my tree appears clean (and git diff returns nothing). I can now
start adding the changes I had in my working tree that I want to
include in the next commit, using git add (which would know I am in
the "prep" mode). I can examine those original working dir changes I
am choosing from with:
git diff --prep
which, at this point, shows the same output that "git diff" did before
I ran "git prep." Now I want to add some subset of my original
changes:
git add newfile.c
git add -i
<add a couple of hunks of the changes from file modfile.c>
Now I have a working tree state that I think I want to commit. I can
examine it with:
git diff
and I can compile and test it. Yep, it works and passes my test suite
(an option I did not have if I had added these changes to the index).
So now I want to commit:
git commit -a -m "made change A"
I think the commit should probably "pop" the rest of the changes I did
not commit back into the working directory. If I want to pull another
subset of changes again, I can repeat the process with another "git
prep".
Does this idea resonate with anyone else?
Thanks,
Bob Anderson
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 6:50 An alternate model for preparing partial commits Robert Anderson
@ 2008-06-27 7:10 ` Björn Steinbrink
2008-06-27 14:37 ` [PATCH/RFC] stash: introduce 'stash save --keep-index' option SZEDER Gábor
2008-06-27 16:54 ` An alternate model for preparing partial commits Robert Anderson
2008-06-27 8:35 ` Johannes Sixt
` (3 subsequent siblings)
4 siblings, 2 replies; 61+ messages in thread
From: Björn Steinbrink @ 2008-06-27 7:10 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
On 2008.06.26 23:50:06 -0700, Robert Anderson wrote:
> Seems to me the concept of the "index" is a half-baked version of what
> I really want, which is the ability to factor a working tree's changes
> into its constituent parts in preparation for committing them. The
> index provides some very nice facilities to factor out changes in a
> working tree into a "staging area", but the fundamental flaw of this
> in my view is that this "staging area" is not instantiated as a tree,
> so it cannot be compiled and/or tested before committing.
>
> Consider a facility where the state you want to commit next is built
> up in the current working directory, and the original set of changes
> exists in some proto-space like the index currently inhabits, where
> you can query and manipulate that state, but it isn't instantiated in
> your working tree.
>
> Imagine a session like this:
>
> You've got a couple of conflated changes in your working tree, that
> you think you can break up into two orthogonal changes, each of which
> will compile and pass a set of tests you've got. You think. You'd
> like to verify the build and test before you commit each piece.
>
> git prep
>
> where "prep" means "prepare commit". Don't get hung up on command or
> option names I'm using as placeholders, I just made that up without
> much deep thought about what to call it.
>
> Now my tree appears clean (and git diff returns nothing). I can now
> start adding the changes I had in my working tree that I want to
> include in the next commit, using git add (which would know I am in
> the "prep" mode). I can examine those original working dir changes I
> am choosing from with:
>
> git diff --prep
>
> which, at this point, shows the same output that "git diff" did before
> I ran "git prep." Now I want to add some subset of my original
> changes:
>
> git add newfile.c
> git add -i
> <add a couple of hunks of the changes from file modfile.c>
>
> Now I have a working tree state that I think I want to commit. I can
> examine it with:
>
> git diff
>
> and I can compile and test it. Yep, it works and passes my test suite
> (an option I did not have if I had added these changes to the index).
> So now I want to commit:
>
> git commit -a -m "made change A"
>
> I think the commit should probably "pop" the rest of the changes I did
> not commit back into the working directory. If I want to pull another
> subset of changes again, I can repeat the process with another "git
> prep".
>
> Does this idea resonate with anyone else?
Hm, I use "stash" for that purpose, which leads to kind of the reverse
of your approach. So I do sth. like this:
- hack hack hack
- Notice that I want to make two commits out of what I have in my
working tree
- git add -p -- stage what I want in the first commit
- git commit -m tmp -- temporary commit
- git stash -- stash away what doesn't belong in the first commit
- git reset HEAD^ -- drop the temporary commit, with the changes kept
in the working tree
- test, fix bugs, read the diff, whatever
- git commit -- this time for good
- git stash apply -- get back the changes for the second commit
Instead of using reset, you could also use "commit --amend" (I actually
used to do that), but that needs you to do "git diff HEAD^" to see the
full changes, and (IMHO) makes it a harder sometimes to review your
stuff, because you now have three places where the changes for one
commit might reside (HEAD, index and working tree).
Björn
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH/RFC] stash: introduce 'stash save --keep-index' option
2008-06-27 7:10 ` Björn Steinbrink
@ 2008-06-27 14:37 ` SZEDER Gábor
2008-06-27 18:26 ` Junio C Hamano
2008-06-27 16:54 ` An alternate model for preparing partial commits Robert Anderson
1 sibling, 1 reply; 61+ messages in thread
From: SZEDER Gábor @ 2008-06-27 14:37 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: Robert Anderson, Git Mailing List
'git stash save' saves local modifications to a new stash, and runs 'git
reset --hard' to revert them to a clean index and work tree. When the
'--keep-index' option is specified, after that 'git reset --hard' the
previous contents of the index is restored and the work tree is updated
to match the index. This option is useful if the user wants to commit
only parts of his local modifications, but wants to test those parts
before committing.
Also add support for the completion of the new option, and add an
example use case to the documentation.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
On Fri, Jun 27, 2008 at 09:10:14AM +0200, Björn Steinbrink wrote:
> Hm, I use "stash" for that purpose, which leads to kind of the reverse
> of your approach. So I do sth. like this:
>
> - hack hack hack
> - Notice that I want to make two commits out of what I have in my
> working tree
> - git add -p -- stage what I want in the first commit
> - git commit -m tmp -- temporary commit
> - git stash -- stash away what doesn't belong in the first commit
> - git reset HEAD^ -- drop the temporary commit, with the changes kept
> in the working tree
> - test, fix bugs, read the diff, whatever
> - git commit -- this time for good
> - git stash apply -- get back the changes for the second commit
I used to do the same, so I have added a '--keep-index' option to 'git
stash save' to simplify this workflow. Have a look at the use case
added to the documentation to see, how you could spare the temporary
commit and the 'reset HEAD^'.
RFC, because I'm not quite confident with using plumbing like 'git
read-tree'... and there are no tests.
Documentation/git-stash.txt | 22 +++++++++++++++++++++-
contrib/completion/git-completion.bash | 13 ++++++++++++-
git-stash.sh | 22 ++++++++++++++++++----
3 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt
index baa4f55..936864f 100644
--- a/Documentation/git-stash.txt
+++ b/Documentation/git-stash.txt
@@ -36,12 +36,15 @@ is also possible).
OPTIONS
-------
-save [<message>]::
+save [--keep-index] [<message>]::
Save your local modifications to a new 'stash', and run `git-reset
--hard` to revert them. This is the default action when no
subcommand is given. The <message> part is optional and gives
the description along with the stashed state.
++
+If the `--keep-index` option is used, all changes already added to the
+index are left intact.
list [<options>]::
@@ -169,6 +172,23 @@ $ git stash apply
... continue hacking ...
----------------------------------------------------------------
+Testing partial commits::
+
+You can use `git stash save --keep-index` when you want to make two or
+more commits out of the changes in the work tree, and you want to test
+each change before committing:
++
+----------------------------------------------------------------
+... hack hack hack ...
+$ git add --patch foo
+$ git stash save --keep-index
+$ build && run tests
+$ git commit -m 'First part'
+$ git stash apply
+$ build && run tests
+$ git commit -a -m 'Second part'
+----------------------------------------------------------------
+
SEE ALSO
--------
linkgit:git-checkout[1],
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ebf7cde..9a15500 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1139,8 +1139,19 @@ _git_show ()
_git_stash ()
{
local subcommands='save list show apply clear drop pop create'
- if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
+ local subcommand="$(__git_find_subcommand "$subcommands")"
+ if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
+ else
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$subcommand,$cur" in
+ save,--*)
+ __gitcomp "--keep-index"
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
fi
}
diff --git a/git-stash.sh b/git-stash.sh
index 4938ade..92531a2 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -86,6 +86,13 @@ create_stash () {
}
save_stash () {
+ keep_index=
+ case "$1" in
+ --keep-index)
+ keep_index=t
+ shift
+ esac
+
stash_msg="$1"
if no_changes
@@ -104,6 +111,13 @@ save_stash () {
git update-ref -m "$stash_msg" $ref_stash $w_commit ||
die "Cannot save the current status"
printf 'Saved working directory and index state "%s"\n' "$stash_msg"
+
+ git reset --hard
+
+ if test -n "$keep_index" && test -n $i_tree
+ then
+ git read-tree --reset -u $i_tree
+ fi
}
have_stash () {
@@ -153,7 +167,8 @@ apply_stash () {
die "$*: no valid stashed state found"
unstashed_index_tree=
- if test -n "$unstash_index" && test "$b_tree" != "$i_tree"
+ if test -n "$unstash_index" && test "$b_tree" != "$i_tree" &&
+ test "$c_tree" != "$i_tree"
then
git diff-tree --binary $s^2^..$s^2 | git apply --cached
test $? -ne 0 &&
@@ -235,7 +250,7 @@ show)
;;
save)
shift
- save_stash "$*" && git-reset --hard
+ save_stash "$*"
;;
apply)
shift
@@ -268,8 +283,7 @@ pop)
if test $# -eq 0
then
save_stash &&
- echo '(To restore them type "git stash apply")' &&
- git-reset --hard
+ echo '(To restore them type "git stash apply")'
else
usage
fi
--
1.5.6.1.95.ge713
^ permalink raw reply related [flat|nested] 61+ messages in thread
* Re: [PATCH/RFC] stash: introduce 'stash save --keep-index' option
2008-06-27 14:37 ` [PATCH/RFC] stash: introduce 'stash save --keep-index' option SZEDER Gábor
@ 2008-06-27 18:26 ` Junio C Hamano
0 siblings, 0 replies; 61+ messages in thread
From: Junio C Hamano @ 2008-06-27 18:26 UTC (permalink / raw)
To: SZEDER Gábor
Cc: Björn Steinbrink, Robert Anderson, Git Mailing List
SZEDER Gábor <szeder@ira.uka.de> writes:
> 'git stash save' saves local modifications to a new stash, and runs 'git
> reset --hard' to revert them to a clean index and work tree. When the
> '--keep-index' option is specified, after that 'git reset --hard' the
> previous contents of the index is restored and the work tree is updated
> to match the index. This option is useful if the user wants to commit
> only parts of his local modifications, but wants to test those parts
> before committing.
Please do not describe how it does, before what it does and what it is
good for. Here is an example:
When preparing for a partial commit (iow, committing only part of
the changes you made in your work tree), you would use various
forms of "git add" to prepare the index to a shape you think is
appropriate for committing, and finally run "git commit".
This workflow however has a flaw in that you are committing
something that you could never have tested as a whole (and without
any other modification) in your work tree.
With the new "--keep-index" option, "git stash" takes a snapshot
of your index and the work tree state, and updates the work tree
to match your index, i.e. what you are about to commit. This way,
you can commit with confidence, knowing that you are committing
what you saw (and hopefully tested) as a whole in your work tree.
After making that initial commit, "git stash pop" will bring the
work tree state back without touching the index, so you can start
the next cycle of "git add" to prepare the second batch.
I do not know if your --keep-index implementation would actually allow the
above workflow; I haven't read the patch.
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 7:10 ` Björn Steinbrink
2008-06-27 14:37 ` [PATCH/RFC] stash: introduce 'stash save --keep-index' option SZEDER Gábor
@ 2008-06-27 16:54 ` Robert Anderson
2008-06-27 17:27 ` Björn Steinbrink
1 sibling, 1 reply; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 16:54 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: Git Mailing List
On Fri, Jun 27, 2008 at 12:10 AM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
> Hm, I use "stash" for that purpose, which leads to kind of the reverse
> of your approach. So I do sth. like this:
> - hack hack hack
> - Notice that I want to make two commits out of what I have in my
> working tree
> - git add -p -- stage what I want in the first commit
> - git commit -m tmp -- temporary commit
This is a guess at the first commit? I don't like it, but I'm still listening.
> - git stash -- stash away what doesn't belong in the first commit
> - git reset HEAD^ -- drop the temporary commit, with the changes kept
> in the working tree
Now I have my guess at the first commit as my tree state, correct?
What happens when I decide I need a couple of hunks from another file
which I missed in my first guess, and is now in the stashed state?
How do I get those out of the stash and into the working tree? If
there is no convenient way to do that, then this method is not
sufficient to cover the use case I am talking about.
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 16:54 ` An alternate model for preparing partial commits Robert Anderson
@ 2008-06-27 17:27 ` Björn Steinbrink
2008-06-27 17:34 ` Robert Anderson
0 siblings, 1 reply; 61+ messages in thread
From: Björn Steinbrink @ 2008-06-27 17:27 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
On 2008.06.27 09:54:43 -0700, Robert Anderson wrote:
> On Fri, Jun 27, 2008 at 12:10 AM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
> > Hm, I use "stash" for that purpose, which leads to kind of the reverse
> > of your approach. So I do sth. like this:
> > - hack hack hack
> > - Notice that I want to make two commits out of what I have in my
> > working tree
> > - git add -p -- stage what I want in the first commit
> > - git commit -m tmp -- temporary commit
>
> This is a guess at the first commit? I don't like it, but I'm still
> listening.
It's rather a work-around to stash away only the changes that are not in
the index. See the other reply to my mail for a patch that adds an
option to stash to do that without the commit/reset hack.
> > - git stash -- stash away what doesn't belong in the first commit
> > - git reset HEAD^ -- drop the temporary commit, with the changes kept
> > in the working tree
>
> Now I have my guess at the first commit as my tree state, correct?
> What happens when I decide I need a couple of hunks from another file
> which I missed in my first guess, and is now in the stashed state?
> How do I get those out of the stash and into the working tree? If
> there is no convenient way to do that, then this method is not
> sufficient to cover the use case I am talking about.
git stash pop
eventually fix conflicts if you changed the working tree in the meantime
go back to the "git add -p" step
Björn
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 17:27 ` Björn Steinbrink
@ 2008-06-27 17:34 ` Robert Anderson
0 siblings, 0 replies; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 17:34 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: Git Mailing List
On Fri, Jun 27, 2008 at 10:27 AM, Björn Steinbrink <B.Steinbrink@gmx.de> wrote:
>> Now I have my guess at the first commit as my tree state, correct?
>> What happens when I decide I need a couple of hunks from another file
>> which I missed in my first guess, and is now in the stashed state?
>> How do I get those out of the stash and into the working tree? If
>> there is no convenient way to do that, then this method is not
>> sufficient to cover the use case I am talking about.
>
> git stash pop
> eventually fix conflicts if you changed the working tree in the meantime
> go back to the "git add -p" step
>
> Björn
But that pops the entire stash, right? Inconvenient at best.
A good UI here would allow you to move pieces bidirectionally to/from
the stash at will until the desired, verifiable factorization of
changes has been achieved.
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 6:50 An alternate model for preparing partial commits Robert Anderson
2008-06-27 7:10 ` Björn Steinbrink
@ 2008-06-27 8:35 ` Johannes Sixt
2008-06-27 17:01 ` Robert Anderson
2008-06-27 8:50 ` Petr Baudis
` (2 subsequent siblings)
4 siblings, 1 reply; 61+ messages in thread
From: Johannes Sixt @ 2008-06-27 8:35 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
Robert Anderson schrieb:
> Seems to me the concept of the "index" is a half-baked version of what
> I really want, which is the ability to factor a working tree's changes
> into its constituent parts in preparation for committing them. The
> index provides some very nice facilities to factor out changes in a
> working tree into a "staging area", but the fundamental flaw of this
> in my view is that this "staging area" is not instantiated as a tree,
> so it cannot be compiled and/or tested before committing.
I do this all the time. After I have made $N commits out of my worktree, I
usually
$ git rebase -i HEAD~$N
and turn all 'pick's into 'edit's and 'squash's. Then I can compile and
test each commit, perhaps add some fixups, in isolation.
-- Hannes
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 8:35 ` Johannes Sixt
@ 2008-06-27 17:01 ` Robert Anderson
0 siblings, 0 replies; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 17:01 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Git Mailing List
On Fri, Jun 27, 2008 at 1:35 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Robert Anderson schrieb:
>> Seems to me the concept of the "index" is a half-baked version of what
>> I really want, which is the ability to factor a working tree's changes
>> into its constituent parts in preparation for committing them. The
>> index provides some very nice facilities to factor out changes in a
>> working tree into a "staging area", but the fundamental flaw of this
>> in my view is that this "staging area" is not instantiated as a tree,
>> so it cannot be compiled and/or tested before committing.
>
> I do this all the time. After I have made $N commits out of my worktree, I
> usually
>
> $ git rebase -i HEAD~$N
>
> and turn all 'pick's into 'edit's and 'squash's. Then I can compile and
> test each commit, perhaps add some fixups, in isolation.
>
> -- Hannes
Hannes,
I do not have N commits. I have a modified working tree from which I
would like to create N commits. I would like to compile and test an
instantiation of each of those to-be-committed states before
committing them.
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 6:50 An alternate model for preparing partial commits Robert Anderson
2008-06-27 7:10 ` Björn Steinbrink
2008-06-27 8:35 ` Johannes Sixt
@ 2008-06-27 8:50 ` Petr Baudis
2008-06-27 17:02 ` Robert Anderson
2008-06-27 13:33 ` Johannes Schindelin
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7H4sOFEDjCbyi>
4 siblings, 1 reply; 61+ messages in thread
From: Petr Baudis @ 2008-06-27 8:50 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
Hi,
On Thu, Jun 26, 2008 at 11:50:06PM -0700, Robert Anderson wrote:
> Seems to me the concept of the "index" is a half-baked version of what
> I really want, which is the ability to factor a working tree's changes
> into its constituent parts in preparation for committing them. The
> index provides some very nice facilities to factor out changes in a
> working tree into a "staging area", but the fundamental flaw of this
> in my view is that this "staging area" is not instantiated as a tree,
> so it cannot be compiled and/or tested before committing.
>
> Consider a facility where the state you want to commit next is built
> up in the current working directory, and the original set of changes
> exists in some proto-space like the index currently inhabits, where
> you can query and manipulate that state, but it isn't instantiated in
> your working tree.
I wanted to suggest using commit and commit --amend, but I realized
that frankly, I don't understand quite what are you wanting to do.
Through the process, are you preparing a sequence of two commits at
once, or merely a single commit? With s/--prep/--cached/ and throwing
git prep away completely, it's not clear to me how would what you
present be different at all from just using index - could you point out
what is actually different in your workflow compared to the prep
workflow you propose?
--
Petr "Pasky" Baudis
The last good thing written in C++ was the Pachelbel Canon. -- J. Olson
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 8:50 ` Petr Baudis
@ 2008-06-27 17:02 ` Robert Anderson
0 siblings, 0 replies; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 17:02 UTC (permalink / raw)
To: Petr Baudis; +Cc: Git Mailing List
On Fri, Jun 27, 2008 at 1:50 AM, Petr Baudis <pasky@suse.cz> wrote:
> Hi,
>
> On Thu, Jun 26, 2008 at 11:50:06PM -0700, Robert Anderson wrote:
>> Seems to me the concept of the "index" is a half-baked version of what
>> I really want, which is the ability to factor a working tree's changes
>> into its constituent parts in preparation for committing them. The
>> index provides some very nice facilities to factor out changes in a
>> working tree into a "staging area", but the fundamental flaw of this
>> in my view is that this "staging area" is not instantiated as a tree,
>> so it cannot be compiled and/or tested before committing.
>>
>> Consider a facility where the state you want to commit next is built
>> up in the current working directory, and the original set of changes
>> exists in some proto-space like the index currently inhabits, where
>> you can query and manipulate that state, but it isn't instantiated in
>> your working tree.
>
> I wanted to suggest using commit and commit --amend, but I realized
> that frankly, I don't understand quite what are you wanting to do.
I think if you read the whole message the answer to your question is there.
> Through the process, are you preparing a sequence of two commits at
> once, or merely a single commit? With s/--prep/--cached/ and throwing
> git prep away completely, it's not clear to me how would what you
> present be different at all from just using index - could you point out
> what is actually different in your workflow compared to the prep
> workflow you propose?
As I said in my original message, twice, was that the index state is
never instantiated and therefore cannot be compiled or tested.
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 6:50 An alternate model for preparing partial commits Robert Anderson
` (2 preceding siblings ...)
2008-06-27 8:50 ` Petr Baudis
@ 2008-06-27 13:33 ` Johannes Schindelin
2008-06-27 13:49 ` Miklos Vajna
` (2 more replies)
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7H4sOFEDjCbyi>
4 siblings, 3 replies; 61+ messages in thread
From: Johannes Schindelin @ 2008-06-27 13:33 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
Hi,
On Thu, 26 Jun 2008, Robert Anderson wrote:
> Seems to me the concept of the "index" is a half-baked version of what
> I really want, which is the ability to factor a working tree's changes
> into its constituent parts in preparation for committing them.
Half-baked is probably too strong a word.
What you are basically asking for is to have the working directory
as staging area, and to be able to stash away changes that are not to be
committed.
Now, this is not necessarily what everybody wants, which is why many
people are fine with the index.
Having said that, I played with the idea of a "git stash -i", which would
allow you to select the changes to stash away. (And by extension, "git
stash -e" using the "git add -e" command.)
Hmm?
Ciao,
Dscho
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 13:33 ` Johannes Schindelin
@ 2008-06-27 13:49 ` Miklos Vajna
2008-06-27 17:14 ` Robert Anderson
2008-06-27 18:15 ` Junio C Hamano
2 siblings, 0 replies; 61+ messages in thread
From: Miklos Vajna @ 2008-06-27 13:49 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Robert Anderson, Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 921 bytes --]
On Fri, Jun 27, 2008 at 02:33:33PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Having said that, I played with the idea of a "git stash -i", which would
> allow you to select the changes to stash away. (And by extension, "git
> stash -e" using the "git add -e" command.)
If we are at it, git checkout -i is also something which may be useful,
like:
1) Do two unrelated changes in a file.
2) You realize one of them is unnecessary.
Currently what you can do is something like:
1) You stage the first hunk using git add -p
2) git commit
3) git checkout file
But this forces you to commit early, and to commit --amend later. It
would be nice to be able to completely drop a hunk without first
commiting.
(Feel free to point out if this is something bad, I just remember from
the past that darcs revert - which is like git checkout - had such an
interactive mode.)
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 13:33 ` Johannes Schindelin
2008-06-27 13:49 ` Miklos Vajna
@ 2008-06-27 17:14 ` Robert Anderson
2008-06-27 17:45 ` Johannes Schindelin
` (2 more replies)
2008-06-27 18:15 ` Junio C Hamano
2 siblings, 3 replies; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 17:14 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Git Mailing List
On Fri, Jun 27, 2008 at 6:33 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Thu, 26 Jun 2008, Robert Anderson wrote:
>
>> Seems to me the concept of the "index" is a half-baked version of what
>> I really want, which is the ability to factor a working tree's changes
>> into its constituent parts in preparation for committing them.
>
> Half-baked is probably too strong a word.
It is too subtle. That the index state - which becomes the next
committed state - is not available for building or testing before
committing is a deep flaw.
> What you are basically asking for is to have the working directory
> as staging area, and to be able to stash away changes that are not to be
> committed.
Correct.
> Now, this is not necessarily what everybody wants, which is why many
> people are fine with the index.
But it is something they should want, and should have, if they care
about the quality of their commits. Especially in the common case of
a project with development lines which have some sort of policy about
build/test requirements. How do you ensure your commits obey that
policy if you cannot verify it? That is why the index is not a
sufficient mechanism for preparing partial commits. It's fine for
quick and dirty operation when the factorization of the conflated
changes is obvious and trivial. It is not sufficient otherwise.
> Having said that, I played with the idea of a "git stash -i", which would
> allow you to select the changes to stash away. (And by extension, "git
> stash -e" using the "git add -e" command.)
>
> Hmm?
I meant to mention that - at least in the model I described - this has
some overlap with "stash" and could possibly be folded into it.
In my ideal UI, changes (from all changes to hunk level) could be
moved back and forth between the stash and the working tree equally
easily. Would git stash -i allow that?
For example, if I moved a couple of files into the stash, and then
realized I needed one hunk back, could I easily retrieve just that
from the stash?
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 17:14 ` Robert Anderson
@ 2008-06-27 17:45 ` Johannes Schindelin
2008-06-27 17:49 ` Robert Anderson
2008-06-27 20:31 ` Stephen Sinclair
2008-06-28 2:14 ` Dmitry Potapov
2 siblings, 1 reply; 61+ messages in thread
From: Johannes Schindelin @ 2008-06-27 17:45 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
Hi,
On Fri, 27 Jun 2008, Robert Anderson wrote:
> On Fri, Jun 27, 2008 at 6:33 AM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>
> > On Thu, 26 Jun 2008, Robert Anderson wrote:
> >
> >> Seems to me the concept of the "index" is a half-baked version of
> >> what I really want, which is the ability to factor a working tree's
> >> changes into its constituent parts in preparation for committing
> >> them.
> >
> > Half-baked is probably too strong a word.
>
> It is too subtle. That the index state - which becomes the next
> committed state - is not available for building or testing before
> committing is a deep flaw.
>
> > Now, this is not necessarily what everybody wants, which is why many
> > people are fine with the index.
>
> But it is something they should want, and should have, if they care
> about the quality of their commits.
This is too narrow-minded a view for me.
No longer interested,
Dscho
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 17:45 ` Johannes Schindelin
@ 2008-06-27 17:49 ` Robert Anderson
[not found] ` <alpine.DEB.1.00.0806271854120.9925@racer>
2008-06-27 18:20 ` Dana How
0 siblings, 2 replies; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 17:49 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Git Mailing List
On Fri, Jun 27, 2008 at 10:45 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Fri, 27 Jun 2008, Robert Anderson wrote:
>
>> On Fri, Jun 27, 2008 at 6:33 AM, Johannes Schindelin
>> <Johannes.Schindelin@gmx.de> wrote:
>>
>> > On Thu, 26 Jun 2008, Robert Anderson wrote:
>> >
>> >> Seems to me the concept of the "index" is a half-baked version of
>> >> what I really want, which is the ability to factor a working tree's
>> >> changes into its constituent parts in preparation for committing
>> >> them.
>> >
>> > Half-baked is probably too strong a word.
>>
>> It is too subtle. That the index state - which becomes the next
>> committed state - is not available for building or testing before
>> committing is a deep flaw.
>>
>> > Now, this is not necessarily what everybody wants, which is why many
>> > people are fine with the index.
>>
>> But it is something they should want, and should have, if they care
>> about the quality of their commits.
>
> This is too narrow-minded a view for me.
>
> No longer interested,
> Dscho
>
Here's a patch to match the local culture: "It is incredible how
stupid the idea of the index is."
Clearly you should now be interested.
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
[parent not found: <alpine.DEB.1.00.0806271854120.9925@racer>]
* Re: An alternate model for preparing partial commits
[not found] ` <alpine.DEB.1.00.0806271854120.9925@racer>
@ 2008-06-27 18:07 ` Robert Anderson
0 siblings, 0 replies; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 18:07 UTC (permalink / raw)
To: Git Mailing List
On Fri, Jun 27, 2008 at 10:54 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> Hi,
>
> On Fri, 27 Jun 2008, Robert Anderson wrote:
>
>> Here's a patch to match the local culture: "It is incredible how stupid
>> the idea of the index is."
>>
>> Clearly you should now be interested.
>
> No, you're wrong. I am totall uninterested in talking to you now.
>
Tongue in cheek, of course - a play on Linus' "narrow minded views"
about svn. Not much of a sense of humor, eh?
You may consider the idea that the next committed state ought to be
available for build/test to be a "narrow-minded" view. I find it to
be a manifestly sound view. In fact, if you disagree I have little
respect for your technical judgment and therefore am not concerned if
you will not talk with me. Which is too bad on both counts.
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 17:49 ` Robert Anderson
[not found] ` <alpine.DEB.1.00.0806271854120.9925@racer>
@ 2008-06-27 18:20 ` Dana How
1 sibling, 0 replies; 61+ messages in thread
From: Dana How @ 2008-06-27 18:20 UTC (permalink / raw)
To: Robert Anderson; +Cc: Johannes Schindelin, Git Mailing List, danahow
On Fri, Jun 27, 2008 at 10:49 AM, Robert Anderson <rwa000@gmail.com> wrote:
> On Fri, Jun 27, 2008 at 10:45 AM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>> Hi,
>>
>> On Fri, 27 Jun 2008, Robert Anderson wrote:
>>
>>> On Fri, Jun 27, 2008 at 6:33 AM, Johannes Schindelin
>>> <Johannes.Schindelin@gmx.de> wrote:
>>>
>>> > On Thu, 26 Jun 2008, Robert Anderson wrote:
>>> >
>>> >> Seems to me the concept of the "index" is a half-baked version of
>>> >> what I really want, which is the ability to factor a working tree's
>>> >> changes into its constituent parts in preparation for committing
>>> >> them.
>>> >
>>> > Half-baked is probably too strong a word.
>>>
>>> It is too subtle. That the index state - which becomes the next
>>> committed state - is not available for building or testing before
>>> committing is a deep flaw.
>>>
>>> > Now, this is not necessarily what everybody wants, which is why many
>>> > people are fine with the index.
>>>
>>> But it is something they should want, and should have, if they care
>>> about the quality of their commits.
>>
>> This is too narrow-minded a view for me.
>>
>> No longer interested,
>> Dscho
>>
>
> Here's a patch to match the local culture: "It is incredible how
> stupid the idea of the index is."
>
> Clearly you should now be interested.
>
> Thanks,
> Bob
I guess I'm not interested in the over-generalizations. ;-)
But the ability to use e.g. some stash-like feature (as suggested above)
to easily make the index-state (about to be committed) fully available
for compiling/processing/testing without losing edits not yet ready
for commit is an extra feature we would use here at least some of the time.
I will admit it's currently not the "itch" at the top of my list.
Thanks,
--
Dana L. How danahow@gmail.com +1 650 804 5991 cell
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 17:14 ` Robert Anderson
2008-06-27 17:45 ` Johannes Schindelin
@ 2008-06-27 20:31 ` Stephen Sinclair
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7ZhB8FEDjCdJs>
2008-06-28 2:14 ` Dmitry Potapov
2 siblings, 1 reply; 61+ messages in thread
From: Stephen Sinclair @ 2008-06-27 20:31 UTC (permalink / raw)
To: Git Mailing List
Hello,
On Fri, Jun 27, 2008 at 1:14 PM, Robert Anderson <rwa000@gmail.com> wrote:
> On Fri, Jun 27, 2008 at 6:33 AM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>> Now, this is not necessarily what everybody wants, which is why many
>> people are fine with the index.
>
> But it is something they should want, and should have, if they care
> about the quality of their commits. Especially in the common case of
> a project with development lines which have some sort of policy about
> build/test requirements. How do you ensure your commits obey that
> policy if you cannot verify it? That is why the index is not a
> sufficient mechanism for preparing partial commits. It's fine for
> quick and dirty operation when the factorization of the conflated
> changes is obvious and trivial. It is not sufficient otherwise.
I just thought I'd throw in my $0.02 here. There's something
fundamental I think I'm not getting about this argument: it seems to
be based on the premise that partial commits allow untested tree
states to enter the repository. However, having gotten used to the
git way of things, I personally don't see the problem with allowing
bad commits, as long as they are not pushed to public.
That is, I use the git add -p command all the time when I realize I've
just done two things that should be committed separately. Then I'll
git commit everything else, and go back and test, like so:
git checkout master
[hack hack..]
git add -p
git commit
git commit -a
[test..]
git checkout master^
[test..]
git checkout master
See? All tested. If I find a problem during testing, I'll probably
commit it and then rebase master off my new commit, fixing any
conflicts I just introduced.
Frankly I hardly even use the stash; since history can be edited, I
feel like commits are all I need when working with git. Anything I do
doesn't matter until I push to public anyways. So it's up to me to
make sure I test everything before pushing, but otherwise I'm very
happy with the ability to commit half-baked ideas and then go back to
make sure they are usable (and tested!) before pushing. This is what
local branches are for, isn't it?
Steve
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 17:14 ` Robert Anderson
2008-06-27 17:45 ` Johannes Schindelin
2008-06-27 20:31 ` Stephen Sinclair
@ 2008-06-28 2:14 ` Dmitry Potapov
2008-06-28 2:57 ` Robert Anderson
2 siblings, 1 reply; 61+ messages in thread
From: Dmitry Potapov @ 2008-06-28 2:14 UTC (permalink / raw)
To: Robert Anderson; +Cc: Johannes Schindelin, Git Mailing List
On Fri, Jun 27, 2008 at 10:14:05AM -0700, Robert Anderson wrote:
>
> It is too subtle. That the index state - which becomes the next
> committed state - is not available for building or testing before
> committing is a deep flaw.
And why is that? It is like saying that any editor that does not allow
you to compile the file without saving it first has a deep flaw.
In Git, commits are not the same as in CVS. You can commit any changes
and amend them any time later before you publish your changes. So, what
you normally do is to commit your changes and then run test on them.
The advantage of this approach is that you can continue to your normal
work while test are running, besides the tests are running in clear and
control environment, not in the developer working director where always
there is some garbage.
> > Now, this is not necessarily what everybody wants, which is why many
> > people are fine with the index.
>
> But it is something they should want, and should have, if they care
> about the quality of their commits.
Those who care about quality should have a review process, and the
review process works best when all changes are slit in a small logical
steps. How do you propose to that without committing changes first?
> Especially in the common case of
> a project with development lines which have some sort of policy about
> build/test requirements. How do you ensure your commits obey that
> policy if you cannot verify it?
You can verify it, but you do that _after_ you committed changes but
before you publish them. BTW, policy may include that it should be
compiled and tested on a few platforms, so you cannot do that in
your working directory anyway.
I think the source of your confusion is that you consider git commit
as cvs commit, while git commit in some sense may be closer to saving
files, while a better analogue for cvs commit will be git push to a
public repository.
Dmitry
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-28 2:14 ` Dmitry Potapov
@ 2008-06-28 2:57 ` Robert Anderson
2008-06-28 4:03 ` Dmitry Potapov
0 siblings, 1 reply; 61+ messages in thread
From: Robert Anderson @ 2008-06-28 2:57 UTC (permalink / raw)
To: Dmitry Potapov; +Cc: Git Mailing List
On Fri, Jun 27, 2008 at 7:14 PM, Dmitry Potapov <dpotapov@gmail.com> wrote:
> On Fri, Jun 27, 2008 at 10:14:05AM -0700, Robert Anderson wrote:
>>
>> It is too subtle. That the index state - which becomes the next
>> committed state - is not available for building or testing before
>> committing is a deep flaw.
>
> And why is that? It is like saying that any editor that does not allow
> you to compile the file without saving it first has a deep flaw.
I don't believe it is like that. It would be like that if you
intended for your on-tree disk to have a policy to always compile (for
example). That is not a common use-case.
> In Git, commits are not the same as in CVS.
I have not suggested they were.
> You can commit any changes
> and amend them any time later before you publish your changes.
This is enforcing a two-step process where there only need be one the
vast majority of the time, to require that commit and publish be
separate operations.
> Those who care about quality should have a review process, and the
> review process works best when all changes are slit in a small logical
> steps. How do you propose to that without committing changes first?
I don't understand the question. The entire point of the facility I
am proposing is to facilitate creating small clean changesets. Go
back and read my original proposal, or Junio's statement of more or
less the same idea, to see how it is proposed to do this.
> You can verify it, but you do that _after_ you committed changes but
> before you publish them.
Again, this is requiring two steps when it is otherwise not required,
creating an inefficient workflow that is error prone.
> BTW, policy may include that it should be
> compiled and tested on a few platforms, so you cannot do that in
> your working directory anyway.
Huh? I have done that every day for 15+ years.
> I think the source of your confusion is that you consider git commit
> as cvs commit
No. I have experience with a wide array of source control systems.
CVS fits my mental model the least well. git is pretty close, but it
is not there yet. The current partial commit facility is the biggest
misfire, in my view.
I like that git's philosophy does not include a draconian policy of
not changing history. That's fine, it's practical, and it's useful,
to cover common scenarios in which you'd like to quickly recover from
a mistake. However, I am afraid that these facilities have been
abused and turned into something that they are not well-suited for,
i.e., the use of lines of development as both keepers of history and
of scratch spaces where you scribble around with temporary things, all
the while git having no clue which is intended. That these ideas are
conflated is a mistake. That's my opinion. These activities ought to
occur in separate, logically distinct spaces in which they occur,
because they have different requirements and common use-cases.
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-28 2:57 ` Robert Anderson
@ 2008-06-28 4:03 ` Dmitry Potapov
[not found] ` <9af502e50806272320p23f01e8eo4a67c5f6f4476098@mail.gmail.com>
0 siblings, 1 reply; 61+ messages in thread
From: Dmitry Potapov @ 2008-06-28 4:03 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
On Fri, Jun 27, 2008 at 07:57:02PM -0700, Robert Anderson wrote:
> On Fri, Jun 27, 2008 at 7:14 PM, Dmitry Potapov <dpotapov@gmail.com> wrote:
> > On Fri, Jun 27, 2008 at 10:14:05AM -0700, Robert Anderson wrote:
> >>
> >> It is too subtle. That the index state - which becomes the next
> >> committed state - is not available for building or testing before
> >> committing is a deep flaw.
> >
> > And why is that? It is like saying that any editor that does not allow
> > you to compile the file without saving it first has a deep flaw.
>
> I don't believe it is like that. It would be like that if you
> intended for your on-tree disk to have a policy to always compile (for
> example). That is not a common use-case.
Do you think commit only tested changes is a common policy among
Git users? I seriously doubt that. And as I said before, git commit
is probably closer to saving a file than to what cvs commit does.
> > You can commit any changes
> > and amend them any time later before you publish your changes.
>
> This is enforcing a two-step process where there only need be one the
> vast majority of the time, to require that commit and publish be
> separate operations.
I don't see it is a problem. In fact, it saves time for me, because
I can work while tests are running, and considering the whole cycle
with different configurations may take 3 hours, I really want to do
something useful while it is running... Besides, I really believe
in review, so it cannot be one-step process anyway...
>
> > Those who care about quality should have a review process, and the
> > review process works best when all changes are slit in a small logical
> > steps. How do you propose to that without committing changes first?
>
> I don't understand the question.
If you use CVS like workflow, you may have the policy of no commit
until your patches are reviewed. In case of Git, you do commit but
only push to fast-forward only branch after receiving okay (or the
maintainer pull your changes to it). With Git, commit is more like
saving file, except that you save not a single file but the whole
changeset with the commit message and relevant information.
> > You can verify it, but you do that _after_ you committed changes but
> > before you publish them.
>
> Again, this is requiring two steps when it is otherwise not required,
> creating an inefficient workflow that is error prone.
I don't see why you think that is inefficient or error prone.
>
> > BTW, policy may include that it should be
> > compiled and tested on a few platforms, so you cannot do that in
> > your working directory anyway.
>
> Huh? I have done that every day for 15+ years.
You have your working directory let's say on Linux, and you have to
test your changes on Windows. So what do you do? With Git, it is
simple as you commit your changes and then run testing automatically
on different platforms and they use exactly what you put into the
repo. So if everything is okay, you can publish.
>
> > I think the source of your confusion is that you consider git commit
> > as cvs commit
>
> No. I have experience with a wide array of source control systems.
> CVS fits my mental model the least well. git is pretty close, but it
> is not there yet. The current partial commit facility is the biggest
> misfire, in my view.
Do you have your personal experience of using it, or it is just some
abstract considerations? Certainly, any feature may be misused but, in
general, it is handy and I have not had any problem with it. And, yes,
if I split a very complex patch then I will use stash to facilitate
me with this work, but it is rare.
> I like that git's philosophy does not include a draconian policy of
> not changing history. That's fine, it's practical, and it's useful,
> to cover common scenarios in which you'd like to quickly recover from
> a mistake. However, I am afraid that these facilities have been
> abused and turned into something that they are not well-suited for,
> i.e., the use of lines of development as both keepers of history and
> of scratch spaces where you scribble around with temporary things, all
> the while git having no clue which is intended.
I don't see why git should know it. The policy depends on workflow
and is usually enforced by hooks. I don't see why Git should care
about it deeply. It is like a word processor can be used for writing
a draft of a document or the final version for publication. Sure,
you can mark something as work-in-progress (use tags or comments),
but it is not something about Git should care deeply inside.
Dmitry
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 13:33 ` Johannes Schindelin
2008-06-27 13:49 ` Miklos Vajna
2008-06-27 17:14 ` Robert Anderson
@ 2008-06-27 18:15 ` Junio C Hamano
2008-06-27 18:43 ` Robert Anderson
2008-06-28 5:03 ` Jeff King
2 siblings, 2 replies; 61+ messages in thread
From: Junio C Hamano @ 2008-06-27 18:15 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Robert Anderson, Git Mailing List
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> On Thu, 26 Jun 2008, Robert Anderson wrote:
>
>> Seems to me the concept of the "index" is a half-baked version of what
>> I really want, which is the ability to factor a working tree's changes
>> into its constituent parts in preparation for committing them.
>
> Half-baked is probably too strong a word.
>
> What you are basically asking for is to have the working directory
> as staging area, and to be able to stash away changes that are not to be
> committed.
>
> Now, this is not necessarily what everybody wants, which is why many
> people are fine with the index.
I've always said that I am not in favor of any form of partial commits,
exactly for the reason Robert states, namely that you are not committing
what you had in your work tree as a whole. I said so back when the only
form of partial commits were "git commit [-o] this-file". I said it again
even when I introduced "add -i", that the interface goes backwards and
does not fix the issues associated with partial commits.
But I agree with you that calling the index half-baked is missing the
point. The index is merely the lowest level of facility to stage what is
to be committed, and there is no half nor full bakedness to it. The way
the current Porcelain layer uses it however could be improved and Robert
is allowed to call _that_ half-baked when he is in a foul mood (even then
I would rather prefer people to be civil on this list).
So I would welcome constructive proposals to make things better.
But before going into the discussion, to be fair, I would mention that
people who are used to partial commits (perhaps inherited from their
CVS/SVN habit) defend the practice by saying that they will want to make
commit series first (with unproven separation between commit boundaries
that is inherent to the practice of making partial commits) and it is not
problem for them that their commits are not tested at commit time, because
they will test each step afterwards after they are done committing. They
can fix things up later with "rebase -i" if they find glitches.
The defense makes sense from the workflow point of view, in that batching
things up tends to make people more productive. You think of the logical
separation first and make commits without having to wait for each step to
build and test (otherwise your train of thought would be interrupted), and
then you test the final resulting sequence as a separate phase. Although
I imagine I would personally not be able to work that way comfortably, I
consider this a personal preference issue, and if some people are more
productive to work that way, it is fine to support the workflow.
But that is not a reason not to support other workflows.
> Having said that, I played with the idea of a "git stash -i", which would
> allow you to select the changes to stash away.
I would actually go the other way. I think the problem we are trying to
solve here in this thread is to support this (other) workflow:
You keep working, and eventually build all the changes intermixed in
your work tree, perhaps without any commit, or perhaps with a commit
sequence that is only meant as snapshots and not as a logical
sequence. Your work tree state is in good shape right now (you do
build and test at this "commit goal" state). Now you would want to
split the changes while making sure each step is good (i.e. builds and
tests fine as well as the patch makes sense standalone).
One thing I think would make sense is to stash away _everything_ at this
point. That would take you to the state before you started working. Then
if we can selectively _unstash_ the parts that should logically be
committed first to bring them to your work tree, then you can inspect that
change against HEAD, test it, and when you are happy with it, you would
make your first commit in the final sequence.
Once you have capability to unstash selectively and make that first commit
in the final sequence like so, breaking up the remainder that is still in
your stash to a reasonable sequence of commits can be done with the same
workflow. Unstash the next batch, inspect, test and be satisfied and then
commmit. Lather, rinse and repeat.
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 18:15 ` Junio C Hamano
@ 2008-06-27 18:43 ` Robert Anderson
2008-06-28 5:03 ` Jeff King
1 sibling, 0 replies; 61+ messages in thread
From: Robert Anderson @ 2008-06-27 18:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, Git Mailing List
On Fri, Jun 27, 2008 at 11:15 AM, Junio C Hamano <gitster@pobox.com> wrote:
> I've always said that I am not in favor of any form of partial commits,
> exactly for the reason Robert states, namely that you are not committing
> what you had in your work tree as a whole. I said so back when the only
> form of partial commits were "git commit [-o] this-file". I said it again
> even when I introduced "add -i", that the interface goes backwards and
> does not fix the issues associated with partial commits.
We are seeing eye-to-eye here.
> But I agree with you that calling the index half-baked is missing the
> point.
What I said is that the index is a half-baked version of _what I
want_, which is the ability to do partial commits from testable
states. Clearly the index is a way to do partial commits, but it does
not address the "untested state" issue, so it is only halfway there,
i.e., half-baked.
> The index is merely the lowest level of facility to stage what is
> to be committed, and there is no half nor full bakedness to it. The way
> the current Porcelain layer uses it however could be improved and Robert
> is allowed to call _that_ half-baked when he is in a foul mood (even then
> I would rather prefer people to be civil on this list).
Fair enough. I did not mean "half baked" to be particular provocative, fwiw.
> I would actually go the other way. I think the problem we are trying to
> solve here in this thread is to support this (other) workflow:
>
> You keep working, and eventually build all the changes intermixed in
> your work tree, perhaps without any commit, or perhaps with a commit
> sequence that is only meant as snapshots and not as a logical
> sequence. Your work tree state is in good shape right now (you do
> build and test at this "commit goal" state). Now you would want to
> split the changes while making sure each step is good (i.e. builds and
> tests fine as well as the patch makes sense standalone).
>
> One thing I think would make sense is to stash away _everything_ at this
> point. That would take you to the state before you started working. Then
> if we can selectively _unstash_ the parts that should logically be
> committed first to bring them to your work tree, then you can inspect that
> change against HEAD, test it, and when you are happy with it, you would
> make your first commit in the final sequence.
Exactly. That was a good summary of the workflow I proposed in my
original email.
> Once you have capability to unstash selectively and make that first commit
> in the final sequence like so, breaking up the remainder that is still in
> your stash to a reasonable sequence of commits can be done with the same
> workflow. Unstash the next batch, inspect, test and be satisfied and then
> commmit. Lather, rinse and repeat.
Bingo.
Time permitting, I will propose a more well thought through UI for
this workflow. If you like it, we can talk about how it might be
implemented.
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 18:15 ` Junio C Hamano
2008-06-27 18:43 ` Robert Anderson
@ 2008-06-28 5:03 ` Jeff King
2008-06-28 7:03 ` Robert Anderson
2008-06-28 14:51 ` Johannes Schindelin
1 sibling, 2 replies; 61+ messages in thread
From: Jeff King @ 2008-06-28 5:03 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Schindelin, Robert Anderson, Git Mailing List
On Fri, Jun 27, 2008 at 11:15:44AM -0700, Junio C Hamano wrote:
> I've always said that I am not in favor of any form of partial commits,
> exactly for the reason Robert states, namely that you are not committing
> what you had in your work tree as a whole. I said so back when the only
> form of partial commits were "git commit [-o] this-file". I said it again
> even when I introduced "add -i", that the interface goes backwards and
> does not fix the issues associated with partial commits.
I do partial commits all the time. I used to use the "go back and clean
up and test each" method. But now with stash, I use the workflow
mentioned elsewhere in the thread:
1. hack hack hack
2. add -i; commit -m tmp
3. stash
4. reset HEAD^
which is really kind of awkward, since I didn't want to make that commit
in the first place.
I think of it as three ordered buckets: index, working tree, and stash.
You can move changes from any bucket to an adjacent bucket, but you can
only test what's in the working tree.
So we have too many changes in the working tree. Right now we can put
some of them in the index bucket. But that doesn't help with testing.
So what I do now is move good changes to the index bucket (and then
commit -- more on that in a second), and then everything else to the
stash bucket, and then reset the commit.
The extra commit / reset is annoying. We could do better than that
with the proposed "stash --keep-index". Then I just have to move my good
changes into the index and say "ok, now stash everything else."
But that still involves two bucket moves. I think what would be much
more natural is to simply say "I don't want these changes right now;
move them into the stash bucket." And Dscho mentioned "git stash -i",
which does that (and theoretically, it could even be based on the "git
add -i" code).
What you propose below accomplishes the same thing, but seems mentally
reversed to me (and involves two bucket moves):
> One thing I think would make sense is to stash away _everything_ at this
> point. That would take you to the state before you started working. Then
> if we can selectively _unstash_ the parts that should logically be
> committed first to bring them to your work tree, then you can inspect that
> change against HEAD, test it, and when you are happy with it, you would
> make your first commit in the final sequence.
Here we say "OK, I don't want any of these changes; stash them" and then
selectively bring them back. And maybe that _is_ what you want
sometimes, or maybe how certain people think. But personally, given two
sets of changes, what makes sense to me is to directly say "these are
the changes I _don't_ want". And at any point after ditching some
changes, you can re-run your tests.
So I fundamentally think that all of these contortions are because
moving things to the stash bucket is not as featureful as moving them to
the index bucket. And there's no reason for it, since we can use the
_same_ tools to do both.
Here's a somewhat hackish implementation of "git stash -i" that just relies
on "add -i":
---
diff --git a/git-stash.sh b/git-stash.sh
index 4938ade..6685004 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -67,7 +67,7 @@ create_stash () {
GIT_INDEX_FILE="$TMP-index" &&
export GIT_INDEX_FILE &&
git read-tree -m $i_tree &&
- git add -u &&
+ git add $ADD_OPTIONS </dev/tty >/dev/tty 2>&1 &&
git write-tree &&
rm -f "$TMP-index"
) ) ||
@@ -218,6 +218,11 @@ drop_stash () {
git rev-parse --verify "$ref_stash@{0}" > /dev/null 2>&1 || clear_stash
}
+ADD_OPTIONS="-u"
+case "$1" in
+ -i|-p) ADD_OPTIONS=$1; shift
+esac
+
# Main command set
case "$1" in
list)
@@ -235,7 +240,7 @@ show)
;;
save)
shift
- save_stash "$*" && git-reset --hard
+ save_stash "$*" && show_stash -p -R | git apply
;;
apply)
shift
@@ -269,7 +274,7 @@ pop)
then
save_stash &&
echo '(To restore them type "git stash apply")' &&
- git-reset --hard
+ show_stash -p -R | git apply
else
usage
fi
^ permalink raw reply related [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-28 5:03 ` Jeff King
@ 2008-06-28 7:03 ` Robert Anderson
2008-06-28 8:53 ` Jeff King
2008-06-28 14:51 ` Johannes Schindelin
1 sibling, 1 reply; 61+ messages in thread
From: Robert Anderson @ 2008-06-28 7:03 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, Johannes Schindelin, Git Mailing List
On Fri, Jun 27, 2008 at 10:03 PM, Jeff King <peff@peff.net> wrote:
> So I fundamentally think that all of these contortions are because
> moving things to the stash bucket is not as featureful as moving them to
> the index bucket. And there's no reason for it, since we can use the
> _same_ tools to do both.
>
> Here's a somewhat hackish implementation of "git stash -i" that just relies
> on "add -i":
Are all features for moving changes to stash bi-directional in your
implementation? Can we move a hunk out of stash, just as easily as we
can move one in? I think this is an essential property of a good
implementation of this workflow.
As to which way people like to think and work, in terms of re-applying
changes from a fresh state one at a time, or just pushing off changes
they don't want, I think ensuring bi-directionality in the tools for
moving changes back and forth will ensure that all such scenarios will
be equally well supported.
It does seem to me at this point that extending stash functionality is
a reasonable way to approach supporting this type of workflow.
Thanks,
Bob
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-28 7:03 ` Robert Anderson
@ 2008-06-28 8:53 ` Jeff King
2008-06-28 21:53 ` Junio C Hamano
0 siblings, 1 reply; 61+ messages in thread
From: Jeff King @ 2008-06-28 8:53 UTC (permalink / raw)
To: Robert Anderson; +Cc: Junio C Hamano, Johannes Schindelin, Git Mailing List
On Sat, Jun 28, 2008 at 12:03:54AM -0700, Robert Anderson wrote:
> > Here's a somewhat hackish implementation of "git stash -i" that just relies
> > on "add -i":
>
> Are all features for moving changes to stash bi-directional in your
> implementation? Can we move a hunk out of stash, just as easily as we
> can move one in? I think this is an essential property of a good
> implementation of this workflow.
No, they're not bi-directional. You get the full power of "add -i" when
moving things into the stash, but not out. It is the reverse of the
situation with the index; we have good tools for staging things, but not
for unstaging them.
But I agree that they _should_ be. Given the patch I posted already,
probably the simplest way to do both at once would be to give "add -i"
an "unstage" mode.
> It does seem to me at this point that extending stash functionality is
> a reasonable way to approach supporting this type of workflow.
Actually, I oversimplified a little bit in my "buckets" description.
Stash actually stashes two things: the current index and the current
worktree. So in that sense, it is not just another bucket as I
described. For the purposes of the workflow we're discussing, I think
that is how we want it to function. But the implementation will be a bit
trickier than it might otherwise be because of this. I just didn't want
to have to introduce another, slightly different type of stash.
-Peff
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-28 8:53 ` Jeff King
@ 2008-06-28 21:53 ` Junio C Hamano
0 siblings, 0 replies; 61+ messages in thread
From: Junio C Hamano @ 2008-06-28 21:53 UTC (permalink / raw)
To: Jeff King; +Cc: Robert Anderson, Johannes Schindelin, Git Mailing List
Jeff King <peff@peff.net> writes:
> Actually, I oversimplified a little bit in my "buckets" description.
> Stash actually stashes two things: the current index and the current
> worktree. So in that sense, it is not just another bucket as I
> described. For the purposes of the workflow we're discussing, I think
> that is how we want it to function. But the implementation will be a bit
> trickier than it might otherwise be because of this. I just didn't want
> to have to introduce another, slightly different type of stash.
You do *not* have to use stash that has different index and work tree
components and then your buckets description makes sense.
The index is to hold good changes verified to be fine to make commits, the
work tree is to test and verify outstanding changes, and the stash is to
hold the remainder (i.e. further changes that does not belong to what you
are currently looking at in your work tree).
When your workflow is to "verify and immediately commit", then the need
for buckets to your particular workflow can degenerate to a one that does
not need the index. That is essentially Robert's workflow (but it does
not mean it is the only valid one).
What I do these days is this:
* Fork a new topic from the commit I pushed out the last time to the
public ("git checkout -b jc/topic ko/master").
* Think, hack, commit, think, hack, commit, lather, rinse, repeat.
* Make sure everything is worthy for the final state. There can be (and
need to be to use the current set of tools) some uncommitted changes.
Make a stash, so that the work tree component records the final tree,
and mentally name it the "commit goal".
* I have never grew comfortable operating "edit" insn in "rebase -i", so
the workflow from this point does not use it. Instead, I detech the
HEAD to the root of the series ("git checkout ko/master^0") at this
point. Now, none of my change is in the work tree.
* Repeat the following:
* Recreate the work tree state for the next round to be built on HEAD
and make a commit, after verifying what I have in the commit is good.
Examples of the tools at my disposal are:
* "cherry-pick jc/topic~$N" to get the necessary changes from my
earlier "snapshots", which can possibly be followed by a "git
commit --amend". This "going forward" is easiest especially in the
early part of the sequence.
"format-patch --stdout jc/topic~$N..jc/topic~$M | git am" is a
slight variant of the above when I already had a good logical
sequence (someday we probably will have "cherry-pick A..B").
* "read-tree -m -u stash" to read the final state of the tree,
selectively _remove_ the parts I do not want in this round, and
make a commit ("git add -i && git commit && git reset --hard").
This "going backward" is easier near the end of the sequence than
other method that goes forward.
* If I find some issues to be fixed in the state that was stashed
(which I earlier thought was perfect) during the above:
* "read-tree -m -u stash" to read the (previous) final state, fix it
up, "stash drop" and "stash save" to update our "commit goal".
The above is repeated until "git diff HEAD stash" does not have
anything I need in the final series.
The lower-level "read-tree -m -u" probably can be replaced with "stash
apply" in real life, but I tend to try to ask for the final tree
explicitly, because there is no reason to perform three-way merge dance
"stash apply" does for these steps.
* Final re-review:
* "git diff jc/topic HEAD" to see if I did not miss anything (and review
the "oops, the earlier commit goal was faulty" fixes).
* "git log --reverse -p ko/master.." to see the final shape of the
series.
* "git branch -f jc/topic" to finish it off.
The commits from the session are merely convenient snapshot points that I
can use during the clean-up phase for series of cherry-picks to prepare
bulk of each of the logical change in the final series. If somebody
subscribes to a dogma not to make commits of unproven changes, that is
fine, and such a person may not have any commits during "think, hack,
lather, rinse, repeat" phase, and that is fine. But fortunately I don't.
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-28 5:03 ` Jeff King
2008-06-28 7:03 ` Robert Anderson
@ 2008-06-28 14:51 ` Johannes Schindelin
2008-07-08 4:58 ` Jeff King
1 sibling, 1 reply; 61+ messages in thread
From: Johannes Schindelin @ 2008-06-28 14:51 UTC (permalink / raw)
To: Jeff King; +Cc: Git Mailing List
Hi.
On Sat, 28 Jun 2008, Jeff King wrote:
> Here's a somewhat hackish implementation of "git stash -i" that just
> relies on "add -i":
I like it.
> +ADD_OPTIONS="-u"
> +case "$1" in
> + -i|-p) ADD_OPTIONS=$1; shift
> +esac
I'll squash in "|-e" here.
Note that some time ago, I was working on "git stash apply -i", which I
never came around to finish. Yesterday, I was briefly considering working
on it, but I have other things to tend to now.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-28 14:51 ` Johannes Schindelin
@ 2008-07-08 4:58 ` Jeff King
0 siblings, 0 replies; 61+ messages in thread
From: Jeff King @ 2008-07-08 4:58 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Git Mailing List
On Sat, Jun 28, 2008 at 03:51:12PM +0100, Johannes Schindelin wrote:
> > Here's a somewhat hackish implementation of "git stash -i" that just
> > relies on "add -i":
>
> I like it.
Thinking about this some more, it seems to me to lack one really
important feature that "git add -i" has: you must stash all in one go.
That is, I may do some of the adds as "git add <file1> <file2>" and then
pick out the rest of the changes with "git add -p". And traditionally,
stashing has been about dumping all changes, so everything happened at
once.
But I think what I would really like here is to say "now I don't want to
stage for a commit; I want to stage into some bucket, so that I can
clear my workspace for making the commit". And then proceed to use "add"
or "add -i" in the usual way, except that they go into my bucket. And at
the end, I switch back to staging for a commit, make the commit, and
then start picking things out of my bucket.
And that workflow is not too hard to imagine by just pointing
GIT_INDEX_FILE to the bucket.
But I am still thinking on this, so I'll let it percolate and then maybe
try to implement something once I have a better sense of exactly what
workflow I want. I just thought I would throw it out there for others to
ponder.
-Peff
^ permalink raw reply [flat|nested] 61+ messages in thread
[parent not found: <willow-jeske-01l7H4tHFEDjCgPV-01l7H4sOFEDjCbyi>]
* Re: An alternate model for preparing partial commits
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7H4sOFEDjCbyi>
@ 2008-06-27 20:29 ` David Jeske
2008-06-27 20:29 ` David Jeske
1 sibling, 0 replies; 61+ messages in thread
From: David Jeske @ 2008-06-27 20:29 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
Robert, I'm new to git, but I understand where you are going.
Why limit it only to working tree changes? For me, the stash machinery is of no
help here, because I commit super-often. What I end up with is 30 commits in a
topic branch, but where not every point passes 100% of tests. I want to go back
through and order them properly, and decide which points are sensible as
upstream committs. (especially as I read more about bisect).
git has all the concepts I want except one. However, it makes the process
pretty manual. Here is an idea about automating it. I'll talk about that one
new concept at the bottom.
I think of this as reorder/merge/split...
reorder: Picture that a list of commits on this branch opens in an editor. You
are free to rearrange the lines in any order you want, but you have to keep all
the lines. When you are done reordering the lines, the tool creates a new topic
branch and applies the changes (probably with cherrypick) to the new topic
branch. If there are no conflicts, you're done.
merge: Picture now that in your editor you can create groupings of those
individual commits that should make up separate topic-branches. The operation
can still be performed automatically, and at the end, it can compose those
topic branches into a single branch just like your original. At this point, you
can "isolate" any one of those topic branches and test/push that topic branch.
split: Picture now that you can list the same commit in more than one of the
topic-branches. This is a little more tricky, and there is no way to do it
automatically.. It drops you into an editor and asks you to select the lines of
the diff for the first topic. The remaining lines are put in the next topic.
This can continue for multiple topics.
This seems like something that could be assembled pretty easily on top of the
current git mechanisms, except for one thing.
If you use merge, the history will be a mess. If you use rebase, anyone else
who pulled your topic branch will be in a world of hurt.
I've been thinking about a solution for this I think of as "supercede".
Once you have completed the above reorder/merge/split, your new topic branch
should be EXACTLY the same as your old topic branch. (if it's not, it needs to
be trued up to be so). At that point, it is safe to ask for that new line of
commits to supercede the old line. Other people who have pulled in your older
ordered topic branch would then be able to pull/rebase/etc, and the merge
machinery would be able to back out their set of changes, and supercede them
with your new ordering.
This mechanism is intended to combine the benefits of rebase-clean-history and
the benefits of the dag-links for merging. I find it convenient to think of it
as stack push/pop for portions of the dag. Because of the supercede - the
history knows it can avoid showing you all the superceded dag nodes, however,
because those nodes are there, it can still use them to compute merges.
If this behaves the way I think, this has another powerful effect. You can pull
in a set of draft changes; you can build off them; you can periodically rebase
them, and if those draft changes end up in the mainline, because the
merge-history is still there, git can 'do the right thing' and remove those
changes from your topic branch. In fact, because of the SHA1 strong naming, it
doesn't even matter where you got them from. You could apply a patch from the
mailing list and as long as everyone applies that patch as only a single
commit, when the string of supercedes shows up on the main branch git will just
'do-the right thing' to remove them from your topic branch when you rebase (or
skip them during a merge down to your topic branch).
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7H4sOFEDjCbyi>
2008-06-27 20:29 ` David Jeske
@ 2008-06-27 20:29 ` David Jeske
2008-06-27 20:47 ` Jakub Narebski
1 sibling, 1 reply; 61+ messages in thread
From: David Jeske @ 2008-06-27 20:29 UTC (permalink / raw)
To: Robert Anderson; +Cc: Git Mailing List
Robert, I'm new to git, but I understand where you are going.
Why limit it only to working tree changes? For me, the stash machinery is of no
help here, because I commit super-often. What I end up with is 30 commits in a
topic branch, but where not every point passes 100% of tests. I want to go back
through and order them properly, and decide which points are sensible as
upstream committs. (especially as I read more about bisect).
git has all the concepts I want except one. However, it makes the process
pretty manual. Here is an idea about automating it. I'll talk about that one
new concept at the bottom.
I think of this as reorder/merge/split...
reorder: Picture that a list of commits on this branch opens in an editor. You
are free to rearrange the lines in any order you want, but you have to keep all
the lines. When you are done reordering the lines, the tool creates a new topic
branch and applies the changes (probably with cherrypick) to the new topic
branch. If there are no conflicts, you're done.
merge: Picture now that in your editor you can create groupings of those
individual commits that should make up separate topic-branches. The operation
can still be performed automatically, and at the end, it can compose those
topic branches into a single branch just like your original. At this point, you
can "isolate" any one of those topic branches and test/push that topic branch.
split: Picture now that you can list the same commit in more than one of the
topic-branches. This is a little more tricky, and there is no way to do it
automatically.. It drops you into an editor and asks you to select the lines of
the diff for the first topic. The remaining lines are put in the next topic.
This can continue for multiple topics.
This seems like something that could be assembled pretty easily on top of the
current git mechanisms, except for one thing.
If you use merge, the history will be a mess. If you use rebase, anyone else
who pulled your topic branch will be in a world of hurt.
I've been thinking about a solution for this I think of as "supercede".
Once you have completed the above reorder/merge/split, your new topic branch
should be EXACTLY the same as your old topic branch. (if it's not, it needs to
be trued up to be so). At that point, it is safe to ask for that new line of
commits to supercede the old line. Other people who have pulled in your older
ordered topic branch would then be able to pull/rebase/etc, and the merge
machinery would be able to back out their set of changes, and supercede them
with your new ordering.
This mechanism is intended to combine the benefits of rebase-clean-history and
the benefits of the dag-links for merging. I find it convenient to think of it
as stack push/pop for portions of the dag. Because of the supercede - the
history knows it can avoid showing you all the superceded dag nodes, however,
because those nodes are there, it can still use them to compute merges.
If this behaves the way I think, this has another powerful effect. You can pull
in a set of draft changes; you can build off them; you can periodically rebase
them, and if those draft changes end up in the mainline, because the
merge-history is still there, git can 'do the right thing' and remove those
changes from your topic branch. In fact, because of the SHA1 strong naming, it
doesn't even matter where you got them from. You could apply a patch from the
mailing list and as long as everyone applies that patch as only a single
commit, when the string of supercedes shows up on the main branch git will just
'do-the right thing' to remove them from your topic branch when you rebase (or
skip them during a merge down to your topic branch).
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
2008-06-27 20:29 ` David Jeske
@ 2008-06-27 20:47 ` Jakub Narebski
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7[1OFFEDjCYJV>
[not found] ` <-8386235276716376372@unknownmsgid>
0 siblings, 2 replies; 61+ messages in thread
From: Jakub Narebski @ 2008-06-27 20:47 UTC (permalink / raw)
To: git
David Jeske wrote:
> reorder: Picture that a list of commits on this branch opens in an editor. You
> are free to rearrange the lines in any order you want, but you have to keep all
> the lines. When you are done reordering the lines, the tool creates a new topic
> branch and applies the changes (probably with cherrypick) to the new topic
> branch. If there are no conflicts, you're done.
>
> merge: Picture now that in your editor you can create groupings of those
> individual commits that should make up separate topic-branches. The operation
> can still be performed automatically, and at the end, it can compose those
> topic branches into a single branch just like your original. At this point, you
> can "isolate" any one of those topic branches and test/push that topic branch.
git rebase --interactive?
Any patch management interface (StGIT, Guilt)?
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
@ 2008-06-28 1:17 Theodore Tso
2008-06-28 1:56 ` Miklos Vajna
0 siblings, 1 reply; 61+ messages in thread
From: Theodore Tso @ 2008-06-28 1:17 UTC (permalink / raw)
To: David Jeske; +Cc: Robert Anderson, Git Mailing List
On Fri, Jun 27, 2008 at 08:29:15PM -0000, David Jeske wrote:
> git has all the concepts I want except one. However, it makes the process
> pretty manual. Here is an idea about automating it. I'll talk about that one
> new concept at the bottom.
>
> I think of this as reorder/merge/split...
>
> reorder: Picture that a list of commits on this branch opens in an
> editor. You are free to rearrange the lines in any order you want,
> but you have to keep all the lines. When you are done reordering the
> lines, the tool creates a new topic branch and applies the changes
> (probably with cherrypick) to the new topic branch. If there are no
> conflicts, you're done.....
Read the man page for for "git rebase --interactive". I think you
will find that it handles reording and merging (its called squashing)
already.
Splitting patches is harder to do and probably is one of the things
you have to do manually.
- Ted
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
@ 2008-06-28 1:23 Theodore Tso
0 siblings, 0 replies; 61+ messages in thread
From: Theodore Tso @ 2008-06-28 1:23 UTC (permalink / raw)
To: David Jeske; +Cc: Jakub Narebski, git
On Fri, Jun 27, 2008 at 08:51:41PM -0000, David Jeske wrote:
> -- Jakub Narebski wrote:
> > git rebase --interactive?
> > Any patch management interface (StGIT, Guilt)?
>
> Yes, as I said, that set of operations can be performed with git today.
>
> What git can't do, is let me "supercede" the old DAG-subset, so
> people I shared them with can get my new changes without hurting
> their world. Currently git seems to rely on the idea that "if you
> accept changes into your tree that will be later rebased, it's up to
> you to figure it out". I don't see why that is the case
Because it's fundamentally hard and fraught with danger --- especially
since with git-rebase --interactive you actually can *edit* an
intervening patch, so commits that are based off of a rebased branch
have absolutely no guarantee of correctly applying against the rebased
branch.
If they do apply cleanly, you can use git rebase --onto, but the
possibility of merge conflicts are endless.
The general workflow here is that you simply don't share your git
state until it's been refactored and you're positive that it you've
gotten it right. Or if you do share, it you do so in a branch where
you tell people --- don't base work off of this! (i.e., a "pu" branch
like git has.)
As I said earlier, premature sharing is highly over-rated. And having
people develop against an unstable branch is just extra work for them
anyway. So commit frequently, and if you want to backup your local
hard drive, push regularly to your own private git repository located
off-machine. Just don't ask people base any branches off your private
branch until you're ready to publish it in a form after which you
don't do rebase operations. This works quite well for many projects
and many developers.
- Ted
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: An alternate model for preparing partial commits
@ 2008-06-28 9:30 Stephen R. van den Berg
0 siblings, 0 replies; 61+ messages in thread
From: Stephen R. van den Berg @ 2008-06-28 9:30 UTC (permalink / raw)
To: David Jeske; +Cc: Stephen Sinclair, Git Mailing List
David Jeske wrote:
>- I could supercede 2-commits with 1, effectively making the bad-commit
>disappear in the linear history. Users who already have the history, however,
>would be unaffected, because the start/end endpoints are the same.
Superseding does not work in git trees and is a disruptive operation to
*all* commits following the point being superseded.
Also, superseding preserves the startpoint, but *always* alters the
endpoint.
I suggest you take a look at how a git-repository is stored and learn
about how the SHA1-hashes interact with the stored repository.
--
Sincerely,
Stephen R. van den Berg.
Heisenberg might have been here.
^ permalink raw reply [flat|nested] 61+ messages in thread
end of thread, other threads:[~2008-07-08 5:00 UTC | newest]
Thread overview: 61+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-27 6:50 An alternate model for preparing partial commits Robert Anderson
2008-06-27 7:10 ` Björn Steinbrink
2008-06-27 14:37 ` [PATCH/RFC] stash: introduce 'stash save --keep-index' option SZEDER Gábor
2008-06-27 18:26 ` Junio C Hamano
2008-06-27 16:54 ` An alternate model for preparing partial commits Robert Anderson
2008-06-27 17:27 ` Björn Steinbrink
2008-06-27 17:34 ` Robert Anderson
2008-06-27 8:35 ` Johannes Sixt
2008-06-27 17:01 ` Robert Anderson
2008-06-27 8:50 ` Petr Baudis
2008-06-27 17:02 ` Robert Anderson
2008-06-27 13:33 ` Johannes Schindelin
2008-06-27 13:49 ` Miklos Vajna
2008-06-27 17:14 ` Robert Anderson
2008-06-27 17:45 ` Johannes Schindelin
2008-06-27 17:49 ` Robert Anderson
[not found] ` <alpine.DEB.1.00.0806271854120.9925@racer>
2008-06-27 18:07 ` Robert Anderson
2008-06-27 18:20 ` Dana How
2008-06-27 20:31 ` Stephen Sinclair
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7ZhB8FEDjCdJs>
2008-06-27 20:45 ` David Jeske
2008-06-28 17:23 ` Wincent Colaiuta
2008-06-27 20:45 ` David Jeske
2008-06-28 2:14 ` Dmitry Potapov
2008-06-28 2:57 ` Robert Anderson
2008-06-28 4:03 ` Dmitry Potapov
[not found] ` <9af502e50806272320p23f01e8eo4a67c5f6f4476098@mail.gmail.com>
2008-06-28 6:31 ` Fwd: " Robert Anderson
2008-06-28 12:38 ` Dmitry Potapov
[not found] ` <20080628123522.GL5737@dpotapov.dyndns.org>
2008-06-28 15:53 ` Robert Anderson
2008-06-28 16:52 ` Dmitry Potapov
2008-06-27 18:15 ` Junio C Hamano
2008-06-27 18:43 ` Robert Anderson
2008-06-28 5:03 ` Jeff King
2008-06-28 7:03 ` Robert Anderson
2008-06-28 8:53 ` Jeff King
2008-06-28 21:53 ` Junio C Hamano
2008-06-28 14:51 ` Johannes Schindelin
2008-07-08 4:58 ` Jeff King
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7H4sOFEDjCbyi>
2008-06-27 20:29 ` David Jeske
2008-06-27 20:29 ` David Jeske
2008-06-27 20:47 ` Jakub Narebski
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7[1OFFEDjCYJV>
2008-06-27 20:51 ` David Jeske
2008-06-27 20:51 ` David Jeske
[not found] ` <-8386235276716376372@unknownmsgid>
2008-06-27 22:55 ` Robert Anderson
2008-06-27 23:14 ` Junio C Hamano
2008-06-28 0:08 ` Robert Anderson
2008-06-28 2:57 ` Dmitry Potapov
2008-06-28 3:31 ` Robert Anderson
2008-06-28 14:34 ` Stephen Sinclair
2008-06-28 16:00 ` Robert Anderson
2008-06-28 16:30 ` Robert Anderson
2008-06-28 17:12 ` Jakub Narebski
2008-06-28 18:25 ` Robert Anderson
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l82hwbFEDjCX70>
2008-06-28 19:12 ` David Jeske
2008-06-28 19:12 ` David Jeske
2008-06-28 19:13 ` Stephen Sinclair
[not found] ` <willow-jeske-01l7H4tHFEDjCgPV-01l7buicFEDjCagd>
2008-06-28 0:22 ` David Jeske
2008-06-28 0:22 ` David Jeske
-- strict thread matches above, loose matches on Subject: below --
2008-06-28 1:17 Theodore Tso
2008-06-28 1:56 ` Miklos Vajna
2008-06-28 1:23 Theodore Tso
2008-06-28 9:30 Stephen R. van den Berg
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).