* Teach git-gui about merging around modified files?
@ 2007-07-27 17:03 Brian Downing
2007-07-29 7:36 ` Shawn O. Pearce
0 siblings, 1 reply; 3+ messages in thread
From: Brian Downing @ 2007-07-27 17:03 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
"git merge" will happily merge a change with modified files in the tree
as long as the merge doesn't touch any of them. However, it appears
"git gui" won't even try if there are modified files at all.
How hard would it be to fix this, or is this an intentional choice?
I realize that commiting even untouched files before a merge is safer,
but I'm tasked with migrating some CVS users to Git, and I'd prefer
to be able to introduce the new Git workflow slowly.
(I'm happy enough with disallowing merges that actually touch modified
files, so I'm not looking for any kind of in-working-directory merge
like some others were. I'd just like the "git merge" behavior to work
in git-gui.)
-bcd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Teach git-gui about merging around modified files?
2007-07-27 17:03 Teach git-gui about merging around modified files? Brian Downing
@ 2007-07-29 7:36 ` Shawn O. Pearce
2007-07-29 9:04 ` Shawn O. Pearce
0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2007-07-29 7:36 UTC (permalink / raw)
To: Brian Downing; +Cc: git
Brian Downing <bdowning@lavos.net> wrote:
> "git merge" will happily merge a change with modified files in the tree
> as long as the merge doesn't touch any of them. However, it appears
> "git gui" won't even try if there are modified files at all.
Yes. That is actually intentional...
> How hard would it be to fix this, or is this an intentional choice?
Its not hard to fix. I just did it in a patch that would be:
lib/merge.tcl | 12 +-----------
1 files changed, 1 insertions(+), 11 deletions(-)
and we all know deleting more lines is good, but after I made the
patch and started testing it I remembered exactly why I don't allow
you to merge with modified files.
If you merge and get conflicts you cannot abort to your pre-merge
state safely by just doing a `git reset --hard` (or git-gui's own
builtin action that does the same) as you will toss your own not
yet committed changes too. You really need to save those changes
off first.
> I realize that commiting even untouched files before a merge is safer,
> but I'm tasked with migrating some CVS users to Git, and I'd prefer
> to be able to introduce the new Git workflow slowly.
>
> (I'm happy enough with disallowing merges that actually touch modified
> files, so I'm not looking for any kind of in-working-directory merge
> like some others were. I'd just like the "git merge" behavior to work
> in git-gui.)
What do you do when the merge goes badly on the command line
(lots of conflicts, but none to the files you have modified),
and you want to get back to your pre-merge state? You can't,
there's no state saved for git to reset back to.
Really what you want to do here is stash your local changes away,
then do the merge, and after the merge is successfully completed
apply the stash back onto your working tree. Because then if the
merge goes badly you can `git reset --hard && git stash apply`
to bring back your prior state.
So until git-gui plays along nicely with git-stash (can save
and apply to it) I'm going to continue to disallow merging with
uncommitted changes. Its just not a smart thing to be doing.
--
Shawn.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Teach git-gui about merging around modified files?
2007-07-29 7:36 ` Shawn O. Pearce
@ 2007-07-29 9:04 ` Shawn O. Pearce
0 siblings, 0 replies; 3+ messages in thread
From: Shawn O. Pearce @ 2007-07-29 9:04 UTC (permalink / raw)
To: Brian Downing; +Cc: git
"Shawn O. Pearce" <spearce@spearce.org> wrote:
> Brian Downing <bdowning@lavos.net> wrote:
> > "git merge" will happily merge a change with modified files in the tree
> > as long as the merge doesn't touch any of them. However, it appears
> > "git gui" won't even try if there are modified files at all.
>
> Yes. That is actually intentional...
>
> If you merge and get conflicts you cannot abort to your pre-merge
> state safely by just doing a `git reset --hard` (or git-gui's own
> builtin action that does the same) as you will toss your own not
> yet committed changes too. You really need to save those changes
> off first.
I felt bad about my original response to this thread. Telling a
user that their workflow is broken and should be changed is not
very nice, and not user friendly.
So I just spent a couple of hours trying to teach git-gui to first
save off your index and working directory, then run the merge, and
during abort let you restore things even if they weren't committed.
During testing I learned that you can't merge if you have any
staged but uncommitted changes. If you try git-merge-recursive
just aborts and refuses to execute the merge, even if the file
paths aren't in conflict and won't require a file level merge.
The issue is the files are staged in the index and would commit
as part of the merge commit, rather than staying out until after,
so the merge driver is really doing the right thing here.
I'm still convinced that merging while you have uncommitted changes
in the working directory is really bad. Its nearly impossible
to recover from a conflict and get back to pre-merge state, and
its also confusing to resolve conflicts because your unstaged but
modified files are still showing in the status.
I'm going to shelve this work until post 0.8.0 and try to rework
it using git-stash as part of git-gui 0.9.0. Ideally you should
be able to stash your work before merging, and unstash after the
merge is complete.
--
Shawn.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-29 9:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-27 17:03 Teach git-gui about merging around modified files? Brian Downing
2007-07-29 7:36 ` Shawn O. Pearce
2007-07-29 9:04 ` Shawn O. Pearce
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).