Comments (9)
Thanks so much for reporting - I could reproduce the issue.
It boils down to the following: When detecting that a script should be executed, it applies a 'trick' to pass arguments. With that, it ends up invoking /bin/sh -c 'echo "$@" >&2 "$@"' -- store
even though it should invoke /bin/sh -c 'echo "$@" >&2' $@ -- store
.
Somehow, the $@
which is part of the 'trick' ends up as part of the script itself, not as a separate argument.
I'd expect to have a fix for that soon.
from gitoxide.
I have merged the PR and you could try it out for a spin on main
if you want.
The following should do the trick.
cargo build --bin gix --no-default-features --features max-pure
./target/debug/gix …
Your particular usecase is handled now, and if it's not working you can get more information using gix --trace -v …
.
Thanks for helping with validating the change 🙏.
from gitoxide.
Thanks for this gem!
When using GIT_TRACE=1
I see trace: run_command: 'echo "$@" "$@" >&2 store'
and 'echo "$@" "$@" >&2 && exit 1 store'
respectively. This explains why it prints a single store
- the script has no arguments, and all it does is to add store
to the end of the script itself.
gitoxide
now says this, which I believe is consistent and provides the expected results.
07:27:54 tracing DEBUG │ ┝━ gix_protocol::handshake() [ 524ms | 70.96% ] service: UploadPack | extra_parameters: []
07:27:54 tracing DEBUG │ │ ┝━ 🐛 [debug]: launching credential helper | cmd: "git" "credential-osxkeychain" "get"
07:27:54 tracing DEBUG │ │ ┝━ 🐛 [debug]: launching credential helper | cmd: "git" "credential-osxkeychain" "store"
07:27:54 tracing DEBUG │ │ ┝━ 🐛 [debug]: Will not add '$@' to '"echo \"$@\" \"$@\" >&2 && exit 1"' as it seems to contain it already
07:27:54 tracing DEBUG │ │ ┝━ 🐛 [debug]: launching credential helper | cmd: "/bin/sh" "-c" "echo \"$@\" \"$@\" >&2 && exit 1" "--" "store"
07:27:54 tracing DEBUG │ │ ┝━ 🐛 [debug]: Will not add '$@' to '"echo \"$@\" \"$@\" >&2 && exit 1"' as it seems to contain it already
07:27:54 tracing DEBUG │ │ ┕━ 🐛 [debug]: launching credential helper | cmd: "/bin/sh" "-c" "echo \"$@\" \"$@\" >&2 && exit 1" "--" "store"
It always runs the helper in a shell, which is why that usually works. I do not know where the $@
suggestion in pass-git-helper
is coming from though, as it should not be required at all even for Git.
From all I can tell, gitoxide
is consistent here as it uses the same engine for invoking commands as it always does, which should support typical Git use-cases, while being more open overall.
In any case, I think this concludes this interesting exploration into the depth of Git interactions with credential helper, and documentation some of these have :).
from gitoxide.
Actually, this seems to be cause by the "$@"
being expanded and get
being provided, if I remove the "$@"
(git config credential.helper '!echo >&2'
), both git
and gix
work the same way.
It is still desirable to match git
's behavior as pass-git-helper
suggests this.
The way git handles this is weird: !echo $@ $@
prints get
thrice in gix
, but only once in git
.
from gitoxide.
Without looking at the git credential's implementation. My guess is that git just adds a get
at the end of the command (i.e. echo $@ $@
-> echo $@ $@ get
) while gix
both adds a get
at the end and calls it with get
(i.e. echo $@ $@
-> sh -c 'echo $@ $@ get' -- get
). Which would explain the difference in behavior.
Another clue is !echo $@ >&2 exit 1
will print get
then fail with too many arguments for exit when using gix
and it prints nothing before failing the same way when using git
.
from gitoxide.
I have made a symptomatic fix in #1286 that you could try, even though I think that there is more going on here.
From what I can tell, running credential helpers works fine, and it's the doubling of arguments in this specific case has nothing to do with its correct functioning.
Thus, I don't know what else I can do as I don't actually understand the problem. Admittedly, I also don't understand how Git manages to not double the arguments given its code - maybe it doesn't run into this code at all which is also the reason that they suggest to add $@
in the end of the script even though that's not needed with the way gitoxide
is currently functioning.
After having written this, I do believe I understand the issue, which is to get credential helpers to work that use $@
like described in pass-git-helper, and I do think that's the case now.
from gitoxide.
I have made a symptomatic fix in #1286 that you could try, even though I think that there is more going on here.
From what I can tell, running credential helpers works fine, and it's the doubling of arguments in this specific case has nothing to do with its correct functioning.Thus, I don't know what else I can do as I don't actually understand the problem. Admittedly, I also don't understand how Git manages to not double the arguments given its code - maybe it doesn't run into this code at all which is also the reason that they suggest to add
$@
in the end of the script even though that's not needed with the waygitoxide
is currently functioning.After having written this, I do believe I understand the issue, which is to get credential helpers to work that use
$@
like described in pass-git-helper, and I do think that's the case now.
I feel like git has legacy behavior which the helpers work around by using $@. I'll take a look at the code and see what I can figure out.
from gitoxide.
So this fixes the common case credential.helper '!pass-git-helper "$@"'
, which is all I (and hopefully everyone) will need, but it still has differences with git
:
$ git config credential.helper '!echo "$@" "$@" >&2'
$ gix-v0.33.0 fetch
get get get
...
^C
$ gix-main fetch
get get
...
^C
$ git fetch
get
...
^C
Why git does that? I can't tell. As far as I understand from the linked git code it should behave like gix-v0.33.0
and print get get get
.
Do you have an issue to track known differences to git
? This feels like it should not impact anyone, but it should be documented somewhere.
from gitoxide.
Another example of gix-main
and git
handling things differently:
$ git config credential.helper '!echo "$@" "$@" >&2 && exit 1'
$ gix-v0.33.0 fetch
get get
--: line 1: exit: too many arguments
Cannot run askpass program: "" with error: No such file or directory (os error 2)
$ gix-main fetch
get get
Cannot run askpass program: "" with error: No such file or directory (os error 2)
$ git fetch
echo "$@" "$@" >&2 && exit 1 get: line 1: exit: too many arguments
Password for 'https://[email protected]':
This suggests that the commands are:
gix-v0.33.0
:sh -c 'echo "$@" "$@" >&2 && exit 1 get' -- get
.gix-main
:sh -c 'echo "$@" "$@" >&2 && exit 1' -- get
git
:sh -c 'echo "$@" "$@" >&2 && exit 1 get'
I feel like gix-main
does the right thing and git
has a bug.
from gitoxide.
Related Issues (20)
- `gix clean -xde` deletes the repo's own hidden nested worktrees, but they are not really hidden HOT 5
- The 32-bit Windows releases are 64-bit HOT 6
- Unclear intent regarding optimizations for some profiles HOT 5
- Prebuilt binaries obtained on ARM64 macOS are x86-64 HOT 5
- OSS-Fuzz issue 70841 HOT 1
- OSS-Fuzz issue 70863 HOT 1
- Release workflow relies on deprecated `set-output` feature
- OSS-Fuzz issue 70876 HOT 1
- `from_path_no_follow` test runs `touch` with nonportable date format HOT 3
- Panic when parsing `HEAD:README` in a repo with invalid HEAD. HOT 2
- gitx-credentials fails to build HOT 4
- copy detection differs from git weirdly HOT 12
- progress.rs misleadingly claims "we target 32bit systems only" HOT 6
- CVE-2024-43785: gitoxide-core does not neutralize special characters for terminals HOT 10
- gix-object v0.44.0 fail to compile HOT 2
- gitoxide is still less lenient than git when parsing signatures, in particular in tags
- gix clone fails on https://git.zx2c4.com/sha256-oid-test HOT 1
- Oxidize `git-cliff` HOT 2
- Unable to fetch with only extra_refspecs HOT 1
- Add a `tokio` feature HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gitoxide.