USAGE="[--quiet] add [-b branch] [-f|--force] [--reference <repository>] [--] <repository> [<path>]
or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: $dashless [--quiet] init [--] [<path>...]
- or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
+ or: $dashless [--quiet] update [--init] [-N|--no-fetch] [-f|--force] [--commit] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]
or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: $dashless [--quiet] foreach [--recursive] <command>
or: $dashless [--quiet] sync [--] [<path>...]"
command=
branch=
force=
+commit=
reference=
cached=
recursive=
(clear_local_git_env; cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b")
}
+#
+# Commit changed submodule gitlinks
+#
+# $1 = name-a;sha1-a;subsha1-a\n[name-b;sha1-b;subsha1-b\n...]
+#
+commit_changes()
+{
+ echo "commiting $1"
+ OIFS="$IFS"
+ IFS=";"
+ paths=$(echo "$1" |
+ while read name sm_path sha1 subsha1
+ do
+ echo "$sm_path"
+ done
+ )
+ names=$(echo "$1" |
+ while read name sm_path sha1 subsha1
+ do
+ printf ' %s' "$name"
+ done
+ )
+ summary="$(eval_gettext "Updated submodules:")$names"
+ body=$(echo "$1" |
+ while read name sm_path sha1 subsha1
+ do
+ if test "$name" = "$sm_path"
+ then
+ printf 'Changes to %s:\n\n' "$name"
+ else
+ printf 'Changes to %s (%s):\n\n' "$name" "$sm_path"
+ fi
+ (
+ clear_local_git_env
+ cd "$sm_path" &&
+ git shortlog "${sha1}..${subsha1}" ||
+ die "$(eval_gettext "Unable to generate shortlog in submodule path '\$sm_path'")"
+ )
+ done
+ )
+ IFS="$OIFS"
+ message="$(printf '%s\n\n%s\n' "$summary" "$body")"
+ echo "message: [$message]"
+ git commit -m "$message" $paths
+}
+
#
# Add a new submodule to the working tree, .gitmodules and the index
#
-f|--force)
force=$1
;;
+ --commit)
+ commit=1
+ ;;
-r|--rebase)
update="rebase"
;;
fi
cloned_modules=
+ changed_modules=
module_list "$@" | {
err=
while read mode sha1 stage sm_path
err="${err};$die_msg"
continue
fi
+
+ subsha1=$(clear_local_git_env; cd "$sm_path" &&
+ git rev-parse --verify HEAD) ||
+ die "$(eval_gettext "Unable to find new revision in submodule path '\$sm_path'")"
+
+ if test "$subsha1" != "$sha1"
+ then
+ changed_modules=$(printf '%s%s\n' "$changed_modules" "$name;$sm_path;$sha1;$subsha1")
+ fi
fi
if test -n "$recursive"
fi
done
+ if test -z "$err" -a -n "$commit" -a -n "$changed_modules"
+ then
+ commit_changes "$changed_modules"
+ fi
+
if test -n "$err"
then
OIFS=$IFS
)
'
+test_expect_success 'submodule update --commit --rebase should commit gitlink changes' '
+ (cd super/submodule &&
+ git reset --hard HEAD~1 &&
+ echo "local change" > local-file &&
+ git add local-file &&
+ test_tick &&
+ git commit -m "local change"
+ ) &&
+ (cd super &&
+ git submodule update --commit --rebase submodule &&
+ test "$(git log -1 --oneline)" = "cd69713 Updated submodules: submodule"
+ ) &&
+ (cd submodule &&
+ git remote add super-submodule ../super/submodule &&
+ git pull super-submodule master
+ )
+'
+
test_expect_success 'submodule update - rebase in .git/config' '
(cd super &&
git config submodule.submodule.update rebase