Re: [PATCH] git-gui: Handle git versions of the form n.n.n.GIT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Sewall <jasonsewall@xxxxxxxxx> wrote:
> On 7/17/07, Brian Downing <bdowning@xxxxxxxxx> 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.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux