Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitflow
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tools
gitflow
Commits
a0fe939a
Commit
a0fe939a
authored
Jan 29, 2010
by
Vincent Driessen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/merge-conflict-support' into develop
parents
17a8112b
f6f152ff
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
4 deletions
+95
-4
git-flow
git-flow
+27
-2
git-flow-feature
git-flow-feature
+68
-2
No files found.
git-flow
View file @
a0fe939a
...
...
@@ -18,6 +18,7 @@ if [ "$DEBUG" = "yes" ]; then
set
-x
fi
export
GIT_DIR
=
$(
git rev-parse
--git-dir
)
export
GITFLOW_DIR
=
$(
dirname
"
$0
"
)
export
MASTER_BRANCH
=
$(
git config
--get
gitflow.branch.master
||
echo
master
)
export
DEVELOP_BRANCH
=
$(
git config
--get
gitflow.branch.develop
||
echo
develop
)
...
...
@@ -83,11 +84,23 @@ main() {
cmd_
$SUBACTION
"
$@
"
}
gitflow_
require
_clean_working_tree
()
{
gitflow_
test
_clean_working_tree
()
{
if
!
git diff
--no-ext-diff
--ignore-submodules
--quiet
--exit-code
;
then
return
1
elif
!
git diff-index
--cached
--quiet
--ignore-submodules
HEAD
--
;
then
return
2
else
return
0
fi
}
gitflow_require_clean_working_tree
()
{
gitflow_test_clean_working_tree
result
=
$?
if
[
$result
-eq
1
]
;
then
die
"Working tree contains unstaged changes. Aborting ..."
fi
if
!
git diff-index
--cached
--quiet
--ignore-submodules
HEAD
--
;
then
if
[
$result
-eq
2
]
;
then
die
"Index contains uncommited changes. Aborting ..."
fi
}
...
...
@@ -162,4 +175,16 @@ gitflow_require_branches_equal() {
fi
}
#
# gitflow_is_branch_merged_into()
#
# Checks whether branch $1 is succesfully merged into $2
#
gitflow_is_branch_merged_into
()
{
local
SUBJECT
=
$1
local
BASE
=
$2
ALL_MERGES
=
$(
git branch
--contains
$SUBJECT
|
sed
's/^[* ] //'
)
has
$BASE
$ALL_MERGES
}
main
"
$@
"
git-flow-feature
View file @
a0fe939a
...
...
@@ -102,9 +102,51 @@ cmd_finish() {
parse_args "$@"
# sanity checks
gitflow_require_clean_working_tree
gitflow_require_branch $BRANCH
# detect if we're restoring from a merge conflict
if [ -f "$GIT_DIR/.gitflow/MERGE_BASE" ]; then
#
# TODO: detect that we're working on the correct branch here!
# The user need not necessarily have given the same $NAME twice here
# (although he/she should).
#
# TODO: gitflow_test_clean_working_tree() should provide an alternative
# exit code for "unmerged changes in working tree", which we should
# actually be testing for here
if gitflow_test_clean_working_tree; then
FINISH_BASE="$(cat "$GIT_DIR/.gitflow/MERGE_BASE")"
# Since the working tree is now clean, either the user did a
# succesfull merge manually, or the merge was cancelled.
# We detect this using gitflow_is_branch_merged_into()
if gitflow_is_branch_merged_into $BRANCH $FINISH_BASE; then
rm -f "$GIT_DIR/.gitflow/MERGE_BASE"
helper_finish_cleanup
exit 0
else
# If the user cancelled the merge and decided to wait until later,
# that's fine. But we have to acknowledge this by removing the
# MERGE_BASE file and continuing normal execution of the finish
rm -f "$GIT_DIR/.gitflow/MERGE_BASE"
fi
else
echo
echo "Merge conflicts not resolved yet, use:"
echo " git mergetool"
echo " git commit"
echo
echo "You can then complete the finish by running it again:"
echo " git flow feature finish $NAME"
echo
exit 1
fi
fi
# sanity checks
gitflow_require_clean_working_tree
# update local repo with remote changes first, if asked
if [ $FLAG_FETCH -eq 1 ]; then
git fetch -q $ORIGIN $BRANCH
...
...
@@ -125,8 +167,32 @@ cmd_finish() {
git merge --no-ff $BRANCH
fi
if [ $? -ne 0 ]; then
# oops.. we have a merge conflict!
# write the given $BASE to a temporary file (we need it later)
mkdir -p "$GIT_DIR/.gitflow"
echo "$BASE" > "$GIT_DIR/.gitflow/MERGE_BASE"
echo
echo "There were merge conflicts. To resolve the merge conflict manually, use:"
echo " git mergetool"
echo " git commit"
echo
echo "You can then complete the finish by running it again:"
echo " git flow feature finish $NAME"
echo
exit 1
fi
# when no merge conflict is detected, just clean up the feature branch
helper_finish_cleanup
}
helper_finish_cleanup() {
# sanity checks
gitflow_require_branch $BRANCH
gitflow_check_clean_working_tree
# delete branch
# TODO: How do we handle merge conflicts here??
git push $ORIGIN :refs/heads/$BRANCH
git branch -d $BRANCH
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment