git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 18, 2007, 01:48 UTC
Message-ID
<20070718014806.GQ32566@spearce.org>
In-Reply-To
<31e9dd080707171449r26c430f1vacfb58eb00f578e5@mail.gmail.com>
Jason Sewall <jasonsewall@gmail.com> wrote:
Show 10 quoted lines
> 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.
Previous: Jason SewallNext: Linus Torvalds
Message 7 of 13 in “Problem running git-gui”
  1. Julian PhillipsJul 17, 2007
  2. Thomas GlanzmannJul 17, 2007
  3. git-gui: Handle git versions of the form n.n.n.GITJulian Phillips, Jul 17, 2007
  4. Brian DowningJul 17, 2007
  5. Brian DowningJul 17, 2007
  6. Jason SewallJul 17, 2007
  7. Shawn O. PearceJul 18, 2007
  8. Linus TorvaldsJul 17, 2007
  9. Shawn O. PearceJul 18, 2007
  10. Shawn O. PearceJul 18, 2007
  11. Martin LanghoffJul 18, 2007
  12. Shawn O. PearceJul 18, 2007
  13. Julian PhillipsJul 18, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.