git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git submodule question
@ 2020-05-27 15:01 Laura Smith
  2020-06-10  6:02 ` Stefan Moch
  0 siblings, 1 reply; 2+ messages in thread
From: Laura Smith @ 2020-05-27 15:01 UTC (permalink / raw)
  To: git

Hi,

I'm using git submodule to pull some third-party config templates into my git tree, using the following:

git fetch  foobar-github master
git subtree pull --prefix software/files/perimiter_mail/foobar-github foobar-github master --squash

Now, the question is, when the upstream makes a new commit can I force pull that commit and make git overwrite any changes I've made in the subtree.

At the moment I get bitter complaints from git, e.g. :
CONFLICT (content): Merge conflict in....
Automatic merge failed; fix conflicts and then commit the result.

Basically, I want to make myslef an update script that force-pulls the latest upstream repo and then the script will take care of making the necessary modifications (the upstream puts placeholders in their repo, so my script would take care of replacing the placeholders with the real values so that everything works again)

Thanks !

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git submodule question
  2020-05-27 15:01 git submodule question Laura Smith
@ 2020-06-10  6:02 ` Stefan Moch
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Moch @ 2020-06-10  6:02 UTC (permalink / raw)
  To: Laura Smith, git

Laura Smith wrote:
> I'm using git submodule to pull some third-party config templates into my git tree, using the following:
>
> git fetch  foobar-github master
> git subtree pull --prefix software/files/perimiter_mail/foobar-github foobar-github master --squash
>
> Now, the question is, when the upstream makes a new commit can I force pull that commit and make git overwrite any changes I've made in the subtree.

(Side node: there is `git submodule` as well as `git subtree`, they
are similar in their goals, but work quite differently.)

I have not used subtree much, but from a first glance it seems to me
one would have to either (a) revert the own changes or (b) commit
checked out files from the last upstream version again prior to the
`git subtree pull` to get git subtree merge/pull deliver exactly the
files from new version the upstream repository into the subtree.
That would lead at least to a untidy history with a back and forth
of placeholders and replacements and scripting it could also be a
bit cumbersome.

However, /not/ changing the template files would also be a
possibility to generate your files:

> At the moment I get bitter complaints from git, e.g. :
> CONFLICT (content): Merge conflict in....
> Automatic merge failed; fix conflicts and then commit the result.
>
> Basically, I want to make myslef an update script that force-pulls the latest upstream repo and then the script will take care of making the necessary modifications (the upstream puts placeholders in their repo, so my script would take care of replacing the placeholders with the real values so that everything works again)

If you are going to write a script that replaces the placeholders in
the config templates, you could as well leave the whole subtree /as
it is/ in upstream (i.e. without replacement of placeholders) and
only use `git subtree pull` go get the upstream changes – without
conflicts from now on. (Or maybe only make structural changes to the
templates itself (e.g. added/removed blocks of text), if needed at
all. That should probably lead to fewer conflicts than changing the
placeholders in place.)

You can then use your script to generate /another/ file (with
replacement of placeholders) from each config template as part of
your build process or whatever is run from this repository. The
generated files may or may not be added to the repository (outside
of the subtree). If their content is reproducible (with templates,
script, and replacements), it is not necessarily needed to add them,
just regenerate them if needed or if their corresponding template
changed.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-10  6:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 15:01 git submodule question Laura Smith
2020-06-10  6:02 ` Stefan Moch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).