Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running the script outside of git #10

Open
geoffhart opened this issue Jan 30, 2012 · 1 comment
Open

running the script outside of git #10

geoffhart opened this issue Jan 30, 2012 · 1 comment

Comments

@geoffhart
Copy link

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 :)

@wmanley
Copy link
Owner

wmanley commented Jan 2, 2013

This would be a useful feature but it would probably be better to use git rev-parse --show-toplevel to get the working directory rather than trying to reimplement the logic that git uses. It would also be good to have a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants