ansible/ansible-modules-core — pull request #55 by bibliotechy (2014-09-30 02:41:14+00:00)
Title: Add track submodule branches parameter

Was https://github.com/ansible/ansible/pull/7877
Allows user to decide if git submodule should track branches/tags or track commit hashes defined in the superproject.

Add track_branches parameter to the git module.

Defaults to track branches behavior.

Original Issue was https://github.com/ansible/ansible/issues/7030
##### Issue Type:

“Bug Report” / “Feature Idea”

##### Ansible Version:

ansible 1.6 (devel a5e7492c4f) last updated 2014/04/15 21:12:13 (GMT -400)

##### Environment:

Ubuntu 12.04

##### Summary:

Git submodule update is hard coded to track branches (always adds the `--remote` flag, assuming the git version is late enough to support tracking branches.

https://github.com/ansible/ansible/blob/1c9950678a8a226020c6a1a32d6a60f942495072/library/source_control/git#L423-424

I have a use case where we definitely want to track the sha1 recorded in the superproject, not a branch or tag of the submodule. I'm willing to put in a PR on this, but wonder about the best way to add in a choice on this. A submodule_remote parameter? Something else?

##### Steps To Reproduce:

In a git repo with submodules that are tracked by commit hash stored in the superproject rather than branch or tag, run

`git: repo=reponame dest=place/to/put/it`

##### Expected Results:

I'd expect all of my submodule repos to be checkout out on the commit stored in the the superproject.
##### Actual Results:

All of my submodule repos are be checkout out to the commit at the tip of the master branch.

If the submodules also do not use the label "master" for the master branch, it throws an error

` fatal: Needed a single revision `

` Unable to find current origin/master revision in submodule path`