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

Consider GIT_AUTHOR_EMAIL/GIT_COMMITTER_EMAIL as current author/committer #72

Open
blueyed opened this issue Nov 29, 2022 · 10 comments
Open
Assignees
Labels
upstream Blocked on upstream libgit2/git2rs

Comments

@blueyed
Copy link

blueyed commented Nov 29, 2022

When using $GIT_AUTHOR_EMAIL and $GIT_COMMITTER_EMAIL with something else than git config user.email, it will display a warning:

WARN Will not fix up past commits not authored by you, use --force to override, commit: …

I think that it should consider the env settings as the current owner - not sure if alone or additionally.

(FWIW, I am using the env variables to use different emails per projects.

It is easy enough to configure user.email there additionally, but that might require to do it with many sub-directories / projects for a company stored in a common ancestor dir, where setting the env can be done for all sub-directories more easily)

@tummychow
Copy link
Owner

would prefer to wait for upstream (libgit2/libgit2#3751) rather than hacking this in myself. i only accepted #22 because upstream explicitly declined to support it.

@tummychow tummychow added the upstream Blocked on upstream libgit2/git2rs label Apr 6, 2023
@petski
Copy link

petski commented Jul 18, 2024

FWIW, libgit2/libgit2#3751 is closed. The feature seems to be implemented.

@tummychow
Copy link
Owner

ah, that's good to know. ping this issue again when it's available in a git2-rs release and i'll bump for it

@petski
Copy link

petski commented Feb 10, 2025

@tummychow tummychow self-assigned this Feb 11, 2025
@tummychow
Copy link
Owner

oh how convenient, someone already did this lol #138

@petski
Copy link

petski commented Feb 17, 2025

@tummychow It's already bumped indeed, but the requested feature is not working yet:

I get a Will not fix up past commits not authored by you, use --force to override, even though GIT_COMMITTER_NAME,
GIT_COMMITTER_EMAIL, GIT_AUTHOR_EMAIL and GIT_AUTHOR_NAME are set the same for the commit I want to fix up.

Please re-open this issue.

@blairconrad
Copy link
Contributor

@petski, you're using git-absorb 0.6.17 or a personally-built version that includes commit 52547c2?
Can you zip up a small repo that shows the problem?

@petski
Copy link

petski commented Feb 17, 2025

To reproduce:

$ git absorb --version
git-absorb 0.6.17
$ cd $(mktemp -d)
$ git init
$ echo "foo" > test
$ git add ./test
$ git commit --author="A <a@a.local>" --message=test
$ echo "bar" > test
$ git add ./test
$ export GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="a@a.local" 
$ git absorb -r
Feb 17 14:07:54.925 WARN Will not fix up past commits not authored by you, use --force to override, commit: f53766668de190f42cdc3f128bcb2497680660fb
Feb 17 14:07:54.925 CRIT No commits available to fix up, exiting

@blairconrad
Copy link
Contributor

blairconrad commented Feb 17, 2025

I don't think git2 is doing what we think it's doing.

I added some debug logging to indicate the sig's name and it doesn't respect the GIT_AUTHOR_NAME environment variable:

λ  cargo run -- --verbose
     Running `C:\Dev\git-absorb\target\debug\git-absorb.exe --verbose`
Feb 17 18:53:34.741 DEBG repository found, path: C:/Dev/git-absorb/t/.git/, line: 25, module: git_absorb
Feb 17 18:53:34.745 DEBG head found, head: refs/heads/master, line: 15, module: git_absorb::stack
Feb 17 18:53:34.749 DEBG head pushed, head: refs/heads/master, line: 32, module: git_absorb::stack
Feb 17 18:53:34.753 DEBG branch not hidden, branch: refs/heads/master, line: 56, module: git_absorb::stack
Feb 17 18:53:34.758 DEBG Signature is, signature: Some("Blair Conrad"), line: 67, module: git_absorb::stack
Feb 17 18:53:34.761 WARN Will not fix up past commits not authored by you, use --force-author to override, commit: 3a6531973a726ad6eaa0d9bde95bbf78008c4486, line: 81, module: git_absorb::stack
Feb 17 18:53:34.767 CRIT No commits available to fix up, exiting, line: 42, module: git_absorb

λ  echo $env:GIT_AUTHOR_NAME
A

This is built on 7d1afd2 (master as I type).

Update! git2 is still calling git_signature_default to get the signature, as I read it, not git_signature_default_from_env, which was added to read the environment variables. git_signature_default_from_env doesn't appear in the source of git2-rs, so this may still qualify as an "upstream" problem, at least to expose the functionality required by this issue.

@tummychow
Copy link
Owner

darn, thank you both for checking rust-lang/git2-rs#1126

@tummychow tummychow reopened this Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Blocked on upstream libgit2/git2rs
Projects
None yet
Development

No branches or pull requests

4 participants