0

i need to run below command in gitbash

$ loc_count="$(cloc-1.92.exe --git --diff ${start_commit} ${end_commit})"

but i am getting this error

tar: Cannot connect to C: resolve failed

fatal: Not a valid object name C

how resolve this?

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Can you show us the contents of `$start_commit` and `$end_commit`? Does this command work without the `$(...)` syntax, just run directly? – joanis Feb 19 '22 at 18:38
  • branch=master start_date=2021-01-20 end_date=2021-02-20 start_commit="$(git rev-list -n1 --before=${start_date} ${branch})" end_commit="$(git rev-list -n1 --before=${end_date} ${branch})" echo "Start commit for ${start_date} is ${start_commit} echo "End commit for ${end_date} is ${end_commit} Using this, you can plug $start_commit and $end_commit into your cloc command: loc_count="$(cloc --git --diff ${start_commit} ${end_commit})" echo "$loc_count" – Anusha G Feb 20 '22 at 09:24
  • @joanis in gitbash we can't run any command without $ – Anusha G Feb 20 '22 at 09:50
  • I meant can you run `cloc-1.92.exe --git --diff ${start_commit} ${end_commit}` by itself and let the output go to terminal. – joanis Feb 20 '22 at 14:10
  • Thanks for showing more of your code. It would be a lot easier to read if you edited it right into the question, though. I stand by my original comment, though: for troubleshooting, strip away the script and run `cloc.1.92.exe --git --diff HEAD ` and tell us if that works. No, you don't need to type `$` to run a command in GitBash. `$(...)` is for capturing the output of a command into a variable, but unecessary to run a command. – joanis Feb 20 '22 at 14:21
  • yes its working in command prompt and i got the output thank you so much – Anusha G Feb 21 '22 at 05:26
  • Good, that's one helpful step. Now I'm not sure if you still have a problem. If something still doesn't work, please edit the question to make it clear what's not working and compare the output of the command on its own vs the script, or if your problem is now solved,please confirm that too. – joanis Feb 21 '22 at 14:04

0 Answers0