One of the problems with using git on Windows is that it’s difficult to integrate it with other native (Windows) tools. That’s because the environment git runs in (cygwin or msysgit) refers to files by their UNIX name, but the Windows tools have no notion of where /tmp
is for example (and that location can be different between cygwin and msysgit).
When doing an interactive rebase, the editor might be asked to edit a file such as /cygdrive/c/some/path/to/a/file
. When doing a diff in git, one or both of the files to be diff’d might be placed by git in /tmp
. Windows tools don’t understand such path names.
Fortunately, cygwin ships with a utility called cygpath
that can be used to convert between UNIX and Windows paths. Msysgit doesn’t have this utility, but if cygwin’s /bin
directory is in your Windows path, msysgit will pick it up and the scripts below will be usable for both cygwin and msysgit.
Here’s a GitEditor.sh
script that can be used as a wrapper around your editor:
#!/bin/sh
# Author: Gabriel Burca
#
# Script arguments:
# file-to-edit
FILE=`cygpath -w "${1}"`
"C:/Program Files/Vim/vim72/gvim.exe" "$FILE"
This
GitExtDiff.sh
script can be used as a wrapper around your diff tool:
#!/bin/sh
# Author: Gabriel Burca
#
# Script arguments:
# path old-file old-hex old-mode new-file new-hex new-mode
# The old-file path is typically "/tmp/.diff_something" and windows programs
# don't know how to get to "/tmp"
# We use cygpath to convert to something windows programs understand.
OLD_FILE=`cygpath -w "${2}"`
NEW_FILE=`cygpath -w "${5}"`
"C:/Program Files/WinMerge/WinMergeU.exe" -e -ub "$OLD_FILE" "$NEW_FILE"
Finally, you'll need to modify
~/.gitconfig
to use these scripts by adding something like this to it:
[diff]
external = "C:/Utility/GitExtDiff.sh"
[core]
editor = "C:/Utility/GitEditor.sh" |
[diff]
external = "C:/Utility/GitExtDiff.sh"
[core]
editor = "C:/Utility/GitEditor.sh"
At one point I had a need to extract various pieces of information from the f-spot photo.db
file (that’s where f-spot keeps all the information), so I wrote this script. Posting it here in case others find it useful. I called it
f-spot-list
#!/bin/bash
# Author: Gabriel Burca (gburca dash fspotlist at ebixio dot com)
# Version: 1.0
#
# Copyright (C) 2006-2009 Gabriel Burca (gburca dash fspotlist at ebixio dot com)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
set -o nounset
set -o errexit
function usage () {
cat << EOF
Extracts various pieces of information from an f-spot photo.db file.
Usage:
$0 <photo.db> <option>
Options:
-P | --Photo Pictures in the Photo directory
-k | --links DIR... All pictures in DIR that are not links
-a | --all All pictures in database
-h | --has TAG... Show pictures tagged with the tag
-t | --tags Show all available tags
<photo.db> is usually "~/.config/f-spot/photos.db"
Ex:
- Find all photos tagged "Favorites" or "Web":
$0 photos.db -h Favorites Web | sort | uniq | sed 's|^file://||' \
| xargs -I linkName readlink -e linkName
EOF
}
function PhotosInPhotoDir() {
sqlite3 "$PHOTO_DB" "select id, uri from photos where uri like '%Photos%';"
}
function HasTag() {
for TAG in $@ ; do
SQL="select base_uri || filename from photos \
inner join photo_tags on photos.id = photo_tags.photo_id \
inner join tags on photo_tags.tag_id = tags.id \
where tags.name like '$TAG';"
#echo $SQL
sqlite3 "$PHOTO_DB" "$SQL"
done
}
function ShowNonLinks() {
for DIR in $@ ; do
find "$DIR" -type f
done
}
function ShowTags() {
sqlite3 "$PHOTO_DB" "select name from tags order by name;"
}
function ShowAll() {
sqlite3 "$PHOTO_DB" "select * from photos;"
}
################################################################################
# main()
################################################################################
if [ $# -lt 2 ]; then
usage
exit 1
fi
IFS_orig=$IFS
IFS='
'
PHOTO_DB=$1
shift
if [ ! -e "$PHOTO_DB" ]; then
usage
exit 2
fi
case $1 in
-P | --Photo)
shift
PhotosInPhotoDir $@
;;
-k | --links)
shift
ShowNonLinks $@
;;
-t | --tags)
shift
ShowTags $@
;;
-h | --has)
shift
HasTag $@
;;
-a | --all)
shift
ShowAll $@
;;
*)
usage
exit 1
;;
esac
IFS=$IFS_orig
The vim installation that comes with msysgit is missing a number of syntax file dependencies. In addition to what is installed by default, C:\Program Files\Git\share\vim\vim72\syntax
should also contain diff.vim
and nosyntax.vim
. Without these vim will not display properly and will issue warnings that it’s unable to locate these files.
It looks like a fix has already been made (see this thread) but until it is released you can get these files directly from vim’s SVN repo: diff.vim and nosyntax.vim
Finally released a new version of VirtMus. Go get it from SourceForge if you’re interested. This version will handle PDF documents natively.
A lot of my music is scanned to PDF files, and before this release I had to save the individual PDF pages as images. Fortunately this is easy with the Professional version of Acrobat. It does however double the amount of disk space my music collection takes since I have to store both the original PDF and the raw images.
Both cygwin and the msysgit shell will use the same ~/.bashrc
file on start-up, but they mount the local Windows drives at different mount points. Cygwin uses /cygdrive/c
while msysgit uses simply /c
so if you’re using ~/.bashrc
to configure various settings that have to do with drive letters in your bash shell, you’ll need to distinguish between cygwin and msysgit.
The easiest way to do this is to look for the presence of /etc/bash.bashrc
in ~/.bashrc
, since this file is typically only present in cygwin. If by any chance it’s present in both cygwin and msysgit, a variable can be set in just one of them and ~/.bashrc
can be configured to source /etc/bash.bashrc
and test for the presence of that variable.
if [ -e /etc/bash.bashrc ] ; then
# Cygwin specific settings
export CYGWIN=1
# Msysgit's grep doesn't recognize --color
alias grep='grep --color'
alias vi='/cygdrive/c/Program\ Files/Vim/vim72/gvim.exe'
else
# Msysgit specific settings
export CYGWIN=0
alias vi='/c/Program\ Files/Vim/vim72/gvim.exe'
fi