Reputation: 3
I working on Git now and having a big problem.
The command git bisect run
needs to be like that:
$ git bisect run <my_script> $arguments
But I need to work with git bisect run
only in one script.
I know that my solution with 2 scripts works but I can't find a way to combine them.
What can I do that will resolve the problem?
I tried to use:
git bisect run sh -c
As example: In working on git and writing: bash ../bisecter.sh 102
. When bisecter.sh
is the name of the script and 102
is something we need to search in the commits. And this script I'm trying to write. With bisect
and bash commands.
Upvotes: -1
Views: 609
Reputation: 164699
You could check to see if the program is being run in "interactive mode" and run the appropriate command. If it's interactive, run git bisect
. If it isn't, you're being run by git bisect
.
An interactive shell is one started without non-option arguments (unless -s is specified) and without the -c option whose standard input and error are both con- nected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.
In bash you can check if file descriptor 1 (stdout) is outputting to a terminal.
if [ -t 1 ]; then
echo "We're run from a shell, run git-bisect"
else
echo "We're not run from a shell, do the bisecting."
fi
$ ./test.sh
We're run from a shell, run git-bisect
$ ./test.sh | cat
We're not run from a shell, do the bisecting.
But I seriously doubt that's what your professor intends you to do. The requirement to pass the same program to git bisect
as runs git bisect
doesn't make sense. Either the professor has an odd requirement, a distinct possibility, or perhaps you've misunderstood how to solve the problem.
When bisecter.sh is the name of the script and 102 is something we need to search in the commits.
git bisect
is not for searching like that. It is for finding which commit caused a bug.
If you want to find which commit made a particular change, either in the log messages or in the changes, use git log -S
or git log -G
. That makes sense to do it in a single file.
Upvotes: 1