space


Forcing user to remove trailing spaces in git

There are simple ways to force the user in removing trailing spaces before committing code in git using hooks.
Below we will present a solution that is applied at the local computer before the commit stage, which each developer needs to perform in each repository clone they own.
Note: If you would like to have the hooks on the server, you will need extra access rights to modify the hooks on the remote machine, maybe you will even need your systems administrator to configure it.

Solution

Attached you will find a file named pre-commit ( pre-commit (compressed) (134 downloads) ) it is a hook that get applied before the user is allowed to even commit.
That file you need to copy it (after you extract it) in the .git/hooks folder of your cloned repositories and you are done!

What this script does is simple, if there are whitespace errors, it prints the offending file names and fails.
What are considered whitespace errors is controlled by core.whitespace configuration.
By default, trailing whitespaces (including lines that solely consist of whitespaces) and a space character that is immediately followed by a tab character inside the initial indent of the line are considered whitespace errors.

In case you need to commit files that have whitespace errors, you can bypass the checks that are applied by the hooks using the --no-verify flag as follows:

git commit -m "Some informative message" --no-verify;

There are more ways to achieve this result, others are more verbose but this one is the simplest and more flexible as you can configure it using the git configuration variables.

pre-commit (compressed) (134 downloads)

#!/bin/sh
#
# This hook script verifies that there are no whitespace errors in the files to be committed

if git rev-parse --verify HEAD >/dev/null 2>&1
then
 against=HEAD
else
 # Initial commit: diff against an empty tree object
 against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

# Redirect output to stderr.
exec 1>&2

# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --

pre-commit (compressed) (134 downloads)

Advertisements

2GB επιπλέον χώρος στο GMail

Για να πάρετε δωρεάν 2GB επιπλέον χώρο μπείτε στον έλεγχο ασφαλείας του profile σας μέχρι τις 11 Φεβρουαρίου 2016 (αύριο) και ολοκληρώστε την διαδικασία.

Διαρκεί μόνο 2 λεπτά και 2GB επιπλέον χώρος θα γίνουν δικά σας!

Αυτή η κίνηση έγινε επ’ευκαιρίας της ημέρας ασφαλής χρήσης του διαδικτύου.


Beta test dropbox and get even more free space!

We tried this and it works!

Dropbox is now offering a way of increasing your free space by trying out an Experimental build of the application that allows your machine to scan an external device, like a cell phone mounted as a hard disk, and automatically sync the contents of the folder with your dropbox account.

What they promised is that for every 500MB of uploaded material through the autorun feature on the device uploaded to your profile, you will get it back for free with a limit of going up to 5GB, which is not something to joke about especially for the folks that have 2GB or 2.25GB only. (Tip: you get the first 500MB by just uploading a single photograph :))

How to get and use this build:

  1.  Go to this site http://forums.dropbox.com/forum-build.php which will guide you to the page the build information
  2. Download one of the distributions, depending on your system. (The day this article was written this was the latest build for Windows:
    > Windows: http://dl-web.dropbox.com/u/17/Dropbox%201.3.14.exe
  3. Of course install it as usual, and when you are done make sure it is running
  4. After that, mount your mobile device as an external disk drive to your computer and wait for the autorun menu to appear (if it doesn’t go to ‘My Computer’, right click on the device and select autorun)
  5. From the new window select the dropbox functionality as follows and give it some time to do its magic 🙂

Note: All uploaded photos will be renamed to this format  “<Year>-<Month>-<Day> <Hour>.<Minute>.<Second?>-<Increasing Number if needed>”(e.g 2012-02-07 15.12.22.jpg) but they will not lose their EXIF information.

Note: You will be able to find your uploaded photographs in the folder ‘Camera Uploads’ in the main folder of your dropbox account.

Sources:
(2/1) – Experimental Forum Build – 1.3.12
(2/7) – Experimental Forum Build – 1.3.14
These threads could become obsolete any day now so be sure to check out this page (newer forum build), which we believe will keep on taking you to the latest information.