OVYA Git Bash Scritps  0.1.0
Useful git scritps and OVYA git workflow related scripts
Useful functions

Functions

 oglGetBranch ()
 Return the current branch or detached ref. More...
 
 oglGetDir ()
 Return the location of .git repo. More...
 
 oglGetDivergenceStatus (string, string)
 Return the branches divergence status. More...
 
 oglGetRemoteBranches (string)
 Return the remote branches if any, empty if no remote branches found. More...
 
 oglGetStatus (string)
 Return the git work tree status as concatenation by commas of the variables HAS_UNCOMMITTED_CHANGE and HAS_UNSTAGED_FILE. If the work tree is clean the output is the value of the variable IS_CLEAN. If the work tree is empty the output is comma separated of the variables IS_CLEAN and IS_EMPTY. More...
 
 oglGetUpstreamBranch (string)
 Return current upstream branch if any, empty if no upstream configured for the branch. More...
 
 oglHasRemoteBranch (string)
 Tests if the branch has a remote branch. More...
 
 oglHasUncommittedChange (string)
 Test if the work tree has uncommitted change(s). More...
 
 oglHasUnstagedFile (string)
 Test if the work tree has unstaged file(s). More...
 
 oglHasUpstreamBranch (string)
 Tests if the upstream branch is configured. More...
 
 oglIsBranchExists (string)
 Test if the branch exists. More...
 
 oglIsBranchNeedUpdate (string, string)
 Test if a branch need to be update regarding the upstream branch or the given branch. The branch "need to be update" when the branch is behind, has diverged. More...
 
 oglIsBranchUpToDate (string, string)
 Test if a branch is up-to-date regarding the upstream branch or the given branch. The branch "is up-to-date" when the branch is equal to the given tracking brach or if there is no tracking branch. More...
 
 oglIsClean (string)
 Test if the work tree is clean. Note that an empty work tree is considered clean. More...
 
 oglSwitchToBranch (string)
 Switch to the given branch if it's not the current branch. More...
 
 oglIsValidRef ()
 Test if the given reference is valid in the local repository. The reference can be a commit hash, HEAD,u}, a branch name, a tag, etc. More...
 

Detailed Description

Function Documentation

◆ oglGetBranch()

oglGetBranch ( )

Return the current branch or detached ref.

Note
Come from git-prompt.sh
Return values
stringechoed.

◆ oglGetDir()

oglGetDir ( )

Return the location of .git repo.

Note
Come from git-prompt.sh
Return values
stringechoed.

◆ oglGetDivergenceStatus()

oglGetDivergenceStatus ( string  ,
string   
)

Return the branches divergence status.

Parameters
stringThe branch A to operate on. If not set, use the current branch.
stringThe branch B to operate on. If not set : ⋅ use the upstream branch tracked by A is configured ; ⋅ else use the remote branch of origin/A if exists ; ⋅ else return the value of $IS_NOT_TRACKING.
Return values
stringOne of the value of the global variable IS_EQUAL, IS_AHEAD, IS_BEHIND, HAS_DIVERGED, INVALID_LOCAL_REF, IS_NOT_TRACKING, IS_NOT_APPLICABLE.

◆ oglGetRemoteBranches()

oglGetRemoteBranches ( string  )

Return the remote branches if any, empty if no remote branches found.

Parameters
stringBranch to operate on. Current branch if not set.
Return values
0if remote branch found.
1if remote branch not found.
Returns
string

◆ oglGetStatus()

oglGetStatus ( string  )

Return the git work tree status as concatenation by commas of the variables HAS_UNCOMMITTED_CHANGE and HAS_UNSTAGED_FILE. If the work tree is clean the output is the value of the variable IS_CLEAN. If the work tree is empty the output is comma separated of the variables IS_CLEAN and IS_EMPTY.

Parameters
stringThe optional branch to operate on (current branch if not set).
Return values
0if the status can be found
1if the status can not be found (branch does not exist, …)
Returns
string Echoed value. See brief.

◆ oglGetUpstreamBranch()

oglGetUpstreamBranch ( string  )

Return current upstream branch if any, empty if no upstream configured for the branch.

Parameters
stringBranch to operate on. Current branch if not set.
Return values
0if upstream branch is configured
1if upstream branch is NOT configured
Returns
string

◆ oglHasRemoteBranch()

oglHasRemoteBranch ( string  )

Tests if the branch has a remote branch.

Parameters
stringBranch to operate on. Current branch if not set.
Return values
0if upstream branch is configured
1if upstream branch is NOT configured

◆ oglHasUncommittedChange()

oglHasUncommittedChange ( string  )

Test if the work tree has uncommitted change(s).

Parameters
stringThe optional branch to operate on (current branch if not set).
Return values
0if has uncommitted file(s)
1if not

◆ oglHasUnstagedFile()

oglHasUnstagedFile ( string  )

Test if the work tree has unstaged file(s).

Parameters
stringThe optional branch to operate on (current branch if not set).
Return values
0if has unstaged file(s)
1if not

◆ oglHasUpstreamBranch()

oglHasUpstreamBranch ( string  )

Tests if the upstream branch is configured.

Parameters
stringBranch to operate on. Current branch if not set.
Return values
0if upstream branch is configured
1if upstream branch is NOT configured

◆ oglIsBranchExists()

oglIsBranchExists ( string  )

Test if the branch exists.

Parameters
stringBranch to operate on.
Return values
0if the branch exists
1if the branch does not exist

◆ oglIsBranchNeedUpdate()

oglIsBranchNeedUpdate ( string  ,
string   
)

Test if a branch need to be update regarding the upstream branch or the given branch. The branch "need to be update" when the branch is behind, has diverged.

Parameters
stringThe branch to operate on. If not set the current.
stringThe branch to operate on. If not set the upstream branch.
Return values
0if need update
1if NOT need update

◆ oglIsBranchUpToDate()

oglIsBranchUpToDate ( string  ,
string   
)

Test if a branch is up-to-date regarding the upstream branch or the given branch. The branch "is up-to-date" when the branch is equal to the given tracking brach or if there is no tracking branch.

Parameters
stringThe branch to operate on. If not set the current.
stringThe branch to operate on. If not set the upstream branch.
Return values
0if up-to-date
1if NOT up-to-date

◆ oglIsClean()

oglIsClean ( string  )

Test if the work tree is clean. Note that an empty work tree is considered clean.

Parameters
stringThe optional branch to operate on (current branch if not set).
Return values
0if clean
1if not clean

◆ oglIsValidRef()

oglIsValidRef ( )

Test if the given reference is valid in the local repository. The reference can be a commit hash, HEAD,u}, a branch name, a tag, etc.

Parameters
stringThe ref to test.
Return values
0if the ref exists
1if the ref does not exist

◆ oglSwitchToBranch()

oglSwitchToBranch ( string  )

Switch to the given branch if it's not the current branch.

Parameters
stringThe branch to go.
Return values
0if the switch is done
1if the switch is failed