From: "Shawn O. Pearce" <spearce@spearce.org>
To: Farrukh Najmi <farrukh@wellfleetsoftware.com>
Cc: git@vger.kernel.org
Subject: Re: Why is TreeWalk.forPath(...) returning null
Date: Wed, 12 Nov 2008 14:42:36 -0800 [thread overview]
Message-ID: <20081112224236.GX2932@spearce.org> (raw)
In-Reply-To: <491B579E.6050408@wellfleetsoftware.com>
Farrukh Najmi <farrukh@wellfleetsoftware.com> wrote:
>
> My "git status" command shows:
>
> # On branch master
> # Changed but not updated:
> # (use "git add <file>..." to update what will be committed)
> #
> # modified: xml/minDB/SubmitObjectsRequest_CMSScheme.xml
>
> The file above was committed and then modified. I want to use jgit to
> find the comitted version of that file.
>
> When I do the following code I get a null treeWalk? Why is that? What
> should I specify for path instead?
>
> String path = "xml/minDB/SubmitObjectsRequest_CMSScheme.xml";
> String versionName = Constants.HEAD;
>
> Commit commit = repository.mapCommit(versionName);
>
> if (commit == null) {
> log.trace("Did not find Commit. versionName:" +
> versionName);
> } else {
> ObjectId[] ids = {commit.getTree().getId()};
> TreeWalk treeWalk = TreeWalk.forPath(repository, path, ids);
> }
Huh. That should have worked.
TreeWalk.forPath returns null if the path doesn't get found. So
it sounds like jgit isn't matching the path. Its a pretty simple
operation, I'm not sure why its failing here. I'd run it through
a debugger to try and see why the TreeWalk didn't match your path.
Your code is logically the same as:
git rev-parse HEAD:$path
so it should find the blob if Git would have found it.
--
Shawn.
next prev parent reply other threads:[~2008-11-12 22:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-12 22:24 Why is TreeWalk.forPath(...) returning null Farrukh Najmi
2008-11-12 22:42 ` Shawn O. Pearce [this message]
2008-11-12 22:52 ` Farrukh Najmi
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=20081112224236.GX2932@spearce.org \
--to=spearce@spearce.org \
--cc=farrukh@wellfleetsoftware.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.