1

We are using git through sourcetree for a project involving HP UFT object repositories.

In our object repository files there is a date line, which is not automatically handled by git, so every time two repositories are merged we basically need to pick which date we want to keep. The date itself is never used and is not needed, and there is a date for every single object in the repository(~50 for each xml) so this is an annoying task.

Is there a way to make git ignore the date line? It doesn't matter if the date stays the way it was instead of being updated. Alternatively have git always overwrite the old date with the new date. It looks like this (norwegian date):

<qtpRep:LastUpdateTime>6. mai 2014 12:03:22</qtpRep:LastUpdateTime>

The object repository files are xml files created/updated through UFT which means that the code is autogenerated, hence the continous update of dates within these files.

Tim
  • 41,901
  • 18
  • 127
  • 145

2 Answers2

1

You could use a clear content filer in a .gitattributes file in order to

http://git-scm.com/figures/18333fig0703-tn.png

(From Pro Git Book)

That would allow, automatically on git add, to set the element <qtpRep:LastUpdateTime> content to a fixed value instead of the auto-generated one.

*.xml     filter=fixedDate

git config --global filter.fixedDate.clean cleanDate

The script declared in the "clean" fixedDate filter, here cleanDate, can parse the content of the file being added, and replace the date by a fixed one.

That script and the .gitattributes can be stored and distributed in the same git repo, but the filter needs to be activated by all users in order to be used consistently across all cloned repos.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

(How do I write complete comments? All I managed to do with comments on stackoverflow was to write a single continous line of text.)

I created a repository and added a file called .gitattributes with a single line:

*.xml filter=fixedDate

Then I ran the following in windows cmd:

git config --global filter.fixedDate.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'

This only returned the git config options. So I assume it ran correctly? Or does git return the options instead of an error message?

I then pushed an .xml file with the following content:

$Date: 123$

The file was pushed normally with no changes to the contents.

The explanation on http://git-scm.com/docs/gitattributes didn't really help much.

  • That filter would be applied on a `git commit` only. If you just push, it won't clean anything. Try to add everything again and commit, as in http://stackoverflow.com/a/1511273/6309 or http://stackoverflow.com/a/15646791/6309. – VonC May 15 '14 at 16:46
  • I did commit, I was not aware that I could push without commiting so I didn't mention it. – user3627566 May 19 '14 at 07:47
  • Ok, try a new commit, to see if the file is changed then (and if it is, then do a `git push`) – VonC May 19 '14 at 07:49