Browse Source

Try to use git `submodule update --rebase` if available.

Change-Id: I4899850ad91c89a8bca49ca50c5883c64263bf0e
Reviewed-on: http://gerrit.dmdirc.com/397
Reviewed-by: Gregory Holmes <greboid@dmdirc.com>
Tested-by: Gregory Holmes <greboid@dmdirc.com>
tags/0.6.3b1
Shane Mc Cormack 14 years ago
parent
commit
9583cb571b
1 changed files with 17 additions and 10 deletions
  1. 17
    10
      updateSubModules.sh

+ 17
- 10
updateSubModules.sh View File

@@ -14,7 +14,7 @@ ${GIT} submodule status | while read -r LINE; do
14 14
 	
15 15
 	# If the module hasn't been checked out yet, then checkout.
16 16
 	if [ "${MISSING}" != "" ]; then
17
-		${GIT} submodule update ${MODULE}
17
+		${GIT} submodule update -- ${MODULE}
18 18
 		if [ ${?} -ne 0 ]; then
19 19
 			echo "Error: Unable to update submodule ${MODULE}, aborting."
20 20
 			exit 1;
@@ -26,15 +26,22 @@ ${GIT} submodule status | while read -r LINE; do
26 26
 	#   - If there are commited revisions on top of the submodule, then they will
27 27
 	#     be rebased onto the revision used upstream,
28 28
 	elif [ "${CHANGED}" != "" ]; then
29
-		# Get the revision used upstream
30
-		OLDREV=`git diff ${MODULE} | grep -- "-Subproject" | awk '{print $3}'`
31
-		if [ "${OLDREV}" != "" ]; then
32
-			cd ${MODULE}
33
-			${GIT} fetch origin 
34
-			${GIT} rebase ${OLDREV}
35
-			if [ ${?} -ne 0 ]; then
36
-				echo "Error: Rebase failed on ${MODULE}, continuing with current HEAD."
37
-				${GIT} rebase --abort
29
+		# Try using git to do this. (1.6.4+)
30
+		${GIT} submodule update --rebase -- ${MODULE}
31
+
32
+		# Check to see if the above command worked, if not then do it
33
+                # manually.
34
+		if [ "${?}" -ne 0 ]; then
35
+			# Get the revision used upstream
36
+			OLDREV=`git diff ${MODULE} | grep -- "-Subproject" | awk '{print $3}'`
37
+			if [ "${OLDREV}" != "" ]; then
38
+				cd ${MODULE}
39
+				${GIT} fetch origin
40
+				${GIT} rebase ${OLDREV}
41
+				if [ ${?} -ne 0 ]; then
42
+					echo "Error: Rebase failed on ${MODULE}, continuing with current HEAD."
43
+					${GIT} rebase --abort
44
+				fi;
38 45
 			fi;
39 46
 		fi;
40 47
 	fi;

Loading…
Cancel
Save