-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Acquire last effected commit for a git object #2217
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
Conversation
Can you squash the two commits as one? |
Thanks for point out. but the PR not finished that I will rebase and squash after PR finished. |
@@ -12,6 +12,8 @@ | |||
#include "oid.h" | |||
#include "object.h" | |||
|
|||
#define VISITED (1 << 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this #define
be private and moved into the .c
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flags should go with the other ones in src/commit_list.h
, and it should not override the meaning of existing ones.
Hmm. I don't think this belongs in the To me, something like this feels like an addition to the Alternatively, something like this could conceptually be grouped with the I'm curious what @carlosmn thinks (and, of course, what @vmg thinks if he has an opinion). |
OK for the function
I think this is a good proposal. |
This feels like something that should be in snippets, rather than integrated directly into the library. It's a very specific wrapping of the revision walker. Why go inside the revwalk's guts instead of using it? |
That makes sense to me, although I think this feature is asked for frequently enough that making it super simple to walk to the last commit to modify a file would be a nice helper to add. I'm also wondering what we can do to make it easier to write code like this without feeling like we need to expose internal APIs. When we discussed the callback function for the revwalk, one idea was exposing the commit list node - I'm wondering if this is a use case for that so that you can more easily get the list of parents. Actually, I guess there is not much advantage to that because since you need to get the tree and the parent trees, you'll need to do the full lookups anyhow. There isn't much efficiency to be gained by exposing revwalk internals. As for labeling every blob in a tree with the latest commit to change it, it seems like that's mostly a bookkeeping exercise as you do a revwalk, yes? If you want, you can use |
It's a common request, but it doesn't represent the underlying work that would be done. Getting the last commit is a special case of filtering by path. We can add that to the revwalk as long as we make sure to advertise the limitation that it's not history simplification at all and the resulting history will be disconnected. If we're adding that, then we should should start by adding filtering for a single path, rather than something like As for the whole-tree one, that would be something like |
So, in summary,
right? It's OK for me. I'd like continue to complete it. |
Yeah, it should be in |
I've opened issue #3041 to keep track of the interface which would allow for use-cases such as this one in a way which doesn't assume knowledge of the internals. |
As discussed at #495 (Retrieve history for given file), libgit2/pygit2#231 (Show last commits for Tree or Blob) and libgit2/libgit2sharp#89 (Question: How to get the last commit that affected a given file), I'd like introduce two functions may named as
git_commit_entry_last_commit_id
andgit_commit_tree_last_commit_id
.git_commit_entry_last_commit_id
git_commit_tree_last_commit_id