Using shelve to mimic Git's staging area

John Arbash Meinel john at arbash-meinel.com
Tue Sep 27 09:10:08 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 9/27/2011 11:00 AM, A. S. Budden wrote:
> Dear all,
> 
> I've recently been experimenting with bzr shelve.  As I understand
> it, this is intended to be an equivalent to the staging area in
> git: I can make changes on two separate issues and then commit them
> separately by moving one set of changes temporarily onto the shelf.
> I hope I have understood that right.
> 
> However, I have been unable to work out how to do this when
> changes are close together in a file.  For example, imagine I had a
> file stuff.c, which "bzr diff" reports as looking like this:
> 
> === modified file 'Stuff.c' --- Stuff.c             2011-09-22
> 14:04:20 +0000 +++ Stuff.c             2011-09-27 07:40:16 +0000 @@
> -42,6 +42,8 @@ * Some random comments preceding the change * that
> have already been committed. */ +/* I'd like to shelve this change
> */ +/* But not this one */ void AFunctionThatHasNotChanged(void) { 
> uint8_t variable;
> 
> With git, I can add one of those too new comment lines to the
> staging area and commit, then add the other one and commit [1].
> Obviously this is a rather contrived example, but is there any way
> to do the equivalent of this with bzr (q)shelve?
> 
> Thanks,
> 
> Al
> 
> [1] In the command line version of git, this is done by editing
> the patch directly; in "git gui", you can right-click on a line and
> select either "add hunk to staging area" or "add line to staging
> area".
> 

If you do "bzr config change_editor=???", and set that to a text
editor, it will allow you to do "e" to edit the file.
My change editor is configured to "vim -d".

That gives you a side-by-side of the old value of the file, and the
new value of the file. You edit the 'new' side until it looks like
what you want to keep, and then save and exit. And then bzr will leave
the new value to what you left it, and determine what diff gets
shelved based on that.

So in the above case you would hit 'e' then delete the "I want to
shelve this line" case.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6BkvAACgkQJdeBCYSNAANjOwCghB19x3f2TYJQQeFbkOQRhnW8
o6wAoLYEw7rxPhW4I4fg9POXTNuy7Aii
=qEJb
-----END PGP SIGNATURE-----



More information about the bazaar mailing list