wmanley/git-meld — Issue #10: running the script outside of git
Author: geoffhart
Created: 2012-01-30 23:59:40+00:00
State: open

I wouldn't call this an "issue", but for me it's handy to run the script directly, without changing the .gitconfig. Like:

.../git-meld.pl HEAD^^ -- $PWD

all that was needed was:

@@ -157,13 +158,15 @@ sub copy_files_named_tree($$$) {
# diff viewer
sub link_files_working_dir($$) {
(my $file_list, my $out_dir) = @_;
+ my $git_root = cwd();
+ $git_root =~ s!/[^/]+$!! while (! -d $git_root."/.git");
# Because we're diffing against the working directory we wish to create a
# tree of links in the dest folder mirroring that in the repo.
# TODO: Fix this so we don't have to loop over each filename somehow
foreach my $filename (@$file_list) {
my $dir = $filename;
safe_system("mkdir", "-p", dirname("$out_dir/$filename"));
- safe_system("ln", "-s", cwd() . "/$filename", "$out_dir/$filename");
+ safe_system("ln", "-s", $git_root . "/$filename", "$out_dir/$filename")
}
}

I'm not sure if that's the correct way to detect the git root, but you get the idea.

Also, something you might consider:

@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl

a little more flexible....

BTW - awesome script - exactly what I was looking for :)