All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Jason Sewall <jasonsewall@gmail.com>
Cc: Brian Downing <bdowning@lavos.net>,
	Julian Phillips <julian@quantumfyre.co.uk>,
	git@vger.kernel.org
Subject: Re: [PATCH] git-gui: Handle git versions of the form n.n.n.GIT
Date: Tue, 17 Jul 2007 21:48:06 -0400	[thread overview]
Message-ID: <20070718014806.GQ32566@spearce.org> (raw)
In-Reply-To: <31e9dd080707171449r26c430f1vacfb58eb00f578e5@mail.gmail.com>

Jason Sewall <jasonsewall@gmail.com> wrote:
> On 7/17/07, Brian Downing <bdowning@lavos.net> wrote:
> >I take it this means that keeping your home directory under git
> >/directly/ as I have chosen to do is a bad idea...
> 
> Interesting, because this is something I've wanted to do - I use
> several machines (work, work laptop, home, home laptop) and I'm always
> tweaking my various dotfiles... I could really use a way to keep them
> all synchronized.
> 
> Just out of curiosity, what do you people do?

I have a regular git directory in ~/cgwork/HomeDir, with its
associated .git directory in ~/cgwork/HomeDir/.git.  In other
words standard Git repository setup in a location that isn't my
actual home directory.

My dotfiles in ~/ are actually symlinks back to that Git repository.
To update the symlinks I run the script below.  Its pretty simple,
it just merges to directories from the Git repository into my ~/
as dotfiles (the dot-* items) and into my ~/bin (the bin/* items).
So my Git repository looks like this:

  $ git ls-tree --abbrev=4 HEAD
  040000 tree 0d35        common
  040000 tree e033        host-asimov
  040000 tree 21c4        host-spearce-pb15.local
  100755 blob 0f2d        relink.sh

  $ git ls-tree --abbrev=4 HEAD:common/
  040000 tree cc76        bin
  100644 blob 371e        dot-bash_profile
  100644 blob e675        dot-bashrc
  100644 blob 1f0a        dot-gitconfig
  100644 blob 3d02        dot-ldaprc
  100644 blob 1d42        dot-vilerc

  $ git ls-tree --abbrev=4 HEAD:common/bin/
  100755 blob 7322        cherry-kill
  100755 blob 9ed5        fp
  100755 blob 89f2        genbibtex
  100755 blob 68be        newrepo
  100755 blob 3759        tkbibtex

  $ ls -l ~/.bashrc ~/bin/fp
  lrwxr-xr-x   1 spearce  spearce  41 Feb  3 23:05 /Users/spearce/.bashrc -> cgwork/HomeDir-DotFiles/common/dot-bashrc
  lrwxr-xr-x   1 spearce  spearce  40 Feb  3 23:05 /Users/spearce/bin/fp -> ../cgwork/HomeDir-DotFiles/common/bin/fp

Yea, it relies on the fact that I never use `git config --global`,
which apparently I've done recently as the damn thing isn't a symlink
like its supposed to be.  Uggh.  Its the *only* program on my system
that doesn't resolve the symlink and edit the file it points at.

-->--
#!/bin/sh

root=`dirname "$0"`
[ -d "$root" ] || {
	echo "error: Can't locate $0 in filesystem." >&2
	exit 1
}

cd "$root"
root=$(pwd)
root=$(echo "$root" | sed s:^$HOME/::)

if [ "X$HOSTTYPE" = Xpowerpc ]
then
	HOSTNAME=spearce-pb15.local
fi

dot_sources="common/dot-* host-$HOSTNAME/dot-*"
bin_sources="common/bin/* host-$HOSTNAME/bin/*"

echo "Linking from $dot_sources"
for src in $dot_sources
do
	if [ -e "$src" ]
	then
		dot_file=$(basename "$src" | sed s/^dot-/./)

		targ="$root/$src"
		dest="$HOME/$dot_file"

		if [ -L "$dest" ]
		then
			echo " U $dest -> $targ"
			rm -f "$dest"
			ln -s "$targ" "$dest"
			continue
		fi

		if [ ! -e "$dest" ]
		then
			echo " N $dest -> $targ"
			ln -s "$targ" "$dest"
			continue
		fi

		if [ -e "$dest" -a ! -e "$dest.bak" ]
		then
			echo " O $dest -> $targ"
			mv "$dest" "$dest.bak"
			ln -s "$targ" "$dest"
			continue
		fi

		echo " ! $dest -> $targ"
	fi
done
echo "done."

echo
echo "Linking from $bin_sources"
for src in $bin_sources
do
	if [ -e "$src" ]
	then
		bin_file=$(basename "$src")

		case "$root" in
		/*) targ="$root/$src";;
		*)  targ="../$root/$src"
		esac
		dest="$HOME/bin/$bin_file"

		mkdir -p "$HOME/bin"

		if [ -L "$dest" ]
		then
			echo " U $dest -> $targ"
			rm -f "$dest"
			ln -s "$targ" "$dest"
			continue
		fi

		if [ ! -e "$dest" ]
		then
			echo " N $dest -> $targ"
			ln -s "$targ" "$dest"
			continue
		fi

		if [ -e "$dest" -a ! -e "$dest.bak" ]
		then
			echo " O $dest -> $targ"
			mv "$dest" "$dest.bak"
			chmod a-x "$dest.bak"
			ln -s "$targ" "$dest"
			continue
		fi

		echo " ! $dest -> $targ"
	fi
done
echo "done."
-->--

-- 
Shawn.

  reply	other threads:[~2007-07-18  1:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-17 11:48 Problem running git-gui Julian Phillips
2007-07-17 12:04 ` Thomas Glanzmann
2007-07-17 21:14 ` [PATCH] git-gui: Handle git versions of the form n.n.n.GIT Julian Phillips
2007-07-17 21:40   ` Brian Downing
2007-07-17 21:45     ` Brian Downing
2007-07-17 21:49       ` Jason Sewall
2007-07-18  1:48         ` Shawn O. Pearce [this message]
2007-07-17 22:34       ` Linus Torvalds
2007-07-18  1:52     ` Shawn O. Pearce
2007-07-18  1:51   ` Shawn O. Pearce
2007-07-18  2:32     ` Martin Langhoff
2007-07-18  2:54       ` Shawn O. Pearce
2007-07-18 10:10         ` Julian Phillips

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070718014806.GQ32566@spearce.org \
    --to=spearce@spearce.org \
    --cc=bdowning@lavos.net \
    --cc=git@vger.kernel.org \
    --cc=jasonsewall@gmail.com \
    --cc=julian@quantumfyre.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.