[Vm-dev] git and branch JMM/SleepTime

Ben Coman btc at openinworld.com
Thu Mar 23 08:17:27 UTC 2017

On Thu, Mar 23, 2017 at 4:47 AM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> I don't understand how to see a branch's changes.
> I updated a clone of opensmalltalk-vm and switched to John's JMM/SleepTime branch:
> McStalker.oscogvm.clean$ git pull -a
> Already up-to-date.
> McStalker.oscogvm.clean$ git checkout -b JMM/SleepTime
> Switched to a new branch 'JMM/SleepTime'

As someone Stefan said, the "-b" creates a new branch,
as the response also advises.  That command should have said
"fatal: A branch named 'JMM/SleepTime' already exists"
which implies that that branch was not in your local repository.

> McStalker.oscogvm.clean$ git status
> On branch JMM/SleepTime
> nothing to commit, working tree clean

If you were previously in a clean "Cog" branch,
then nothing has changed in your working directory.
Per the "-b" you just created a branch tag "JMM/SleepTime"
pointing at the same commit as "Cog."

> then I searched for the code, of which there was no sign:
> McStalker.oscogvm.clean$ find platforms/iOS -type f -exec grep -H 'receive[A-Za-z]*Note' {} \;
> McStalker.oscogvm.clean$ diff platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m ~/oscogvm/platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m
> What gives?  I'm on John's branch but I don't see his modifications.

You are not on his branch.  Just a branch with the same name.
Just check what branches you have in case something was misspelt.

$ git banch -vv

Now to recover, first you should delete that branch you created locally.

$ git checkout Cog
$ git branch -d JMM/SleepTime

Now I'm going to advocate that you don't use "git pull"
and instead separately use "git fetch && git merge".
"git pull" essentially rolls both those into one, which is efficient
by a few keystrokes,
but you lose the cognitive understanding of what is going on.
As described at [1] "[The] nice point about fetching and merging
separately [is] it gives you the chance to examine what you’ve fetched
before deciding what to do next. Also, by doing this separately the
distinction between when you should use a local branch name and a
remote-tracking branch name becomes clear very quickly."

I think that last point is particularly important when you've come
from a subversion background.
Possibly even though you've found a daily workflow with git, how you
"think" about repositories is probably
still heavily biased by your long subversion usage. I actually find
the topic "remote-tracking" branches
mildly confusing when it generically refer to "origin/master".  I find
it much easier to understand
by concretely renaming origin to its github remote name. So please
humour me and try this...

$ git remote -v
$ git remote rename origin OpenSmalltalk
$ git remote -v
(and later you can revert doing...)
($ git remote rename OpenSmalltalk origin)

$ git fetch
$ git branch -r
should show...

Now without *absolutely*no*risk* to your local work,
you can review the difference between two remote branches on github..
$ git diff  OpenSmalltalk/Cog  OpenSmalltalk/JMM//SleepTime

or your local branch and a remote branch...
$ git diff  Cog   OpenSmalltalk/JMM//SleepTime

or if your working is clean...
$ git checkout Cog
$ git diff  JMM//SleepTime

Note that you can use <tab> completion for the branch names.

So btw that is how *I* *need* to do it since I work in my own "bencoman" fork,
and long time ago I did this...
$ git remote add OpenSmalltalk

but since you work in the mainline "OpenSmalltalk" fork
you could do this...
$ git diff  Cog  JMM//SleepTime
$ git checkout Cog
$ git diff  JMM//SleepTime

However I believe (not tested), if OpenSmalltalk/JMM//SleepTime moves ahead,
you would need to do this...
$ git fetch
$ git checkout  JMM/SleepTime
$ git merge
$ git diff  Cog

$ git fetch
$ git diff  OpenSmalltalk/Cog  OpenSmalltalk/JMM//SleepTime
seems a little easier and *always* means the same thing regardless of
which branch I am working in.

Now looking at   https://github.com/OpenSmalltalk/opensmalltalk-vm/network
I see that JMM/SleepTime is just a single commit off the mainline,
so if you want to see just those changes, you can do...
$ git fetch
$ git diff OpenSmalltalk/Cog...OpenSmalltalk/JMM/SleepTime

where the ellipsis provides the difference from where the second
branched off the first,
which is what you are probably really interested in!

[1] https://longair.net/blog/2009/04/16/git-fetch-and-merge/


Now just to round things out, you could review the changes from
Guido's Nopsys fork like this...
$ git remote add charig https://github.com/charig/opensmalltalk-vm.git
$ git fetch
$ git diff OpenSmalltalk/Cog..charig/Cog
although I'm not sure if the paltform submodule is included (??)

cheers -ben

More information about the Vm-dev mailing list