GIT help needed :: How to get a "diff" between current moodle folder or file and proposed "improvement"

GIT help needed :: How to get a "diff" between current moodle folder or file and proposed "improvement"

by Joseph Rézeau -
Number of replies: 8
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi all GIT gurus again!

Further to this discussion: displaying images in random glossary block, I have created MDL-28413 and made a hacked version of the random glossary block available on my github at https://github.com/rezeau/moodle/tree/MDL-28413_display_attachments_in_glossary_random_block.

In the discussion at MDL-28413, Petr says "The problem is I can not see easily what you changed, ..."

My question is: how can I create a kind of "diff" file ? folder ? ... ? somewhere on my github that would compare the current version of the random glossary block folder (MOODLE_21_STABLE, latest version) and my own hacked version in order to make the changes immediately visible?

Thanks for pointers.

Joseph

Average of ratings: -
In reply to Joseph Rézeau

Re: GIT help needed :: How to get a "diff" between current moodle folder or file and proposed "improvement"

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Assuming you have the original in the MOODLE_21_STABLE branch and your code in the current branch:

git diff MOODLE_21_STABLE blocks/glossary_random > mychanges.diff

In general:

git diff [branch/commit to compare to] [optional: folder / file to compare]

Average of ratings: Useful (2)
In reply to Joseph Rézeau

Re: GIT help needed :: How to get a "diff" between current moodle folder or file and proposed "improvement"

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can do it through the github interface: https://github.com/rezeau/moodle/compare/MOODLE_21_STABLE...MDL-28413_display_attachments_in_glossary_random_block

However, that just deals with seeing the changes. There is a higher-level point: are you changes clear?

I would say that they are not as clear as they could be in the following ways:

  1. There are some merge commits there that just add noise. Much better to have a clean branch that starts with the latest MOODLE_21_STABLE and adds a few extra commits.
  2. The commit that adds the French lang strings is irrelevant to the change that is under discussion.
  3. The //devjr comments are also just noise. They would have to be stripped out before this is committed.
  4. However, they do point out that this is a lot of copy-and-paste code from somewhere else, which is bad.
  5. There seems to be no good reason for https://github.com/rezeau/moodle/commit/0ccaf05543151ef18d1dd00e50729398d6cc0d22 to be a separate commit.
  6. The commit comment "glossary_random to display attached files" does not follow the Moodle house style, and is not very informative. It is not bad as the first line of a commit comment, but I would add a bit more after that, possibly some of the information that is currently in the devjr comments.

You can probably fix this using something like:

git checkout -b MDL-28413_glossary_random_new MOODLE_21_STABLE

git cherry-pick 45076a94026

git cherry-pick 0ccaf0554315

git rebase -i MOODLE_21_STABLE

and use the interactive rebase to squash the two commits into one.

Average of ratings: Useful (3)
In reply to Joseph Rézeau

Re: GIT help needed :: How to get a "diff" between current moodle folder or file and proposed "improvement"

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Many thanks to all who tried to help, especially Tim for his detailed explanations...

I will take the time to "digest" all this info and maybe start again from fresh (if I cannot "repair" my mistakes).

@ Tim : when you say " Much better to have a clean branch that starts with the latest MOODLE_21_STABLE and adds a few extra commits." does this mean that I should have developed my hacks on my local box, and not pushed them to my github until I was satisfied with the local result?

Joseph

In reply to Joseph Rézeau

Re: GIT help needed :: How to get a "diff" between current moodle folder or file and proposed "improvement"

by Frank Ralf -
Just found these detailed instructions for creating patches using Git: http://drupal.org/node/1054616
Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: GIT help needed :: How to get a "diff" between current moodle folder or file and proposed "improvement"

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Not at all. Publishing on github is good.

One of the useful thing about git is that it is easy to build new branches out of arbitrary sets of changes, so it is easy to clean things up later.

Average of ratings: Useful (1)
In reply to Joseph Rézeau

Re: GIT help needed :: How to get a "diff" between current moodle folder or file and proposed "improvement"

by Robert Striker -

Could simply put a diff that writes to file as part of a hook, such that you never need to bothered to remember to manually do it. If your interested in a more comericial git support option I'd recommend Clearvision-CM