From: Tim Henigan <tim.henigan@gmail.com>
To: gitster@pobox.com, davvid@gmail.com, git@vger.kernel.org
Cc: Tim Henigan <tim.henigan@gmail.com>
Subject: Re: [PATCH 7/9] difftool: teach difftool to handle directory diffs
Date: Tue, 20 Mar 2012 13:43:52 -0400 [thread overview]
Message-ID: <CAFouetiSyTFAR=CJBuYEcpUDq=f2jVaOMnsThgEP-zSbTH1H_g@mail.gmail.com> (raw)
In-Reply-To: <1331949574-15192-1-git-send-email-tim.henigan@gmail.com>
I have run into a problem with the way that the tmp directories are
populated using 'git update-index' and 'git checkout-index'. I would
appreciate any feedback that may help me understand what I am doing
wrong.
This is in regard to the following section of code:
On Fri, Mar 16, 2012 at 9:59 PM, Tim Henigan <tim.henigan@gmail.com> wrote:
>
> +sub setup_dir_diff
> +{
> + # Run the diff; exit immediately if no diff found
> + my $repo = Git->repository();
> + my $diffrtn = $repo->command_oneline(['diff', '--raw', '--no-abbrev', '-z', @ARGV]);
> + exit(0) if (length($diffrtn) == 0);
<snip>
> + my @rawdiff = split('\0', $diffrtn);
> +
> + for (my $i=0; $i<@rawdiff; $i+=2) {
> + my ($lmode, $rmode, $lsha1, $rsha1, $status) = split(' ', substr($rawdiff[$i], 1));
> + my $path = $rawdiff[$i + 1];
> +
> + if (($lmode eq $submodule_mode) or ($rmode eq $submodule_mode)) {
> + $submodule{$path}{left} = $lsha1;
> + $submodule{$path}{right} = $rsha1;
> + next;
> + }
> +
> + if ($lmode ne $null_mode) {
> + $lindex .= "$lmode $lsha1\t$path\0";
> + }
> +
> + if ($rmode ne $null_mode) {
> + if ($rsha1 ne $null_sha1) {
> + $rindex .= "$rmode $rsha1\t$path\0";
> + } else {
> + push(@working_tree, $path);
> + }
> + }
> + }
> +
> + # Populate the left and right directories based on each index file
> + my ($inpipe, $ctx);
> + $ENV{GIT_INDEX_FILE} = "$tmpdir/lindex";
> + ($inpipe, $ctx) = $repo->command_input_pipe(qw/update-index -z --index-info/);
> + print($inpipe $lindex);
> + $repo->command_close_pipe($inpipe, $ctx);
> + $repo->command_oneline(["checkout-index", "-a", "--prefix=$ldir/"]);
When run from the root directory of a Git repository, the 'difftool
--dir-diff' command operates as expected:
- Temporary index files for each side of the diff are created using
'git update-index'.
- 'git checkout-index --all --prefix=$tmp' is used to populate the
tmp directory based on the index file.
However, when 'difftool --dir-diff' is run from a subdirectory of the
Git repository, there are problems.
- The temporary index file generated by 'git update-index' appears
to be correct.
- 'git checkout-index --all --prefix=$tmp' command does not work
(output tmp dir is empty).
I have tried some combinations of setting $ENV{GIT_DIR} and
$ENV{GIT_WORK_TREE}, but it has not fixed the problem. Is there
anything obvious that I missed?
next prev parent reply other threads:[~2012-03-20 17:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-17 1:59 [PATCH 7/9] difftool: teach difftool to handle directory diffs Tim Henigan
2012-03-17 3:08 ` David Aguilar
2012-03-17 14:18 ` Tim Henigan
2012-03-17 14:32 ` Jakub Narebski
2012-03-18 0:58 ` Tim Henigan
2012-03-20 17:43 ` Tim Henigan [this message]
2012-03-20 18:35 ` Junio C Hamano
2012-03-20 20:17 ` Tim Henigan
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='CAFouetiSyTFAR=CJBuYEcpUDq=f2jVaOMnsThgEP-zSbTH1H_g@mail.gmail.com' \
--to=tim.henigan@gmail.com \
--cc=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).